Re: Can't git stash after using git add -N
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Mar 16, 2016, 11:09 UTC
- Message-ID
- <CACsJy8CtPAdJavKPLo3B-s-x5QVzAjNRqOM+MgbjpRbCOSGkXQ@mail.gmail.com>
- In-Reply-To
- <xmqqvb4n58ko.fsf@gitster.mtv.corp.google.com>
On Wed, Mar 16, 2016 at 11:51 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 8 quoted lines
> Josh Triplett <josh@joshtriplett.org> writes: > >> As far as I can tell, if I run "git add -N" on a file, and then commit >> without adding the file contents, it gets committed as an empty file. > > Is that true? Git once worked like that in earlier days, but I > think write-tree (hence commit) would simply ignore intent-to-add > entries from its resulting tree.
We have at least one problem, probably because of the confusion in diff code (I haven't checked further), which may be fixed once i re-fix d95d728 (diff-lib.c: adjust position of i-t-a entries in diff - 2015-03-16)
> /tmp $ git init a
Initialized empty Git repository in /tmp/a/.git/
> /tmp $ cd a > /tmp/a $ git ci --allow-empty -m 1
[master (root-commit) 4d8aed4] 1
> /tmp/a $ git add -N new
fatal: pathspec 'new' did not match any files
So far so good..
> /tmp/a $ touch new > /tmp/a $ git add -N new
OK let's delete "new" and trigger this problem
> /tmp/a $ rm new > /tmp/a $ git ci -m NOOOO
[master ce2e4bb] NOOOO
> /tmp/a $ git cat-file commit HEAD|grep ^tree
tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904
> /tmp/a $ git cat-file commit HEAD^|grep ^tree
tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904
The second commit should not be created. git-commit is somehow fooled that there's changes to commit.
-- Duy