Skip to content

Commit

Permalink
Add timeout for git status command.
Browse files Browse the repository at this point in the history
0.8s is an empirically good value here; prevents the prompt for hanging
on big repos that aren't cached.
  • Loading branch information
ericonr committed Jul 17, 2021
1 parent fe592ae commit 2bf4d41
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions git.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ void print_git(void *arg)
}
}


void free_git(void *arg)
{
struct git_info *git_info = arg;
Expand Down Expand Up @@ -117,7 +116,7 @@ static void *get_git_status(void *arg)
{
struct git_info *git_info = arg;

FILE *f = popen("git status --porcelain=v1 -z 2>/dev/null", "re");
FILE *f = popen("timeout 0.8s git status --porcelain=v1 -z 2>/dev/null", "re");
if (!f)
return NULL;

Expand Down

0 comments on commit 2bf4d41

Please sign in to comment.