diff --git a/builtin-rev-parse.c b/builtin-rev-parse.c
index 37d02335212dea9672e2472970f66dc4ac95dfd1..88bad9af3caae741653e7836a0d53df9563e557c 100644 (file)
--- a/builtin-rev-parse.c
+++ b/builtin-rev-parse.c
"--all",
"--bisect",
"--dense",
"--all",
"--bisect",
"--dense",
+ "--branches=",
"--branches",
"--header",
"--max-age=",
"--branches",
"--header",
"--max-age=",
"--objects-edge",
"--parents",
"--pretty",
"--objects-edge",
"--parents",
"--pretty",
+ "--remotes=",
"--remotes",
"--remotes",
+ "--glob=",
"--sparse",
"--sparse",
+ "--tags=",
"--tags",
"--topo-order",
"--date-order",
"--tags",
"--topo-order",
"--date-order",
for_each_ref_in("refs/bisect/good", anti_reference, NULL);
continue;
}
for_each_ref_in("refs/bisect/good", anti_reference, NULL);
continue;
}
+ if (!prefixcmp(arg, "--branches=")) {
+ for_each_glob_ref_in(show_reference, arg + 11,
+ "refs/heads/", NULL);
+ continue;
+ }
if (!strcmp(arg, "--branches")) {
for_each_branch_ref(show_reference, NULL);
continue;
}
if (!strcmp(arg, "--branches")) {
for_each_branch_ref(show_reference, NULL);
continue;
}
+ if (!prefixcmp(arg, "--tags=")) {
+ for_each_glob_ref_in(show_reference, arg + 7,
+ "refs/tags/", NULL);
+ continue;
+ }
if (!strcmp(arg, "--tags")) {
for_each_tag_ref(show_reference, NULL);
continue;
}
if (!strcmp(arg, "--tags")) {
for_each_tag_ref(show_reference, NULL);
continue;
}
+ if (!prefixcmp(arg, "--glob=")) {
+ for_each_glob_ref(show_reference, arg + 7, NULL);
+ continue;
+ }
+ if (!prefixcmp(arg, "--remotes=")) {
+ for_each_glob_ref_in(show_reference, arg + 10,
+ "refs/remotes/", NULL);
+ continue;
+ }
if (!strcmp(arg, "--remotes")) {
for_each_remote_ref(show_reference, NULL);
continue;
}
if (!strcmp(arg, "--remotes")) {
for_each_remote_ref(show_reference, NULL);
continue;
}
+ if (!strcmp(arg, "--show-toplevel")) {
+ const char *work_tree = get_git_work_tree();
+ if (work_tree)
+ puts(work_tree);
+ continue;
+ }
if (!strcmp(arg, "--show-prefix")) {
if (prefix)
puts(prefix);
if (!strcmp(arg, "--show-prefix")) {
if (prefix)
puts(prefix);
if (!strcmp(arg, "--git-dir")) {
const char *gitdir = getenv(GIT_DIR_ENVIRONMENT);
static char cwd[PATH_MAX];
if (!strcmp(arg, "--git-dir")) {
const char *gitdir = getenv(GIT_DIR_ENVIRONMENT);
static char cwd[PATH_MAX];
+ int len;
if (gitdir) {
puts(gitdir);
continue;
if (gitdir) {
puts(gitdir);
continue;
}
if (!getcwd(cwd, PATH_MAX))
die_errno("unable to get current working directory");
}
if (!getcwd(cwd, PATH_MAX))
die_errno("unable to get current working directory");
- printf("%s/.git\n", cwd);
+ len = strlen(cwd);
+ printf("%s%s.git\n", cwd, len && cwd[len-1] != '/' ? "/" : "");
continue;
}
if (!strcmp(arg, "--is-inside-git-dir")) {
continue;
}
if (!strcmp(arg, "--is-inside-git-dir")) {