git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Goffredo Baroncelli <kreijack@gmail.com>
To: git@vger.kernel.org, Goffredo Baroncelli <kreijack@gmail.com>
Subject: "git add" with several pathspecS and one doesn't match
Date: Wed, 14 Feb 2018 19:31:28 +0100	[thread overview]
Message-ID: <d5e4138e-d5d6-3a84-a222-8d0170a52ccb@gmail.com> (raw)

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

             reply	other threads:[~2018-02-14 18:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-14 18:31 Goffredo Baroncelli [this message]
2018-02-14 19:29 ` "git add" with several pathspecS and one doesn't match Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d5e4138e-d5d6-3a84-a222-8d0170a52ccb@gmail.com \
    --to=kreijack@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=kreijack@inwind.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).