summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: be1295d)
raw | patch | inline | side by side (parent: be1295d)
author | Linus Torvalds <torvalds@osdl.org> | |
Mon, 27 Mar 2006 00:28:20 +0000 (16:28 -0800) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Mon, 27 Mar 2006 03:06:17 +0000 (19:06 -0800) |
When passing in a pathname pattern without the "--" separator on the
command line, we verify that the pathnames in question exist. However,
there were two bugs in that verification:
- git-rev-parse would only check the first pathname, and silently allow
any invalid subsequent pathname, whether it existed or not (which
defeats the purpose of the check, and is also inconsistent with what
git-rev-list actually does)
- git-rev-list (and "git log" etc) would check each filename, but if the
check failed, it would print the error using the first one, i.e.:
[torvalds@g5 git]$ git log Makefile bad-file
fatal: 'Makefile': No such file or directory
instead of saying that it's 'bad-file' that doesn't exist.
This fixes both bugs.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
command line, we verify that the pathnames in question exist. However,
there were two bugs in that verification:
- git-rev-parse would only check the first pathname, and silently allow
any invalid subsequent pathname, whether it existed or not (which
defeats the purpose of the check, and is also inconsistent with what
git-rev-list actually does)
- git-rev-list (and "git log" etc) would check each filename, but if the
check failed, it would print the error using the first one, i.e.:
[torvalds@g5 git]$ git log Makefile bad-file
fatal: 'Makefile': No such file or directory
instead of saying that it's 'bad-file' that doesn't exist.
This fixes both bugs.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
rev-parse.c | patch | blob | history | |
revision.c | patch | blob | history |
diff --git a/rev-parse.c b/rev-parse.c
index 19a5ef7f48a722c44a3534f281581f9a6ed08e84..f176c56f7f896df7d955d1f75e01c464f1aefaf0 100644 (file)
--- a/rev-parse.c
+++ b/rev-parse.c
struct stat st;
char *arg = argv[i];
char *dotdot;
-
+
if (as_is) {
- show_file(arg);
+ if (show_file(arg) && as_is < 2)
+ if (lstat(arg, &st) < 0)
+ die("'%s': %s", arg, strerror(errno));
continue;
}
if (!strcmp(arg,"-n")) {
if (*arg == '-') {
if (!strcmp(arg, "--")) {
- as_is = 1;
+ as_is = 2;
/* Pass on the "--" if we show anything but files.. */
if (filter & (DO_FLAGS | DO_REVS))
show_file(arg);
diff --git a/revision.c b/revision.c
index 12cd0529a5dfac9af01af0f47e895e9cf142c42a..d67718c75beecb2d411eb5cd4b051cbe0a274939 100644 (file)
--- a/revision.c
+++ b/revision.c
@@ -649,7 +649,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
/* If we didn't have a "--", all filenames must exist */
for (j = i; j < argc; j++) {
if (lstat(argv[j], &st) < 0)
- die("'%s': %s", arg, strerror(errno));
+ die("'%s': %s", argv[j], strerror(errno));
}
revs->prune_data = get_pathspec(revs->prefix, argv + i);
break;