All of lore.kernel.org
 help / color / mirror / Atom feed
* [QUESTION] or [BUG] Could not stash new bin files
@ 2010-04-19  8:19 Arnauld Van Muysewinkel
  2010-04-19  9:35 ` Jonathan Nieder
  0 siblings, 1 reply; 3+ messages in thread
From: Arnauld Van Muysewinkel @ 2010-04-19  8:19 UTC (permalink / raw)
  To: git

I'm quite new to Git (using it since a few weeks only) and really like
this tool. This is a great improvement over Svn that I was using until
now. (Still using it for the company master repository though.)

I have the following problem:

I want to stash new files. I tried the combination "git add" / "git
stash" but it does not work. Did I do something wrong, is it a special
case, or some kind of bug?
Does anybody have a clue?

Here are the details:

    $ git add -N XXX/src/jrxml/*.xls
    $ git stash save --keep-index "Improving performance of views"
    XXX/src/jrxml/SubCellMatrixCompared-EXPLAIN-new.xls: not added yet
    XXX/src/jrxml/SubCellMatrixCompared-EXPLAIN-old.xls: not added yet
    fatal: git-write-tree: error building trees
    Cannot save the current index state
    $ git status
    # On branch MS9
    # Changes to be committed:
    #   (use "git reset HEAD <file>..." to unstage)
    #
    #       modified:   XXX/.settings/org.eclipse.wst.common.component
    #       new file:   XXX/src/jrxml/SubCellMatrixCompared-EXPLAIN-new.xls
    #       new file:   XXX/src/jrxml/SubCellMatrixCompared-EXPLAIN-old.xls
    #
    # Changed but not updated:
    #   (use "git add <file>..." to update what will be committed)
    #   (use "git checkout -- <file>..." to discard changes in working
directory)
    #
    #       modified:   XXX/src/jrxml/SubCellMatrixCompared-EXPLAIN-new.xls
    #       modified:   XXX/src/jrxml/SubCellMatrixCompared-EXPLAIN-old.xls
    #
    $ git version
    git version 1.7.0.2.msysgit.0

Specificities:

* I have a file in the index that I do not want to stash
* The two new files are binary files
* I'm running this on windows (msysgit)

Please tell me, should you need any extra information.

-- 
Arnauld Van Muysewinkel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [QUESTION] or [BUG] Could not stash new bin files
  2010-04-19  8:19 [QUESTION] or [BUG] Could not stash new bin files Arnauld Van Muysewinkel
@ 2010-04-19  9:35 ` Jonathan Nieder
  2010-04-19 12:41   ` Jeff King
  0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Nieder @ 2010-04-19  9:35 UTC (permalink / raw)
  To: Arnauld Van Muysewinkel; +Cc: git

Hi Arnauld,

Arnauld Van Muysewinkel wrote:

>     $ git add -N XXX/src/jrxml/*.xls
>     $ git stash save --keep-index "Improving performance of views"
>     XXX/src/jrxml/SubCellMatrixCompared-EXPLAIN-new.xls: not added yet
>     XXX/src/jrxml/SubCellMatrixCompared-EXPLAIN-old.xls: not added yet
>     fatal: git-write-tree: error building trees

Yes, this is a known problem [1].

To explain this requires a bit of a digression into how ‘git stash’
works.  It is a neat script (in commit f2c66ed1, when it was added, it
was only 160 lines or so), especially because it uses ordinary git
commits and reflogs to maintain its data.  You have probably seen what
it looks like in gitk.  A particular stashed version looks like this:

                        index
                       /     \
  history ... --- HEAD ------- work tree

and these are all ordinary commits.

An unsolved problem with this data structure is that it does not store
information that can be stored in the index but not a commit.  This is
the case for the CE_INTENT_TO_ADD bit [2], and that it cannot be used
in commits is very deliberate: trying to commit immediately after an
add -N is almost certainly a sign of a mistake.  See 331fcb598 (git
add --intent-to-add: do not let an empty blob be committed by
accident, 2008-11-28) and the preceding commits for more on this.

One workaround is to make sure the intent-to-add bit is not set when
stashing from such a state.  For example, you can ‘git add’ the file,
or ‘git rm --cached’ it [3].

I suspect the correct fix would be to use the commit message for the
index commit to record the intent to add.

[...]
> Specificities:
> 
> * I have a file in the index that I do not want to stash

Could you explain this further?  The stash currently saves everything
about the current state (except files not in the index nor HEAD).

> * The two new files are binary files

Hope that helps,
Jonathan

[1] See, for example, this discussion:
http://thread.gmane.org/gmane.comp.version-control.git/127290

[2] CE_VALID and CE_SKIP_WORKTREE also, but I suspect no one is
worried about making stash track them.

[3] If you use git rm and then stash, watch out for the following bug.
http://thread.gmane.org/gmane.comp.version-control.git/145228

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [QUESTION] or [BUG] Could not stash new bin files
  2010-04-19  9:35 ` Jonathan Nieder
@ 2010-04-19 12:41   ` Jeff King
  0 siblings, 0 replies; 3+ messages in thread
From: Jeff King @ 2010-04-19 12:41 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: Arnauld Van Muysewinkel, git

On Mon, Apr 19, 2010 at 04:35:23AM -0500, Jonathan Nieder wrote:

> >     $ git add -N XXX/src/jrxml/*.xls
> >     $ git stash save --keep-index "Improving performance of views"
> >     XXX/src/jrxml/SubCellMatrixCompared-EXPLAIN-new.xls: not added yet
> >     XXX/src/jrxml/SubCellMatrixCompared-EXPLAIN-old.xls: not added yet
> >     fatal: git-write-tree: error building trees
> 
> Yes, this is a known problem [1].

Thanks for the pointer.

Re-reading that thread, and considering the fact that this comes up so
rarely, I think leaving it as an error is fine. We could possibly give a
bit more advice on how to proceed, though.

> > Specificities:
> > 
> > * I have a file in the index that I do not want to stash
> 
> Could you explain this further?  The stash currently saves everything
> about the current state (except files not in the index nor HEAD).

Yeah, I'm not really sure why intent-to-add is being used here at all,
instead of regular "git add".

But if the real problem is wanting to stash part of your changes, then
the best thing is probably to use the interactive "git stash -p".

> > * The two new files are binary files

I don't think that is relevant here. The intent-to-add bit is the
problem.

-Peff

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-04-19 12:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-19  8:19 [QUESTION] or [BUG] Could not stash new bin files Arnauld Van Muysewinkel
2010-04-19  9:35 ` Jonathan Nieder
2010-04-19 12:41   ` Jeff King

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.