#476595 git-add --allow-empty would be nice

Package:
git
Source:
git
Description:
fast, scalable, distributed revision control system
Submitter:
Guido Günther
Date:
2010-12-14 13:39:07 UTC
Severity:
wishlist
#476595#5
Date:
2008-04-17 14:09:25 UTC
From:
To:
Hi,
for #476347 it'd be nice to have a:
	git-add --allow-empty <filepattern>
(similar to git-commit) which wouldn't fail if filepattern doesn't match
any files in the current dir. This way we could still detect errors like
git-add being used outside of a git repo, unreadable files, etc.
Cheers,
 -- Guido

#476595#18
Date:
2010-12-14 13:35:33 UTC
From:
To:
tags 476595 + upstream wontfix
quit

Hi Guido,

Guido Günther wrote:

"git add" is for humans and its behavior and output are potential to
change as our understanding of humans improves; "git update-index" is
for machines, is dead simple, and should do better for this task, I
suspect.

It works like this:

1. Come up with a list of paths.  For example,

	git ls-files -c -o -- <pattern>

lists all files matching <pattern>.

	git ls-files -o --exclude-standard -- <pattern>

lists untracked files not excluded by .gitignore and matching
<pattern>.

2. Feed the paths to update-index.  For example,

	git ls-files -c -o -- <pattern> |
	git update-index --verbose --add --stdin

adds all paths matching <pattern> just like "git add <pattern>" would,
except it still works if some files matching <pattern> would have been
excluded by .gitignore and does not require a special case for the
empty list.

That said, thanks for reporting and please feel free to bring this up
on the git list[1] if update-index does not meet your needs.

[1] git@vger.kernel.org (no subscription needed --- the
convention is to always reply-to-all there).