Git development
 help / color / mirror / Atom feed
From: Shaun Cutts <shaun@cuttshome.net>
To: git@vger.kernel.org
Subject: git index: how does it work?
Date: Wed, 5 Aug 2009 16:21:38 +0000 (UTC)	[thread overview]
Message-ID: <loom.20090805T160528-69@post.gmane.org> (raw)

Hello,

I am wondering if someone could explain and/or point me to an explanation of how
the git index works.

For instance, suppose I have a tracked file: "foo.c"

1) [I modify "foo.c"]
2) git add foo.c
3) [modify again]
4) git commit -m "blah blah"

Since I don't include the "-a" switch, the version I added on step 2 is
committed. But how does the index keep track of these changes? Does the index
file actually contain the hunks of "foo.c" that have been modified? Or is there
a "temporary" blob created, which the index points to? 

In either case, is there some interface to access these hunks and/or get a
reference to the blob?

Thanks,

-- Shaun

PS I'm considering writing an extension to git where the "diff" understands the
semantics of certain types of files: hunks wouldn't just be textual blobs but
would try to represent a minimal change from one version to the next based on an
edit distance, so that, e.g. changing the location of a function would be
represented by a "move" edit, rather than two text changes.

I have been building a prototype as a wrapper around git, intervening to store
extra information, etc before passing commands on to git. Blobs, commits, etc
are nice abstractions I can leave as is, but the index seems sort of foggy to
me. Any advice appreciated!

             reply	other threads:[~2009-08-05 17:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-05 16:21 Shaun Cutts [this message]
2009-08-05 18:00 ` git index: how does it work? 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
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=loom.20090805T160528-69@post.gmane.org \
    --to=shaun@cuttshome.net \
    --cc=git@vger.kernel.org \
    /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