From: "Ping Yin" <pkufranky@gmail.com>
To: "Junio C Hamano" <gitster@pobox.com>
Cc: "Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
"Git Mailing List" <git@vger.kernel.org>
Subject: Re: git diff-index --raw HEAD and git diff --raw HEAD output the same thing?
Date: Sun, 2 Mar 2008 14:07:18 +0800 [thread overview]
Message-ID: <46dff0320803012207g450f7447h7266a059194709f0@mail.gmail.com> (raw)
In-Reply-To: <7vbq5xvfpk.fsf@gitster.siamese.dyndns.org>
On Sun, Mar 2, 2008 at 1:48 PM, Junio C Hamano <gitster@pobox.com> wrote:
>
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>
> > On Sat, 1 Mar 2008, Ping Yin wrote:
> >
> >> Strange things is this line
> >> :160000 160000 34f279b1662a6bef6a8fdea1827bbdbd80f12444
> >> 0000000000000000000000000000000000000000 M commonmake
> >>
> >> why mod is 160000 while sha1 is 0000...
> >
> > This indicates that a submodule (160000) was deleted (00000). It is
> > easier not to handle a deletion as mode change...
>
> Read the question again.
>
> When you compare something with a work tree state, and when the work tree
> state is dirty, we always show 0{40} to mean "it is dirty and we do not
> know what the object name of that thing is, until you actuallly run
> git-update-index (or git-add) it" (and at that point it would stop being
> dirty). For blobs (be it a regular file or a symbolic link), this has an
> advantage of not having to run hash-object to obtain the object name of an
> object that would be created if you actually did git-add it.
>
> When we check if it is dirty, we already do an lstat(2) and know the type
> of it, so we can show the mode bits. So you will see 100644, 100755 or
> 120000 for blobs. Similarly for a submodule.
>
> For a submodule, we could read the value from $sub/.git/HEAD, but it is
> more consistent to show 0{40} on the work tree side (typically the right
> hand side, unless you use -R).
>
I should read the git-diff/git-diff-index man pages more carefully. It says
"<sha1> is shown as all 0's if a file is new on the filesystem and it
is out of sync with the index"
But unlike git-diff-index, git-diff does the right thing for me
$ git diff --raw HEAD
:160000 160000 34f279b1662a6bef6a8fdea1827bbdbd80f12444
c1f46b3f10cc041e196c388490ddb049dacc7dc0 M commonmake
while git diff-index desn't
$ git diff-index --raw HEAD
:160000 160000 34f279b1662a6bef6a8fdea1827bbdbd80f12444
0000000000000000000000000000000000000000 M commonmake
Maybe the man page should clarify the different behaviour of git-diff.
I really want the real sha1 instead of 0{40} in my submodule summary
patch, or i have to use git-diff instead of git-diff-index
--
Ping Yin
next prev parent reply other threads:[~2008-03-02 6:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-01 13:10 git diff-index --raw HEAD and git diff --raw HEAD output the same thing? Ping Yin
2008-03-01 13:21 ` Johannes Schindelin
[not found] ` <46dff0320803010545n775f1441x579a53a8c07d0892@mail.gmail.com>
2008-03-02 5:22 ` Fwd: " Ping Yin
2008-03-02 5:48 ` Junio C Hamano
2008-03-02 6:07 ` Ping Yin [this message]
2008-03-02 5:24 ` Ping Yin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=46dff0320803012207g450f7447h7266a059194709f0@mail.gmail.com \
--to=pkufranky@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).