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>maint
parent
cdb3950801
commit
7a3dd472ad
12
rev-parse.c
12
rev-parse.c
|
@ -151,6 +151,12 @@ static void show_datestring(const char *flag, const char *datestr)
|
||||||
show(buffer);
|
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 main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int i, as_is = 0, verify = 0;
|
int i, as_is = 0, verify = 0;
|
||||||
|
@ -162,7 +168,7 @@ int main(int argc, char **argv)
|
||||||
char *dotdot;
|
char *dotdot;
|
||||||
|
|
||||||
if (as_is) {
|
if (as_is) {
|
||||||
show(arg);
|
show_file(arg);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (*arg == '-') {
|
if (*arg == '-') {
|
||||||
|
@ -282,9 +288,7 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
if (verify)
|
if (verify)
|
||||||
die("Needed a single revision");
|
die("Needed a single revision");
|
||||||
if ((filter & (DO_NONFLAGS|DO_NOREV)) ==
|
show_file(arg);
|
||||||
(DO_NONFLAGS|DO_NOREV))
|
|
||||||
show(arg);
|
|
||||||
}
|
}
|
||||||
show_default();
|
show_default();
|
||||||
if (verify && revs_count != 1)
|
if (verify && revs_count != 1)
|
||||||
|
|
Loading…
Reference in New Issue