aboutsummaryrefslogtreecommitdiff
path: root/rev-parse.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@osdl.org>2005-10-18 00:16:45 -0700
committerJunio C Hamano <junkio@cox.net>2005-10-18 00:16:45 -0700
commit7a3dd472ad2c69b7450a59eb2a35efb0698993d0 (patch)
tree62492363d710bbd6b532cbecf74f8743d8e87099 /rev-parse.c
parentcdb3950801fec8e9efa1607093a6e51737bacba0 (diff)
downloadgit-7a3dd472ad2c69b7450a59eb2a35efb0698993d0.tar.gz
git-7a3dd472ad2c69b7450a59eb2a35efb0698993d0.tar.xz
Avoid ambiguity between refname and filename in rev-parse
Although it really is very convenient, not requiring explicit '-r' option to name revs is sometimes ambiguous. Usually we allow a "--" to say where a filename starts when it _is_ ambiguous. However, we fail that at times. In particular, git-rev-parse fails it. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'rev-parse.c')
-rw-r--r--rev-parse.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/rev-parse.c b/rev-parse.c
index 41b9dae42..85230dfaa 100644
--- a/rev-parse.c
+++ b/rev-parse.c
@@ -151,6 +151,12 @@ static void show_datestring(const char *flag, const char *datestr)
show(buffer);
}
+static void show_file(const char *arg)
+{
+ if ((filter & (DO_NONFLAGS|DO_NOREV)) == (DO_NONFLAGS|DO_NOREV))
+ show(arg);
+}
+
int main(int argc, char **argv)
{
int i, as_is = 0, verify = 0;
@@ -162,7 +168,7 @@ int main(int argc, char **argv)
char *dotdot;
if (as_is) {
- show(arg);
+ show_file(arg);
continue;
}
if (*arg == '-') {
@@ -282,9 +288,7 @@ int main(int argc, char **argv)
}
if (verify)
die("Needed a single revision");
- if ((filter & (DO_NONFLAGS|DO_NOREV)) ==
- (DO_NONFLAGS|DO_NOREV))
- show(arg);
+ show_file(arg);
}
show_default();
if (verify && revs_count != 1)