{"thread":{"id":"12406","subject":"git diff-index --raw HEAD and git diff --raw HEAD output the same thing?","startedAt":"2008-03-01T13:10:03Z","lastAt":"2008-03-02T06:07:18Z","messageCount":6,"participants":["Ping Yin","Johannes Schindelin","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"70519","messageId":"46dff0320803010510q67bc4101k9f85c71e5d20b4@mail.gmail.com","threadId":"12406","inReplyTo":null,"subject":"git diff-index --raw HEAD and git diff --raw HEAD output the same thing?","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2008-03-01T13:10:03Z","receivedAt":"2008-03-01T13:10:03Z","isPatch":false,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"Does these two commands output the same content except displaying format?\n\nFollwoing is my test\n\n$ git diff-index --raw HEAD\n:160000 000000 ad1e416e87dc02617de68c41bb18e5abf0e24729\n0000000000000000000000000000000000000000 D      WordBreak\n:160000 160000 34f279b1662a6bef6a8fdea1827bbdbd80f12444\n0000000000000000000000000000000000000000 M      commonmake\n:160000 100644 c517f783d9efb5a8d24f80fb67f644a39afec2a6\ne69de29bb2d1d6434b8b29ae775ad8c2e48c5391 T      util\n\n$ git diff --raw HEAD\n:160000 000000 ad1e416e87dc02617de68c41bb18e5abf0e24729 0000000... D\n WordBreak\n:160000 160000 34f279b1662a6bef6a8fdea1827bbdbd80f12444\nc1f46b3f10cc041e196c388490ddb049dacc7dc0 M      commonmake\n:160000 100644 c517f783d9efb5a8d24f80fb67f644a39afec2a6 e69de29... T    util\n\nStrange things is this line\n:160000 160000 34f279b1662a6bef6a8fdea1827bbdbd80f12444\n0000000000000000000000000000000000000000 M      commonmake\n\nwhy mod is 160000 while sha1 is 0000...\n\n-- \nPing Yin\n"},{"id":"70530","messageId":"alpine.LSU.1.00.0803011320100.22527@racer.site","threadId":"12406","inReplyTo":"46dff0320803010510q67bc4101k9f85c71e5d20b4@mail.gmail.com","subject":"Re: git diff-index --raw HEAD and git diff --raw HEAD output the same thing?","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-03-01T13:21:02Z","receivedAt":"2008-03-01T13:21:02Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 1 Mar 2008, Ping Yin wrote:\n\n> Strange things is this line\n> :160000 160000 34f279b1662a6bef6a8fdea1827bbdbd80f12444\n> 0000000000000000000000000000000000000000 M      commonmake\n> \n> why mod is 160000 while sha1 is 0000...\n\nThis indicates that a submodule (160000) was deleted (00000).  It is \neasier not to handle a deletion as mode change...\n\nCiao,\nDscho\n\n"},{"id":"70578","messageId":"46dff0320803012122r7e97f486m9e4970c81455cdf6@mail.gmail.com","threadId":"12406","inReplyTo":"46dff0320803010545n775f1441x579a53a8c07d0892@mail.gmail.com","subject":"Fwd: git diff-index --raw HEAD and git diff --raw HEAD output the same thing?","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2008-03-02T05:22:52Z","receivedAt":"2008-03-02T05:22:52Z","isPatch":false,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"Sorry i have forgotten to cc git list\n\n\n---------- Forwarded message ----------\nFrom: Ping Yin <pkufranky@gmail.com>\nDate: Sat, Mar 1, 2008 at 9:45 PM\nSubject: Re: git diff-index --raw HEAD and git diff --raw HEAD output\nthe same thing?\nTo: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n\n\n\nOn Sat, Mar 1, 2008 at 9:21 PM, Johannes Schindelin\n <Johannes.Schindelin@gmx.de> wrote:\n > Hi,\n >\n >\n >  On Sat, 1 Mar 2008, Ping Yin wrote:\n >\n >  > Strange things is this line\n >  > :160000 160000 34f279b1662a6bef6a8fdea1827bbdbd80f12444\n >  > 0000000000000000000000000000000000000000 M      commonmake\n >  >\n >  > why mod is 160000 while sha1 is 0000...\n >\n >  This indicates that a submodule (160000) was deleted (00000).  It is\n >  easier not to handle a deletion as mode change...\n >\n No, it isn't deleted, git diff --raw HEAD shows the right result\n And why do diff and diff-index show different result?\n $ git status\n # On branch master\n # Changes to be committed:\n #   (use \"git reset HEAD <file>...\" to unstage)\n #\n #       deleted:    WordBreak\n #       typechange: util\n #\n # Changed but not updated:\n #   (use \"git add <file>...\" to update what will be committed)\n #\n #       modified:   commonmake\n >  Ciao,\n >  Dscho\n >\n >\n\n\n\n --\n Ping Yin\n"},{"id":"70579","messageId":"46dff0320803012124m415516cbof1f3056773843455@mail.gmail.com","threadId":"12406","inReplyTo":"46dff0320803010510q67bc4101k9f85c71e5d20b4@mail.gmail.com","subject":"Re: git diff-index --raw HEAD and git diff --raw HEAD output the same thing?","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2008-03-02T05:24:03Z","receivedAt":"2008-03-02T05:24:03Z","isPatch":false,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"On Sat, Mar 1, 2008 at 9:10 PM, Ping Yin <pkufranky@gmail.com> wrote:\n> Does these two commands output the same content except displaying format?\n>\n>  Follwoing is my test\n>\n>  $ git diff-index --raw HEAD\n>  :160000 000000 ad1e416e87dc02617de68c41bb18e5abf0e24729\n>  0000000000000000000000000000000000000000 D      WordBreak\n>  :160000 160000 34f279b1662a6bef6a8fdea1827bbdbd80f12444\n>  0000000000000000000000000000000000000000 M      commonmake\n>  :160000 100644 c517f783d9efb5a8d24f80fb67f644a39afec2a6\n>  e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 T      util\n>\n>  $ git diff --raw HEAD\n>  :160000 000000 ad1e416e87dc02617de68c41bb18e5abf0e24729 0000000... D\n>   WordBreak\n>  :160000 160000 34f279b1662a6bef6a8fdea1827bbdbd80f12444\n>  c1f46b3f10cc041e196c388490ddb049dacc7dc0 M      commonmake\n>  :160000 100644 c517f783d9efb5a8d24f80fb67f644a39afec2a6 e69de29... T    util\n>\n>  Strange things is this line\n>  :160000 160000 34f279b1662a6bef6a8fdea1827bbdbd80f12444\n>  0000000000000000000000000000000000000000 M      commonmake\n>\n>  why mod is 160000 while sha1 is 0000...\n>\n>  --\n>  Ping Yin\n>\n\nAny more response? Is this a bug or my misunderstanding?\n\n\n-- \nPing Yin\n"},{"id":"70581","messageId":"7vbq5xvfpk.fsf@gitster.siamese.dyndns.org","threadId":"12406","inReplyTo":"alpine.LSU.1.00.0803011320100.22527@racer.site","subject":"Re: git diff-index --raw HEAD and git diff --raw HEAD output the same thing?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-03-02T05:48:39Z","receivedAt":"2008-03-02T05:48:39Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> On Sat, 1 Mar 2008, Ping Yin wrote:\n>\n>> Strange things is this line\n>> :160000 160000 34f279b1662a6bef6a8fdea1827bbdbd80f12444\n>> 0000000000000000000000000000000000000000 M      commonmake\n>> \n>> why mod is 160000 while sha1 is 0000...\n>\n> This indicates that a submodule (160000) was deleted (00000).  It is \n> easier not to handle a deletion as mode change...\n\nRead the question again.\n\nWhen you compare something with a work tree state, and when the work tree\nstate is dirty, we always show 0{40} to mean \"it is dirty and we do not\nknow what the object name of that thing is, until you actuallly run\ngit-update-index (or git-add) it\" (and at that point it would stop being\ndirty).  For blobs (be it a regular file or a symbolic link), this has an\nadvantage of not having to run hash-object to obtain the object name of an\nobject that would be created if you actually did git-add it.\n\nWhen we check if it is dirty, we already do an lstat(2) and know the type\nof it, so we can show the mode bits.  So you will see 100644, 100755 or\n120000 for blobs.  Similarly for a submodule.\n\nFor a submodule, we could read the value from $sub/.git/HEAD, but it is\nmore consistent to show 0{40} on the work tree side (typically the right\nhand side, unless you use -R).\n\n\n"},{"id":"70583","messageId":"46dff0320803012207g450f7447h7266a059194709f0@mail.gmail.com","threadId":"12406","inReplyTo":"7vbq5xvfpk.fsf@gitster.siamese.dyndns.org","subject":"Re: git diff-index --raw HEAD and git diff --raw HEAD output the same thing?","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2008-03-02T06:07:18Z","receivedAt":"2008-03-02T06:07:18Z","isPatch":false,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"On Sun, Mar 2, 2008 at 1:48 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n>\n>  > On Sat, 1 Mar 2008, Ping Yin wrote:\n>  >\n>  >> Strange things is this line\n>  >> :160000 160000 34f279b1662a6bef6a8fdea1827bbdbd80f12444\n>  >> 0000000000000000000000000000000000000000 M      commonmake\n>  >>\n>  >> why mod is 160000 while sha1 is 0000...\n>  >\n>  > This indicates that a submodule (160000) was deleted (00000).  It is\n>  > easier not to handle a deletion as mode change...\n>\n>  Read the question again.\n>\n>  When you compare something with a work tree state, and when the work tree\n>  state is dirty, we always show 0{40} to mean \"it is dirty and we do not\n>  know what the object name of that thing is, until you actuallly run\n>  git-update-index (or git-add) it\" (and at that point it would stop being\n>  dirty).  For blobs (be it a regular file or a symbolic link), this has an\n>  advantage of not having to run hash-object to obtain the object name of an\n>  object that would be created if you actually did git-add it.\n>\n>  When we check if it is dirty, we already do an lstat(2) and know the type\n>  of it, so we can show the mode bits.  So you will see 100644, 100755 or\n>  120000 for blobs.  Similarly for a submodule.\n>\n>  For a submodule, we could read the value from $sub/.git/HEAD, but it is\n>  more consistent to show 0{40} on the work tree side (typically the right\n>  hand side, unless you use -R).\n>\nI should read the git-diff/git-diff-index man pages more carefully.  It says\n\"<sha1> is shown as all 0's if a file is new on the filesystem and it\nis out of sync with the index\"\n\nBut unlike git-diff-index, git-diff does the right thing for me\n\n$ git diff --raw HEAD\n:160000 160000 34f279b1662a6bef6a8fdea1827bbdbd80f12444\nc1f46b3f10cc041e196c388490ddb049dacc7dc0 M      commonmake\n\nwhile git diff-index desn't\n\n$ git diff-index --raw HEAD\n:160000 160000 34f279b1662a6bef6a8fdea1827bbdbd80f12444\n0000000000000000000000000000000000000000 M      commonmake\n\nMaybe the man page should clarify the different behaviour of git-diff.\n\nI really want the real sha1 instead of 0{40} in my submodule summary\npatch, or i have to use git-diff instead of git-diff-index\n\n-- \nPing Yin\n"}]}