From: Junio C Hamano Date: Fri, 20 Sep 2013 19:35:42 +0000 (-0700) Subject: Merge branch 'nr/git-cd-to-a-directory' X-Git-Tag: v1.8.5-rc0~95 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/087350398e8b2c5d4b39f051b23a2e533f4d830b?ds=inline;hp=-c Merge branch 'nr/git-cd-to-a-directory' Just like "make -C ", make "git -C ..." to go there before doing anything else. * nr/git-cd-to-a-directory: t0056: "git -C" test updates git: run in a directory given with -C option --- 087350398e8b2c5d4b39f051b23a2e533f4d830b diff --combined Documentation/git.txt index c4f0ed5957,d6baf98f79..5d68d33e46 --- a/Documentation/git.txt +++ b/Documentation/git.txt @@@ -9,7 -9,7 +9,7 @@@ git - the stupid content tracke SYNOPSIS -------- [verse] - 'git' [--version] [--help] [-c =] + 'git' [--version] [--help] [-C ] [-c =] [--exec-path[=]] [--html-path] [--man-path] [--info-path] [-p|--paginate|--no-pager] [--no-replace-objects] [--bare] [--git-dir=] [--work-tree=] [--namespace=] @@@ -395,6 -395,20 +395,20 @@@ displayed. See linkgit:git-help[1] for because `git --help ...` is converted internally into `git help ...`. + -C :: + Run as if git was started in '' instead of the current working + directory. When multiple `-C` options are given, each subsequent + non-absolute `-C ` is interpreted relative to the preceding `-C + `. + + + This option affects options that expect path name like `--git-dir` and + `--work-tree` in that their interpretations of the path names would be + made relative to the working directory caused by the `-C` option. For + example the following invocations are equivalent: + + git --git-dir=a.git --work-tree=b -C c status + git --git-dir=c/a.git --work-tree=c/b status + -c =:: Pass a configuration parameter to the command. The value given will override values from configuration files. @@@ -457,25 -471,10 +471,25 @@@ linkgit:git-replace[1] for more information. --literal-pathspecs:: - Treat pathspecs literally, rather than as glob patterns. This is - equivalent to setting the `GIT_LITERAL_PATHSPECS` environment + Treat pathspecs literally (i.e. no globbing, no pathspec magic). + This is equivalent to setting the `GIT_LITERAL_PATHSPECS` environment variable to `1`. +--glob-pathspecs: + Add "glob" magic to all pathspec. This is equivalent to setting + the `GIT_GLOB_PATHSPECS` environment variable to `1`. Disabling + globbing on individual pathspecs can be done using pathspec + magic ":(literal)" + +--noglob-pathspecs: + Add "literal" magic to all pathspec. This is equivalent to setting + the `GIT_NOGLOB_PATHSPECS` environment variable to `1`. Enabling + globbing on individual pathspecs can be done using pathspec + magic ":(glob)" + +--icase-pathspecs: + Add "icase" magic to all pathspec. This is equivalent to setting + the `GIT_ICASE_PATHSPECS` environment variable to `1`. GIT COMMANDS ------------ @@@ -838,7 -837,7 +852,7 @@@ for further details 'GIT_FLUSH':: If this environment variable is set to "1", then commands such as 'git blame' (in incremental mode), 'git rev-list', 'git log', - 'git check-attr', 'git check-ignore', and 'git whatchanged' will + 'git check-attr' and 'git check-ignore' will force a flush of the output stream after each record have been flushed. If this variable is set to "0", the output of these commands will be done @@@ -882,18 -881,6 +896,18 @@@ GIT_LITERAL_PATHSPECS: literal paths to Git (e.g., paths previously given to you by `git ls-tree`, `--raw` diff output, etc). +GIT_GLOB_PATHSPECS:: + Setting this variable to `1` will cause Git to treat all + pathspecs as glob patterns (aka "glob" magic). + +GIT_NOGLOB_PATHSPECS:: + Setting this variable to `1` will cause Git to treat all + pathspecs as literal (aka "literal" magic). + +GIT_ICASE_PATHSPECS:: + Setting this variable to `1` will cause Git to treat all + pathspecs as case-insensitive. + Discussion[[Discussion]] ------------------------ diff --combined git.c index b3893e73c9,a2d99a7d82..1188979465 --- a/git.c +++ b/git.c @@@ -7,7 -7,7 +7,7 @@@ #include "commit.h" const char git_usage_string[] = - "git [--version] [--help] [-c name=value]\n" + "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" " [--git-dir=] [--work-tree=] [--namespace=]\n" @@@ -147,24 -147,23 +147,35 @@@ static int handle_options(const char ** setenv(GIT_LITERAL_PATHSPECS_ENVIRONMENT, "0", 1); if (envchanged) *envchanged = 1; + } else if (!strcmp(cmd, "--glob-pathspecs")) { + setenv(GIT_GLOB_PATHSPECS_ENVIRONMENT, "1", 1); + if (envchanged) + *envchanged = 1; + } else if (!strcmp(cmd, "--noglob-pathspecs")) { + setenv(GIT_NOGLOB_PATHSPECS_ENVIRONMENT, "1", 1); + if (envchanged) + *envchanged = 1; + } else if (!strcmp(cmd, "--icase-pathspecs")) { + setenv(GIT_ICASE_PATHSPECS_ENVIRONMENT, "1", 1); + if (envchanged) + *envchanged = 1; } else if (!strcmp(cmd, "--shallow-file")) { (*argv)++; (*argc)--; set_alternate_shallow_file((*argv)[0]); if (envchanged) *envchanged = 1; + } else if (!strcmp(cmd, "-C")) { + if (*argc < 2) { + 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; + (*argv)++; + (*argc)--; } else { fprintf(stderr, "Unknown option: %s\n", cmd); usage(git_usage_string);