Re: Two crazy proposals for changing git's diff commands
From: Carl Worth <hidden>
Date: 2016-06-15 22:42:18
On Wed, 8 Feb 2006 17:21:49 -0800 (PST), Linus Torvalds wrote:
quoted
The largest reason for why "git diff" defaults to diffing against the index (and not head) is _literally_ that it's faster.
That's certainly surprising history to learn.
Btw, it was kind of luck (but it's definitely true) that the current "git diff" semantics happen to also be what you do want during merges when you try to resolve a conflict (while "git diff HEAD" is much less useful). So making "git diff" default to diffing against HEAD is actually the wrong thing to do during merging, where the current behaviour is exactly what you'd want.
I discovered this during the analysis and guess (incorrectly) that it was the motivation for the behavior of "git diff". Initially I think I would have made a proposal that had "git diff" creating a diff from HEAD except that I discovered two different targets that would be useful when diffing from HEAD: HEAD -> index and: HEAD -> files so I chose "index" and "files" as the naming distinction there. In light of those, I couldn't think of any good naming for the remaining: index -> files operation, so it seemed just as well to leave it with a bare "diff" as before. But, as you've pointed out, my trying to create new high-level diff-index and diff-files operations fails in that it clashes with the existing low-level uses of those names, (which scripts may already be depending on). I totally neglected to consider the pain of migrating scripts. I still think the three above operations are the most commonly needed, but I don't yet have good suggestions for names for them. I think I'll be back with some new proposals after considering your suggestion to expand git status. -Carl
Attachments
- (unnamed) [application/pgp-signature] 189 bytes