From: Junio C Hamano <gitster@pobox.com>
To: Olaf Klischat <olaf.klischat@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: git diff <commit> doesn't quite work as documented?
Date: Fri, 08 Sep 2017 10:26:46 +0900 [thread overview]
Message-ID: <xmqqfuby0yll.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <0696f94d-28c2-1f4b-03ee-16553d97f318@gmail.com> (Olaf Klischat's message of "Thu, 7 Sep 2017 18:31:58 +0200")
Olaf Klischat <olaf.klischat@gmail.com> writes:
> `git diff --help' says:
>
> git diff [--options] <commit> [--] [<path>...]
> This form is to view the changes you have in your
> working tree relative to the named <commit>.
That help text is poorly phrased.
When "git diff" talks about files in your working tree, it always
looks them _through_ the index. As far as the command is concerned,
a cruft left in your working tree that is not in the index does
*not* exist.
So when your index does not have bar.txt, even if you have an
untracked bar.txt in your directory, i.e.
> oklischat@oklischat:/tmp/gittest$ git status
> On branch master
> Untracked files:
> (use "git add <file>..." to include in what will be committed)
>
> bar.txt
and you have a commit that _has_ that file, then the command thinks
<commit> has the path, and your working tree does *not*. IOW, this
is...
> oklischat@oklischat:/tmp/gittest$ git diff bar-added
> diff --git a/bar.txt b/bar.txt
> deleted file mode 100644
... totally expected and intended output.
Hope the above explanation clarifies. A documentation update might
be helpful to new users.
Thanks.
next prev parent reply other threads:[~2017-09-08 1:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-07 16:31 git diff <commit> doesn't quite work as documented? Olaf Klischat
2017-09-08 1:26 ` Junio C Hamano [this message]
2017-09-08 12:58 ` Michael J Gruber
2017-09-09 11:39 ` Yubin Ruan
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=xmqqfuby0yll.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=olaf.klischat@gmail.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 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.