{"thread":{"id":"9386","subject":"git-diff new files (without using index)","startedAt":"2007-08-05T03:42:02Z","lastAt":"2007-08-05T04:37:19Z","messageCount":6,"participants":["Miles Bader","Shawn O. Pearce","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"49799","messageId":"87wswalkad.fsf@catnip.gol.com","threadId":"9386","inReplyTo":null,"subject":"git-diff new files (without using index)","fromName":"Miles Bader","fromEmail":"miles@gnu.org","sentAt":"2007-08-05T03:42:02Z","receivedAt":"2007-08-05T03:42:02Z","isPatch":false,"sender":{"key":"miles@gnu.org","avatar":"https://gravatar.com/avatar/01069b69593af7bff28e2f97afeb3644ae6fe2f5f56cb3a8cf34c5fb8c36efe5?d=mp&s=160"},"body":"One thing I often want to do is generate a complete diff of all changes,\nincluding new/removed files.\n\nIf I add things to the index, I can use \"git-diff --cached\" to do it;\nhowever I'd actually like to be able to do this _without_ updating the\nindex; in other words, any un-added new file as a change.  As it is, the\n\"non-indexed\" state seems kind of a second-class citizen, as you can\nnever have new files there (or rather, git will never really see them).\n\nIs there anyway to do this currently?  If not, maybe something like a\n\"git-diff -N\" (mirroring diff's -N/--new-file option) option could be\nadded to do this?\n\nThanks,\n\n-Miles\n-- \n=====\n(^o^;\n(()))\n*This is the cute octopus virus, please copy it into your sig so it can spread.\n"},{"id":"49801","messageId":"20070805035245.GE9527@spearce.org","threadId":"9386","inReplyTo":"87wswalkad.fsf@catnip.gol.com","subject":"Re: git-diff new files (without using index)","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-08-05T03:52:45Z","receivedAt":"2007-08-05T03:52:45Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Miles Bader <miles@gnu.org> wrote:\n> One thing I often want to do is generate a complete diff of all changes,\n> including new/removed files.\n> \n> If I add things to the index, I can use \"git-diff --cached\" to do it;\n> however I'd actually like to be able to do this _without_ updating the\n> index; in other words, any un-added new file as a change.  As it is, the\n> \"non-indexed\" state seems kind of a second-class citizen, as you can\n> never have new files there (or rather, git will never really see them).\n \nUse a temporary index:\n\n  (export GIT_INDEX_FILE=.git/tempindex;\n   cp .git/index $GIT_INDEX_FILE;\n   git add new-file;\n   git add other-new-file;\n   git diff --cached)\n\nWe pull this trick sometimes in internal tools, when we want to\nproduce some result but aren't sure we want to keep the resulting\nindex, or really know we don't want to keep the resulting index.\n\nAnother option is to just add everything, then reset the index:\n\n  git add new-file\n  git add other-new-file\n  git diff --cached\n  git reset\n\nGranted if you had other files staged they just became unstaged\nand will need to be restaged...  the temporary index trick above\navoids that.\n\n-- \nShawn.\n"},{"id":"49803","messageId":"87r6miljfr.fsf@catnip.gol.com","threadId":"9386","inReplyTo":"20070805035245.GE9527@spearce.org","subject":"Re: git-diff new files (without using index)","fromName":"Miles Bader","fromEmail":"miles@gnu.org","sentAt":"2007-08-05T04:00:24Z","receivedAt":"2007-08-05T04:00:24Z","isPatch":false,"sender":{"key":"miles@gnu.org","avatar":"https://gravatar.com/avatar/01069b69593af7bff28e2f97afeb3644ae6fe2f5f56cb3a8cf34c5fb8c36efe5?d=mp&s=160"},"body":"\"Shawn O. Pearce\" <spearce@spearce.org> writes:\n>> If I add things to the index, I can use \"git-diff --cached\" to do it;\n>> however I'd actually like to be able to do this _without_ updating the\n>> index\n>\n> Use a temporary index:\n...\n> Another option is to just add everything, then reset the index:\n...\n> Granted if you had other files staged they just became unstaged\n> and will need to be restaged...  the temporary index trick above\n> avoids that.\n\nThanks for the tip (I guess I can roll my own \"git-diff-uncached\"\nscript)!\n\nThe above sort of quirkiness does seem kind of a wart though; in my\n(admittedly limited, using git) experience this sort of thing really\nreduces the utility of the index, and I often end up feeling like it's\njust getting in the way as a result.  Does adding something like a\n\"git-diff -N\" option seem a _bad_ idea?\n\nThanks,\n\n-Miles\n\n-- \n\"Suppose He doesn't give a shit?  Suppose there is a God but He\njust doesn't give a shit?\"  [George Carlin]\n"},{"id":"49805","messageId":"20070805040841.GG9527@spearce.org","threadId":"9386","inReplyTo":"87r6miljfr.fsf@catnip.gol.com","subject":"Re: git-diff new files (without using index)","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-08-05T04:08:41Z","receivedAt":"2007-08-05T04:08:41Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Miles Bader <miles@gnu.org> wrote:\n> Thanks for the tip (I guess I can roll my own \"git-diff-uncached\"\n> script)!\n\nIndeed, Git is quite scriptable.  ;-)\n \n> The above sort of quirkiness does seem kind of a wart though; in my\n> (admittedly limited, using git) experience this sort of thing really\n> reduces the utility of the index, and I often end up feeling like it's\n> just getting in the way as a result.  Does adding something like a\n> \"git-diff -N\" option seem a _bad_ idea?\n\nI'm not interested in such an option.  Typically if I want a\ndiff on a new untracked file I actually want that file in my next\ncommit anyway.  So I'm usually staging it into the index along with\neverything else that I have modified.  In which case this quirkiness\nisn't really a quirk at all.  Its just not an issue to me.\n\nIf you want to try adding it, go right ahead.  The source for git\nis stored in git and available from many places.  :-)\n\n-- \nShawn.\n"},{"id":"49808","messageId":"7vd4y2ipd0.fsf@assigned-by-dhcp.cox.net","threadId":"9386","inReplyTo":"20070805040841.GG9527@spearce.org","subject":"Re: git-diff new files (without using index)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-08-05T04:20:43Z","receivedAt":"2007-08-05T04:20:43Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Shawn O. Pearce\" <spearce@spearce.org> writes:\n\n>> The above sort of quirkiness does seem kind of a wart though; in my\n>> (admittedly limited, using git) experience this sort of thing really\n>> reduces the utility of the index, and I often end up feeling like it's\n>> just getting in the way as a result.  Does adding something like a\n>> \"git-diff -N\" option seem a _bad_ idea?\n>\n> I'm not interested in such an option.  Typically if I want a\n> diff on a new untracked file I actually want that file in my next\n> commit anyway.\n\nI suspect that it's probably half superstition and half disease\nto wish for \"diff /dev/null new-file\".  Even CVS got this one\nright by saying \"is a new file, no diff available\".  The\ncontents of that new file is available in \"less new-file\" near\nyou anyway and it is quite pointless while you are working\ntoward next commit.  It just is not interesting, until you tell\ngit you _care_ about that file.  And the way you tell git about\nit is with \"git add\".\n\nLearn to love the index, run \"git-add\" and view \"git-diff HEAD\".\n"},{"id":"49813","messageId":"87abt6lhq8.fsf@catnip.gol.com","threadId":"9386","inReplyTo":"7vd4y2ipd0.fsf@assigned-by-dhcp.cox.net","subject":"Re: git-diff new files (without using index)","fromName":"Miles Bader","fromEmail":"miles@gnu.org","sentAt":"2007-08-05T04:37:19Z","receivedAt":"2007-08-05T04:37:19Z","isPatch":false,"sender":{"key":"miles@gnu.org","avatar":"https://gravatar.com/avatar/01069b69593af7bff28e2f97afeb3644ae6fe2f5f56cb3a8cf34c5fb8c36efe5?d=mp&s=160"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n> I suspect that it's probably half superstition and half disease\n> to wish for \"diff /dev/null new-file\".\n\nEr, please, a bit of consideration.  It's not superstition, it's not a disease.\n\nI _want to use the index_:  I want to stage changes, and then make more\nchanges, and just generally be able to treat these three states (HEAD,\nindexed, non-indexed) as points which can be used as inputs to git-diff\n-- and I want _applyable patch files_ as the output from git-diff, not\npretty diffs for browsing.\n\nThanks,\n\n-Miles\n\n-- \nAny man who is a triangle, has thee right, when in Cartesian Space, to\nhave angles, which when summed, come to know more, nor no less, than\nnine score degrees, should he so wish.  [TEMPLE OV THEE LEMUR]\n"}]}