Skip to content

Commit

Permalink
Add 'git rev-parse --show-toplevel' option.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Steven Drake authored and Junio C Hamano committed Jan 12, 2010
1 parent 902f235 commit 7cceca5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Documentation/git-rev-parse.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions builtin-rev-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7cceca5

Please sign in to comment.