git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@osdl.org>
To: Junio C Hamano <junkio@cox.net>
Cc: git@vger.kernel.org
Subject: Re: [RFC] get_sha1() shorthands for blob/tree objects
Date: Tue, 18 Apr 2006 18:43:00 -0700 (PDT)	[thread overview]
Message-ID: <Pine.LNX.4.64.0604181836400.3701@g5.osdl.org> (raw)
In-Reply-To: <7vd5fecpyd.fsf@assigned-by-dhcp.cox.net>



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

  reply	other threads:[~2006-04-19  1:43 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-18 23:45 [RFC] get_sha1() shorthands for blob/tree objects Linus Torvalds
2006-04-19  0:14 ` Martin Langhoff
2006-04-19  0:21   ` Shawn Pearce
2006-04-19  1:20     ` Ray Lehtiniemi
2006-04-19  0:27 ` Junio C Hamano
2006-04-19  0:44   ` Linus Torvalds
2006-04-19  0:47     ` Linus Torvalds
2006-04-19  8:15       ` Andreas Ericsson
2006-04-19 14:44         ` Linus Torvalds
2006-04-19  0:56 ` Junio C Hamano
2006-04-19  1:16   ` Linus Torvalds
2006-04-19  1:19     ` Linus Torvalds
2006-04-19  1:30     ` Junio C Hamano
2006-04-19  1:43       ` Linus Torvalds [this message]
2006-04-19  4:02         ` Junio C Hamano
2006-04-19  4:14           ` Linus Torvalds
2006-04-19 21:49             ` Junio C Hamano
2006-04-19 21:57               ` Linus Torvalds
2006-04-19  3:51       ` Martin Langhoff
2006-04-19  3:58         ` Linus Torvalds
2006-04-19  4:04           ` Linus Torvalds
2006-04-22  0:49 ` [RFC] get_sha1(): :path and :[0-3]:path to extract from index Junio C Hamano
2006-04-25  8:37   ` Uwe Zeisberger
2006-04-25  8:46     ` Junio C Hamano

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=Pine.LNX.4.64.0604181836400.3701@g5.osdl.org \
    --to=torvalds@osdl.org \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.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;
as well as URLs for NNTP newsgroup(s).