summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c10d634)
raw | patch | inline | side by side (parent: c10d634)
author | Junio C Hamano <junkio@cox.net> | |
Fri, 23 Dec 2005 06:35:38 +0000 (22:35 -0800) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Fri, 23 Dec 2005 06:35:38 +0000 (22:35 -0800) |
When --show-prefix is useful, sometimes it is easier to cd up to
the toplevel of the tree. This is equivalent to:
git rev-parse --show-prefix | sed -e 's|[^/][^/]*|..|g'
but we do not have to invoke sed for that.
Signed-off-by: Junio C Hamano <junkio@cox.net>
the toplevel of the tree. This is equivalent to:
git rev-parse --show-prefix | sed -e 's|[^/][^/]*|..|g'
but we do not have to invoke sed for that.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Documentation/git-rev-parse.txt | patch | blob | history | |
rev-parse.c | patch | blob | history |
index 431b8f6e06194e302aac02fdf90522e6f5c04167..d638bfc202ef9ad0386d640cbf70b9cdb2fff665 100644 (file)
Show all refs found in `$GIT_DIR/refs`.
--show-prefix::
- When the command is invoked from a directory show the
+ When the command is invoked from a subdirectory, show the
path of the current directory relative to the top-level
directory.
+--show-cdup::
+ When the command is invoked from a subdirectory, show the
+ path of the top-level directory relative to the current
+ directory (typically a sequence of "../", or an empty string).
+
--since=datestring, --after=datestring::
Parses the date string, and outputs corresponding
--max-age= parameter for git-rev-list command.
diff --git a/rev-parse.c b/rev-parse.c
index bb4949ad70364abdf7c3bbca357e5ebc42880614..0c951af0d49da459fc6c85c32707b016bf581a57 100644 (file)
--- a/rev-parse.c
+++ b/rev-parse.c
puts(prefix);
continue;
}
+ if (!strcmp(arg, "--show-cdup")) {
+ const char *pfx = prefix;
+ while (pfx) {
+ pfx = strchr(pfx, '/');
+ if (pfx) {
+ pfx++;
+ printf("../");
+ }
+ }
+ putchar('\n');
+ continue;
+ }
if (!strcmp(arg, "--git-dir")) {
const char *gitdir = getenv(GIT_DIR_ENVIRONMENT);
static char cwd[PATH_MAX];