{"thread":{"id":"23522","subject":"[QUESTION] or [BUG] Could not stash new bin files","startedAt":"2010-04-19T08:19:25Z","lastAt":"2010-04-19T12:41:17Z","messageCount":3,"participants":["Arnauld Van Muysewinkel","Jonathan Nieder","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"139878","messageId":"p2rc8485ef11004190119q590aea5dy516bdc3d222ebb51@mail.gmail.com","threadId":"23522","inReplyTo":null,"subject":"[QUESTION] or [BUG] Could not stash new bin files","fromName":"Arnauld Van Muysewinkel","fromEmail":"arnauldvm@gmail.com","sentAt":"2010-04-19T08:19:25Z","receivedAt":"2010-04-19T08:19:25Z","isPatch":false,"sender":{"key":"arnauldvm@gmail.com","avatar":null},"body":"I'm quite new to Git (using it since a few weeks only) and really like\nthis tool. This is a great improvement over Svn that I was using until\nnow. (Still using it for the company master repository though.)\n\nI have the following problem:\n\nI want to stash new files. I tried the combination \"git add\" / \"git\nstash\" but it does not work. Did I do something wrong, is it a special\ncase, or some kind of bug?\nDoes anybody have a clue?\n\nHere are the details:\n\n    $ git add -N XXX/src/jrxml/*.xls\n    $ git stash save --keep-index \"Improving performance of views\"\n    XXX/src/jrxml/SubCellMatrixCompared-EXPLAIN-new.xls: not added yet\n    XXX/src/jrxml/SubCellMatrixCompared-EXPLAIN-old.xls: not added yet\n    fatal: git-write-tree: error building trees\n    Cannot save the current index state\n    $ git status\n    # On branch MS9\n    # Changes to be committed:\n    #   (use \"git reset HEAD <file>...\" to unstage)\n    #\n    #       modified:   XXX/.settings/org.eclipse.wst.common.component\n    #       new file:   XXX/src/jrxml/SubCellMatrixCompared-EXPLAIN-new.xls\n    #       new file:   XXX/src/jrxml/SubCellMatrixCompared-EXPLAIN-old.xls\n    #\n    # Changed but not updated:\n    #   (use \"git add <file>...\" to update what will be committed)\n    #   (use \"git checkout -- <file>...\" to discard changes in working\ndirectory)\n    #\n    #       modified:   XXX/src/jrxml/SubCellMatrixCompared-EXPLAIN-new.xls\n    #       modified:   XXX/src/jrxml/SubCellMatrixCompared-EXPLAIN-old.xls\n    #\n    $ git version\n    git version 1.7.0.2.msysgit.0\n\nSpecificities:\n\n* I have a file in the index that I do not want to stash\n* The two new files are binary files\n* I'm running this on windows (msysgit)\n\nPlease tell me, should you need any extra information.\n\n-- \nArnauld Van Muysewinkel\n"},{"id":"139886","messageId":"20100419093523.GA26342@progeny.tock","threadId":"23522","inReplyTo":"p2rc8485ef11004190119q590aea5dy516bdc3d222ebb51@mail.gmail.com","subject":"Re: [QUESTION] or [BUG] Could not stash new bin files","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-04-19T09:35:23Z","receivedAt":"2010-04-19T09:35:23Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi Arnauld,\n\nArnauld Van Muysewinkel wrote:\n\n>     $ git add -N XXX/src/jrxml/*.xls\n>     $ git stash save --keep-index \"Improving performance of views\"\n>     XXX/src/jrxml/SubCellMatrixCompared-EXPLAIN-new.xls: not added yet\n>     XXX/src/jrxml/SubCellMatrixCompared-EXPLAIN-old.xls: not added yet\n>     fatal: git-write-tree: error building trees\n\nYes, this is a known problem [1].\n\nTo explain this requires a bit of a digression into how ‘git stash’\nworks.  It is a neat script (in commit f2c66ed1, when it was added, it\nwas only 160 lines or so), especially because it uses ordinary git\ncommits and reflogs to maintain its data.  You have probably seen what\nit looks like in gitk.  A particular stashed version looks like this:\n\n                        index\n                       /     \\\n  history ... --- HEAD ------- work tree\n\nand these are all ordinary commits.\n\nAn unsolved problem with this data structure is that it does not store\ninformation that can be stored in the index but not a commit.  This is\nthe case for the CE_INTENT_TO_ADD bit [2], and that it cannot be used\nin commits is very deliberate: trying to commit immediately after an\nadd -N is almost certainly a sign of a mistake.  See 331fcb598 (git\nadd --intent-to-add: do not let an empty blob be committed by\naccident, 2008-11-28) and the preceding commits for more on this.\n\nOne workaround is to make sure the intent-to-add bit is not set when\nstashing from such a state.  For example, you can ‘git add’ the file,\nor ‘git rm --cached’ it [3].\n\nI suspect the correct fix would be to use the commit message for the\nindex commit to record the intent to add.\n\n[...]\n> Specificities:\n> \n> * I have a file in the index that I do not want to stash\n\nCould you explain this further?  The stash currently saves everything\nabout the current state (except files not in the index nor HEAD).\n\n> * The two new files are binary files\n\nHope that helps,\nJonathan\n\n[1] See, for example, this discussion:\nhttp://thread.gmane.org/gmane.comp.version-control.git/127290\n\n[2] CE_VALID and CE_SKIP_WORKTREE also, but I suspect no one is\nworried about making stash track them.\n\n[3] If you use git rm and then stash, watch out for the following bug.\nhttp://thread.gmane.org/gmane.comp.version-control.git/145228\n"},{"id":"139893","messageId":"20100419124117.GA20184@coredump.intra.peff.net","threadId":"23522","inReplyTo":"20100419093523.GA26342@progeny.tock","subject":"Re: [QUESTION] or [BUG] Could not stash new bin files","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-04-19T12:41:17Z","receivedAt":"2010-04-19T12:41:17Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Apr 19, 2010 at 04:35:23AM -0500, Jonathan Nieder wrote:\n\n> >     $ git add -N XXX/src/jrxml/*.xls\n> >     $ git stash save --keep-index \"Improving performance of views\"\n> >     XXX/src/jrxml/SubCellMatrixCompared-EXPLAIN-new.xls: not added yet\n> >     XXX/src/jrxml/SubCellMatrixCompared-EXPLAIN-old.xls: not added yet\n> >     fatal: git-write-tree: error building trees\n> \n> Yes, this is a known problem [1].\n\nThanks for the pointer.\n\nRe-reading that thread, and considering the fact that this comes up so\nrarely, I think leaving it as an error is fine. We could possibly give a\nbit more advice on how to proceed, though.\n\n> > Specificities:\n> > \n> > * I have a file in the index that I do not want to stash\n> \n> Could you explain this further?  The stash currently saves everything\n> about the current state (except files not in the index nor HEAD).\n\nYeah, I'm not really sure why intent-to-add is being used here at all,\ninstead of regular \"git add\".\n\nBut if the real problem is wanting to stash part of your changes, then\nthe best thing is probably to use the interactive \"git stash -p\".\n\n> > * The two new files are binary files\n\nI don't think that is relevant here. The intent-to-add bit is the\nproblem.\n\n-Peff\n"}]}