Hi All,
I am facing this issue: I am ADDing some file with several pathspec, and one of
these fails. The results is that no file is added at all.
Simple test case:
$ git init .
$ touch 123.txt
$ git add "*.txt" "*.doc"
fatal: pathspec '*.doc' did not match any files
$ git status
[...]
Untracked files:
(use "git add <file>..." to include in what will be committed)
123.txt
[...]
Results: no file is added
Expected results: the files which match any pathspec should be added
Looking at the code, git works properly:
from builtins/add.c, near line 500
[...]
for (i = 0; i < pathspec.nr; i++) {
const char *path = pathspec.items[i].match;
if (pathspec.items[i].magic & PATHSPEC_EXCLUDE)
continue;
if (!seen[i] && path[0] &&
((pathspec.items[i].magic &
(PATHSPEC_GLOB | PATHSPEC_ICASE)) ||
!file_exists(path))) {
if (ignore_missing) {
int dtype = DT_UNKNOWN;
if (is_excluded(&dir, &the_index, path,
&dtype))
dir_add_ignored(&dir,
&the_index,
path,
pathspec.items[i].len);
} else
die(_("pathspec '%s' did not match any
files"),
pathspec.items[i].original);
}
}
It seems that if any pathspec doesn't match, all add action fails. Which is the
rationale of this choice ? I would expect that an error message would be
printed, but the matched files would be added.
My use case is the following: I use "git" as backup system, and I do something
like:
$ git add paths/*.doc
$ git add paths/*.pdf
$ git commit -m "bla bla"
I know that git is not the best method for that, however we have a lot of files
which are moved between different directories, and git seems to handle this job
quite nicely.
Unfortunately the filesystem is quite slow and quite huge, so I would prefer to
do a single "git add", in order to avoid to traverse all the filesystem more
times. But this would not work because if one pathspce fails, it prevents all
other pathspecs to success.
Please put me in CC because I am not subscribed.
BR
G.Baroncelli
--
gpg @keyserver.linux.it: Goffredo Baroncelli <kreijackATinwind.it>
Key fingerprint BBF5 1610 0B64 DAC6 5F7D 17B2 0EDA 9B37 8B82 E0B5