On Thu, 18 May 2006, Junio C Hamano wrote:
Well, not good as-is. This makes it barf on this sequence:
$ rm -f junk
$ cd junk
$ git init-db
$ date >frotz
$ mkdir nitfol
$ date >nitfol/rezrov
$ git add . ;# OK up to this point - added everything.
$ git add . ;# This is bogus because...
fatal: pathspec '' did not match any files
Ahh. The empty pathspec is special.
It's special for a totally stupid reason: it's not a valid pathname, but
we obviously _turn_ it into a valid pathname when we read the directory
tree (ie from a filesystem standpoint, it means ".").
So then, when we do the "lstat()", we really _should_ have done the same.
If course, since the lstat() is there just to test for existence, and
since "." always exists, it's easier to just pass an empty match entirely
than to turn it into "." and then do an lstat that we know is going to
succeed.
So the patch would be something trivial like this..
Linus
---
diff --git a/builtin-add.c b/builtin-add.c
index 7083820..ac9ed2d 100644
--- a/builtin-add.c
+++ b/builtin-add.c
@@ -124,7 +124,7 @@ static void prune_directory(struct dir_s
/* Existing file? We must have ignored it */
match = pathspec[i];
- if (!lstat(match, &st))
+ if (!*match || !lstat(match, &st))
continue;
die("pathspec '%s' did not match any files", match);
}