From: Steven Drake Date: Mon, 11 Jan 2010 22:33:48 +0000 (+1300) Subject: Add 'git rev-parse --show-toplevel' option. X-Git-Tag: v1.7.0-rc0~76^2~1 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=7cceca5cccdcf1f0f9caa80b82d26fcff65e6fdf;p=git.git Add 'git rev-parse --show-toplevel' option. Shows the absolute path of the top-level working directory. Signed-off-by: Steven Drake Signed-off-by: Junio C Hamano --- diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt index 82045a252..dc829b333 100644 --- a/Documentation/git-rev-parse.txt +++ b/Documentation/git-rev-parse.txt @@ -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 diff --git a/builtin-rev-parse.c b/builtin-rev-parse.c index 37d023352..cbe5b428a 100644 --- a/builtin-rev-parse.c +++ b/builtin-rev-parse.c @@ -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);