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>
Linus Torvalds committed
Oct 18, 2005 at 00:16 UTC
7a3dd472ad2c69b7450a59eb2a35efb0698993d0
1 file changed
+8
-4
rev-parse.c
+8
-4
@@ -151,6 +151,12 @@ static void show_datestring(const char *flag, const char *datestr)
151
show(buffer);
152
}
153
154
+static void show_file(const char *arg)
155
+{
156
+ if ((filter & (DO_NONFLAGS|DO_NOREV)) == (DO_NONFLAGS|DO_NOREV))
157
+ show(arg);
158
+}
159
+
160
int main(int argc, char **argv)
161
{
162
int i, as_is = 0, verify = 0;
@@ -162,7 +168,7 @@ int main(int argc, char **argv)
168
char *dotdot;
169
170
if (as_is) {
165
- show(arg);
171
+ show_file(arg);
172
continue;
173
}
174
if (*arg == '-') {
@@ -282,9 +288,7 @@ int main(int argc, char **argv)
288
}
289
if (verify)
290
die("Needed a single revision");
285
- if ((filter & (DO_NONFLAGS|DO_NOREV)) ==
286
- (DO_NONFLAGS|DO_NOREV))
287
- show(arg);
291
+ show_file(arg);
292
}
293
show_default();
294
if (verify && revs_count != 1)