]> git.ipfire.org Git - thirdparty/git.git/blobdiff - git.c
git: treat "git -C '<path>'" as a no-op when <path> is empty
[thirdparty/git.git] / git.c
diff --git a/git.c b/git.c
index 6b5ae6a2ace7fffdd2ec50ce915ad5dc01a9c7da..fdea1104079d21ea00f408d4fd5fd36fce4b24a8 100644 (file)
--- a/git.c
+++ b/git.c
@@ -204,10 +204,12 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
                                fprintf(stderr, "No directory given for -C.\n" );
                                usage(git_usage_string);
                        }
-                       if (chdir((*argv)[1]))
-                               die_errno("Cannot change to '%s'", (*argv)[1]);
-                       if (envchanged)
-                               *envchanged = 1;
+                       if ((*argv)[1][0]) {
+                               if (chdir((*argv)[1]))
+                                       die_errno("Cannot change to '%s'", (*argv)[1]);
+                               if (envchanged)
+                                       *envchanged = 1;
+                       }
                        (*argv)++;
                        (*argc)--;
                } else {