summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1b0c1e6)
raw | patch | inline | side by side (parent: 1b0c1e6)
author | Linus Torvalds <torvalds@osdl.org> | |
Sun, 18 Sep 2005 18:18:30 +0000 (11:18 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sun, 18 Sep 2005 21:18:34 +0000 (14:18 -0700) |
Especially when you're deep inside the git repository, it's not all that
trivial for scripts to figure out where GIT_DIR is if it isn't set.
So add a flag to git-rev-parse to show where it is, since it will have
figured it out anyway.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
trivial for scripts to figure out where GIT_DIR is if it isn't set.
So add a flag to git-rev-parse to show where it is, since it will have
figured it out anyway.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
rev-parse.c | patch | blob | history |
diff --git a/rev-parse.c b/rev-parse.c
index 6d723f902aaff806431d5e47916dadba7af18a37..0f5630f95c4dc9ac257ea6c3b2f0e178af667ae5 100644 (file)
--- a/rev-parse.c
+++ b/rev-parse.c
puts(prefix);
continue;
}
+ if (!strcmp(arg, "--git-dir")) {
+ const char *gitdir = getenv(GIT_DIR_ENVIRONMENT);
+ static char cwd[PATH_MAX];
+ if (gitdir) {
+ puts(gitdir);
+ continue;
+ }
+ if (!prefix) {
+ puts(".git");
+ continue;
+ }
+ if (!getcwd(cwd, PATH_MAX))
+ die("unable to get current working directory");
+ printf("%s/.git\n", cwd);
+ continue;
+ }
if (verify)
die("Needed a single revision");
show_flag(arg);