Re: [RFC] get_sha1() shorthands for blob/tree objects

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

 




On Tue, 18 Apr 2006, Junio C Hamano wrote:

> > 	git diff v0.99.6:git-commit-script git-commit.sh
> >
> > which parses as one SHA1 of a blob (put onto the rev.pending_objects 
> > list), and one filename (in the rev.prune_data array). We could decide to 
> > automatically do the "right thing" for that case too.
> 
> The "right thing" is ambiguous, I am afraid.
> 
> I think it would be natural to interpret the request as a diff
> between the blob from v0.99.6 and a random working tree file, 
> which may not even exist in the index.

Actually, it's not ambiguous. Just take the named file. If you want to 
diff it against HEAD:<named-file>, you should just say so.

Now, if you _really_ want to be difficult, there's a third option: to diff 
it against the named file as named in the index. "git diff" does have the 
"--cached" option that would make that case unambiguous too, of course.

Ie:

 (a) diff against the current HEAD:

	git diff v0.99.6:git-commit-script HEAD:git-commit.sh

 (b) diff against the current index contents for "git-commit.sh":

	git diff --cached v0.99.6:git-commit-script git-commit.sh

 (c) diff against a random file (which may not even be in the index):

	git diff v0.99.6:git-commit-script git-commit.sh

are all sensible operations, and unambiguous.

The only real downside is that the nice "a..b" syntax doesn't work for 
them, except fot the very first case. That syntax requires both sides to 
be SHA1 names (and while the "index" case could be a SHA1 name, we have no 
way to say so).

> Oh, another possibility is to act as if the user said
> 
> 	git diff v0.99.6:this :git-commit.sh
> 
> where "(empty):" would stand for "look up in the index, not in a
> tree".

That would possibly be a nice extension, yes. But I really did mean 
"random file, possibly not even in the index".

> Unfortunatly, I do not think this parses well:
> 
> 	git diff git-commit.sh v0.99.6:git-commit-script

Correct. As you point out, that would have to be done with -R.

			Linus
-
: 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]