Add 'git rev-parse --show-toplevel' option.
Shows the absolute path of the top-level working directory. Signed-off-by: Steven Drake <sdrake@xnet.co.nz> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Steven Drake committed
Jan 12, 2010 at 11:33 UTC
7cceca5cccdcf1f0f9caa80b82d26fcff65e6fdf
2 files changed
+9
Documentation/git-rev-parse.txt
+3
@@ -112,6 +112,9 @@ OPTIONS
112
--remotes::
113
Show tag refs found in `$GIT_DIR/refs/remotes`.
114
115
+--show-toplevel::
116
+ Show the absolute path of the top-level directory.
117
+
118
--show-prefix::
119
When the command is invoked from a subdirectory, show the
120
path of the current directory relative to the top-level
builtin-rev-parse.c
+6
@@ -581,6 +581,12 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
581
for_each_remote_ref(show_reference, NULL);
582
continue;
583
}
584
+ if (!strcmp(arg, "--show-toplevel")) {
585
+ const char *work_tree = get_git_work_tree();
586
+ if (work_tree)
587
+ puts(work_tree);
588
+ continue;
589
+ }
590
if (!strcmp(arg, "--show-prefix")) {
591
if (prefix)
592
puts(prefix);