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 ...
This commit is contained in:
@ -802,17 +802,27 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
|
||||
putchar('\n');
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(arg, "--git-dir")) {
|
||||
if (!strcmp(arg, "--git-dir") ||
|
||||
!strcmp(arg, "--absolute-git-dir")) {
|
||||
const char *gitdir = getenv(GIT_DIR_ENVIRONMENT);
|
||||
char *cwd;
|
||||
int len;
|
||||
if (gitdir) {
|
||||
puts(gitdir);
|
||||
continue;
|
||||
}
|
||||
if (!prefix) {
|
||||
puts(".git");
|
||||
continue;
|
||||
if (arg[2] == 'g') { /* --git-dir */
|
||||
if (gitdir) {
|
||||
puts(gitdir);
|
||||
continue;
|
||||
}
|
||||
if (!prefix) {
|
||||
puts(".git");
|
||||
continue;
|
||||
}
|
||||
} else { /* --absolute-git-dir */
|
||||
if (!gitdir && !prefix)
|
||||
gitdir = ".git";
|
||||
if (gitdir) {
|
||||
puts(real_path(gitdir));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
cwd = xgetcwd();
|
||||
len = strlen(cwd);
|
||||
|
Reference in New Issue
Block a user