Skip to content

Commit fdeb89f

Browse files
committed
Merge branch 'sg/completion'
Clean-up and updates to command line completion (in contrib/). * sg/completion: (22 commits) completion: restore removed line continuating backslash completion: cache the path to the repository completion: extract repository discovery from __gitdir() completion: don't guard git executions with __gitdir() completion: consolidate silencing errors from git commands completion: don't use __gitdir() for git commands completion: respect 'git -C <path>' rev-parse: add '--absolute-git-dir' option completion: fix completion after 'git -C <path>' completion: don't offer commands when 'git --opt' needs an argument completion: list short refs from a remote given as a URL completion: don't list 'HEAD' when trying refs completion outside of a repo completion: list refs from remote when remote's name matches a directory completion: respect 'git --git-dir=<path>' when listing remote refs completion: fix most spots not respecting 'git --git-dir=<path>' completion: ensure that the repository path given on the command line exists completion tests: add tests for the __git_refs() helper function completion tests: check __gitdir()'s output in the error cases completion tests: consolidate getting path of current working directory completion tests: make the $cur variable local to the test helper functions ...
2 parents 015fba3 + 3ba0420 commit fdeb89f

File tree

5 files changed

+690
-168
lines changed

5 files changed

+690
-168
lines changed

Documentation/git-rev-parse.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,10 @@ If `$GIT_DIR` is not defined and the current directory
217217
is not detected to lie in a Git repository or work tree
218218
print a message to stderr and exit with nonzero status.
219219

220+
--absolute-git-dir::
221+
Like `--git-dir`, but its output is always the canonicalized
222+
absolute path.
223+
220224
--git-common-dir::
221225
Show `$GIT_COMMON_DIR` if defined, else `$GIT_DIR`.
222226

builtin/rev-parse.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -802,17 +802,27 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
802802
putchar('\n');
803803
continue;
804804
}
805-
if (!strcmp(arg, "--git-dir")) {
805+
if (!strcmp(arg, "--git-dir") ||
806+
!strcmp(arg, "--absolute-git-dir")) {
806807
const char *gitdir = getenv(GIT_DIR_ENVIRONMENT);
807808
char *cwd;
808809
int len;
809-
if (gitdir) {
810-
puts(gitdir);
811-
continue;
812-
}
813-
if (!prefix) {
814-
puts(".git");
815-
continue;
810+
if (arg[2] == 'g') { /* --git-dir */
811+
if (gitdir) {
812+
puts(gitdir);
813+
continue;
814+
}
815+
if (!prefix) {
816+
puts(".git");
817+
continue;
818+
}
819+
} else { /* --absolute-git-dir */
820+
if (!gitdir && !prefix)
821+
gitdir = ".git";
822+
if (gitdir) {
823+
puts(real_path(gitdir));
824+
continue;
825+
}
816826
}
817827
cwd = xgetcwd();
818828
len = strlen(cwd);

0 commit comments

Comments
 (0)