Greg Ward avatar Greg Ward committed c0441ba

git: be more particular about interpreting the return value of system().
(In particular, < 0 means unable to fork/exec, not differences.)

Comments (0)

Files changed (1)

         if (context->options->show_modified) {
-            if (system("git diff --no-ext-diff --quiet --exit-code"))
+            int status = system("git diff --no-ext-diff --quiet --exit-code");
+            if (WEXITSTATUS(status) == 1)       /* files modified */
                 result->modified = 1;
+            /* any other outcome (including failure to fork/exec,
+               failure to run git, or diff error): assume no
+               modifications */
         if (context->options->show_unknown) {
-            if (!system("test -n \"$(git ls-files --others --exclude-standard)\""))
+            int status = system("test -n \"$(git ls-files --others --exclude-standard)\"");
+            if (WEXITSTATUS(status) == 0)
                 result->unknown = 1;
+            /* again, ignore other errors and assume no unknown files */
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.