Browse Source

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>
maint
Steven Drake 15 years ago committed by Junio C Hamano
parent
commit
7cceca5ccc
  1. 3
      Documentation/git-rev-parse.txt
  2. 6
      builtin-rev-parse.c

3
Documentation/git-rev-parse.txt

@ -112,6 +112,9 @@ OPTIONS @@ -112,6 +112,9 @@ OPTIONS
--remotes::
Show tag refs found in `$GIT_DIR/refs/remotes`.

--show-toplevel::
Show the absolute path of the top-level directory.

--show-prefix::
When the command is invoked from a subdirectory, show the
path of the current directory relative to the top-level

6
builtin-rev-parse.c

@ -581,6 +581,12 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix) @@ -581,6 +581,12 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
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);

Loading…
Cancel
Save