提交 68889b41 编写于 作者: J John Keeping 提交者: Junio C Hamano

rev-parse: remove restrictions on some options

The "--local-env-vars" and "--resolve-git-dir" arguments to
git-rev-parse are currently only handled if they appear first on the
command line (in the case of "--local-env-vars", only if it is the only
argument).  While it may not make sense to use these options when any
others are specified, there is no reason for this restriction and it
might confuse users if these arguments appear to be ignored.

There is no need for any documentation change here as the restrictions
on these options are not documented.
Signed-off-by: NJohn Keeping <john@keeping.me.uk>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 31fe4057
...@@ -479,21 +479,6 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix) ...@@ -479,21 +479,6 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
if (argc > 1 && !strcmp("--sq-quote", argv[1])) if (argc > 1 && !strcmp("--sq-quote", argv[1]))
return cmd_sq_quote(argc - 2, argv + 2); return cmd_sq_quote(argc - 2, argv + 2);
if (argc == 2 && !strcmp("--local-env-vars", argv[1])) {
int i;
for (i = 0; local_repo_env[i]; i++)
printf("%s\n", local_repo_env[i]);
return 0;
}
if (argc > 2 && !strcmp(argv[1], "--resolve-git-dir")) {
const char *gitdir = resolve_gitdir(argv[2]);
if (!gitdir)
die("not a gitdir '%s'", argv[2]);
puts(gitdir);
return 0;
}
if (argc > 1 && !strcmp("-h", argv[1])) if (argc > 1 && !strcmp("-h", argv[1]))
usage(builtin_rev_parse_usage); usage(builtin_rev_parse_usage);
...@@ -647,6 +632,12 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix) ...@@ -647,6 +632,12 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
for_each_remote_ref(show_reference, NULL); for_each_remote_ref(show_reference, NULL);
continue; continue;
} }
if (!strcmp(arg, "--local-env-vars")) {
int i;
for (i = 0; local_repo_env[i]; i++)
printf("%s\n", local_repo_env[i]);
continue;
}
if (!strcmp(arg, "--show-toplevel")) { if (!strcmp(arg, "--show-toplevel")) {
const char *work_tree = get_git_work_tree(); const char *work_tree = get_git_work_tree();
if (work_tree) if (work_tree)
...@@ -697,6 +688,13 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix) ...@@ -697,6 +688,13 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
printf("%s%s.git\n", cwd, len && cwd[len-1] != '/' ? "/" : ""); printf("%s%s.git\n", cwd, len && cwd[len-1] != '/' ? "/" : "");
continue; continue;
} }
if (!strcmp(arg, "--resolve-git-dir")) {
const char *gitdir = resolve_gitdir(argv[i+1]);
if (!gitdir)
die("not a gitdir '%s'", argv[i+1]);
puts(gitdir);
continue;
}
if (!strcmp(arg, "--is-inside-git-dir")) { if (!strcmp(arg, "--is-inside-git-dir")) {
printf("%s\n", is_inside_git_dir() ? "true" printf("%s\n", is_inside_git_dir() ? "true"
: "false"); : "false");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册