From: Junio C Hamano Date: Fri, 20 Mar 2015 20:11:46 +0000 (-0700) Subject: Merge branch 'kn/git-cd-to-empty' X-Git-Tag: v2.4.0-rc0~38 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/d6c988ddfacd49edf1eb16084af36062d8eb7121?ds=inline;hp=-c Merge branch 'kn/git-cd-to-empty' "git -C '' subcmd" refused to work in the current directory, unlike "cd ''" which silently behaves as a no-op. * kn/git-cd-to-empty: git: treat "git -C ''" as a no-op when is empty --- d6c988ddfacd49edf1eb16084af36062d8eb7121 diff --combined git.c index 8b5659b208,fdea110407..42a4ee5784 --- a/git.c +++ b/git.c @@@ -6,7 -6,7 +6,7 @@@ const char git_usage_string[] = "git [--version] [--help] [-C ] [-c name=value]\n" " [--exec-path[=]] [--html-path] [--man-path] [--info-path]\n" - " [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]\n" + " [-p | --paginate | --no-pager] [--no-replace-objects] [--bare]\n" " [--git-dir=] [--work-tree=] [--namespace=]\n" " []"; @@@ -204,10 -204,12 +204,12 @@@ static int handle_options(const char ** 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 { @@@ -618,7 -620,6 +620,7 @@@ int main(int argc, char **av { const char **argv = (const char **) av; const char *cmd; + int done_help = 0; startup_info = &git_startup_info; @@@ -681,7 -682,9 +683,7 @@@ setup_path(); while (1) { - static int done_help = 0; - static int was_alias = 0; - was_alias = run_argv(&argc, &argv); + int was_alias = run_argv(&argc, &argv); if (errno != ENOENT) break; if (was_alias) {