Re: git with custom diff for commits

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Gerald Gutierrez" <ggmlfs@xxxxxxxxx> writes:

> Yes, but wouldn't it be slick to actually teach git's internal diff to do
> things like GNU diff can, like the ignore option -I, case insensitivity,
> etc. I thought that's what the external diff capability is for, but it is
> not so.

Don't confuse diff and commit.

Git is really snapshot oriented. When you commit, you don't say
"record the changes I made since HEAD", you say "record the current
state of the working tree, and also record the fact that this state is
based on HEAD".

See what a commit object looks like:

$ git cat-file -p 183f84365d 
tree 3f9d576b4adc78188a411104bc21159d459fa3f4
parent b9c506f7d9f05a630fa7e31b77a9cf5081d7dbba
author Shun Kei Leung <kevinlsk@xxxxxxxxx> 1195614079 +0800
committer Junio C Hamano <gitster@xxxxxxxxx> 1195630064 -0800

git-p4: Fix typo in --detect-labels

Signed-off-by: Kevin Leung <kevinlsk@xxxxxxxxx>
Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx>
$ _

The "tree" tells you the state of the project as recorded by commit,
and the "parent" tells you where the HEAD was pointing to at commit
time. That's really the raw information recorded by git.

Now, "diff" comes into the picture for two things: 1) storage
efficiency (you prefer a 1Mb pack file to a 1Gb uncompressed
repository), but that doesn't change the concept, and 2) user
interface.

When you say "git show HEAD", for example, git will recompute a diff,
and show it to you because this is what you expect. But this
information is computed at "git show" time, not at "git commit" time.


What you seem to expect is to tell git "commit the changes except this
portion", what you have to tell git is actually "commit the new state,
but not if this portion is the only change". That sounds identical,
but it's actually a bit different.

-- 
Matthieu
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux