Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Shaun Cutts <shaun@cuttshome.net>
Cc: git@vger.kernel.org
Subject: Re: git index: how does it work?
Date: Wed, 12 Aug 2009 13:31:24 -0700	[thread overview]
Message-ID: <7vab24ydsz.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: 436D5ED1-2F0E-4227-AC4A-3A5FD16B2DCF@cuttshome.net

Shaun Cutts <shaun@cuttshome.net> writes:

> Are renames being tracked by the index, and is there a more basic
> interface than "status" to query about them?

No.  Index, nor git in general, never records renames.  git records
contents, not content changes.  The index records a state, so does the
tree object pointed at by the HEAD commit.

When you ask for "status", git will notice that you have lost a file, and
added a new one, between these two states, by comparing them.  The
contents of these lost files and added files are then compared, and ones
with similar contents are paired up.

That way, you do not have to use "git mv A B" to "rename" A to B.  You can
just as well "mv A B; git rm A; git add B", and get the same outcome,
exactly because git does not record renames.

Instead, we track them by deducing that you renamed from the result.

The tree-vs-index comparison "git status" does to figure all this out is
"git diff-index -M --cached HEAD".

As it should be obvious from the above description,

	git diff-index -M --cached HEAD -- A

is *NOT* the way for you to ask about "possible renames of A".  You need
to run the diff for the whole tree without path limitation so that you can
pair deletions and creations up in order to deduce renames.

  parent reply	other threads:[~2009-08-12 20:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-05 16:21 git index: how does it work? Shaun Cutts
2009-08-05 18:00 ` Junio C Hamano
2009-08-12 11:52   ` Shaun Cutts
2009-08-12 17:47     ` Sverre Rabbelier
2009-08-12 18:45       ` Shaun Cutts
2009-08-12 19:39         ` Björn Steinbrink
2009-08-12 20:31     ` Junio C Hamano [this message]
2009-08-05 18:21 ` Sverre Rabbelier
2009-08-05 19:31   ` Shaun Cutts

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=7vab24ydsz.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=shaun@cuttshome.net \
    /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