summaryrefslogtreecommitdiff
path: root/builtin/rev-parse.c
diff options
context:
space:
mode:
authorFredrik Gustafsson <iveqy@iveqy.com>2011-08-15 23:17:46 +0200
committerJunio C Hamano <gitster@pobox.com>2011-08-16 11:04:31 -0700
commitabc06822af57347d35c0cd64b67e1faeb5b65c71 (patch)
tree6a6484a355e2e5b0a8b7b839c0e3ea6b1bd67457 /builtin/rev-parse.c
parente7a85be3cfc4ee017f59f1d1f8ceb63d7c88c9c8 (diff)
downloadgit-abc06822af57347d35c0cd64b67e1faeb5b65c71.tar.gz
rev-parse: add option --resolve-git-dir <path>
Check if <path> is a valid git-dir or a valid git-file that points to a valid git-dir. We want tests to be independent from the fact that a git-dir may be a git-file. Thus we changed tests to use this feature. Signed-off-by: Fredrik Gustafsson <iveqy@iveqy.com> Mentored-by: Jens Lehmann <Jens.Lehmann@web.de> Mentored-by: Heiko Voigt <hvoigt@hvoigt.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/rev-parse.c')
-rw-r--r--builtin/rev-parse.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 4c19f844a9..98d1cbecca 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -468,6 +468,14 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
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]))
usage(builtin_rev_parse_usage);