git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* wierd git show syntax
@ 2010-09-30  5:02 Geoff Russell
  2010-09-30  8:46 ` Tomas Carnecky
  2010-09-30 11:32 ` Matthieu Moy
  0 siblings, 2 replies; 5+ messages in thread
From: Geoff Russell @ 2010-09-30  5:02 UTC (permalink / raw)
  To: git

Hi,

$ git show XXXX:data/path/object.c

Gives me what I want, a cat of the objects contents. However
for some files I get a message about ambiguous argument telling me to
separate paths from revisions with '--'. Okay so I try that:

$ git show -- XXXX:data/path/object.c

But it gives me nothing

$ git show XXXX -- data/path/object.c

Gives me a git diff output for the object.


This is all with git 1.6.2.3

What's happening here? Why aren't all these equivalent?


Cheers,
Geoff Russell

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: wierd git show syntax
  2010-09-30  5:02 wierd git show syntax Geoff Russell
@ 2010-09-30  8:46 ` Tomas Carnecky
  2010-09-30  9:02   ` Tomas Carnecky
  2010-09-30 11:32 ` Matthieu Moy
  1 sibling, 1 reply; 5+ messages in thread
From: Tomas Carnecky @ 2010-09-30  8:46 UTC (permalink / raw)
  To: geoffrey.russell; +Cc: git

On 9/30/10 7:02 AM, Geoff Russell wrote:
> Hi,
> 
> $ git show XXXX:data/path/object.c

Show me the contents of the file at data/path/object.c in revision XXXX.

> Gives me what I want, a cat of the objects contents. However
> for some files I get a message about ambiguous argument telling me to
> separate paths from revisions with '--'. Okay so I try that:
> 
> $ git show -- XXXX:data/path/object.c

Show me the commit HEAD but limit the diff to the path
XXXX:data/path/object.c.

There is an implicit HEAD before the double dash. You probably want the
double dash *after* the object, to force git to parse that string as an
object and not a path:

$ git show XXXX:data/path/object.c --

> But it gives me nothing
> 
> $ git show XXXX -- data/path/object.c

Show me the commit XXXX but limit the diff to the path data/path/object.c.

> Gives me a git diff output for the object.
> 
> 
> This is all with git 1.6.2.3
> 
> What's happening here? Why aren't all these equivalent?

no.

tom

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: wierd git show syntax
  2010-09-30  8:46 ` Tomas Carnecky
@ 2010-09-30  9:02   ` Tomas Carnecky
  0 siblings, 0 replies; 5+ messages in thread
From: Tomas Carnecky @ 2010-09-30  9:02 UTC (permalink / raw)
  To: geoffrey.russell; +Cc: git

On 9/30/10 10:46 AM, Tomas Carnecky wrote:
>> What's happening here? Why aren't all these equivalent?
> 
> no.

A 'no' does not really fit a 'why?' question. I should explain.

Someone (Linus?) long ago decided that the revision parsing work that
way. It's pretty powerful, even the smallest colon and double dash have
a meaning. But it can be complicated for someone new to git to
understand. See 'man gitrevisions' to understand how git parses
revisions. Sadly the effect of double bash is not described in the
git-show man page. But in most commands it's used to separate revisions
from paths. Example: if you have a file and branch both named master,
'git log master --' will show you the log of that branch while 'git log
-- master' will show you the log of HEAD but limit it to commits which
touched the file master. Again, there's an implicit HEAD before the
double dash.

tom

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: wierd git show syntax
  2010-09-30  5:02 wierd git show syntax Geoff Russell
  2010-09-30  8:46 ` Tomas Carnecky
@ 2010-09-30 11:32 ` Matthieu Moy
  2010-10-04 22:32   ` Geoff Russell
  1 sibling, 1 reply; 5+ messages in thread
From: Matthieu Moy @ 2010-09-30 11:32 UTC (permalink / raw)
  To: geoffrey.russell; +Cc: git

Geoff Russell <geoffrey.russell@gmail.com> writes:

> Hi,
>
> $ git show XXXX:data/path/object.c
>
> Gives me what I want, a cat of the objects contents. However
> for some files I get a message about ambiguous argument telling me to
> separate paths from revisions with '--'.

This happens if data/path/object.c doesn't exist in XXXX.

A common mistake is to write XXXX:relative/path when Git expects a
path relative to the tree root. Git >= 1.7 would give you a more
friendly error message in this case.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: wierd git show syntax
  2010-09-30 11:32 ` Matthieu Moy
@ 2010-10-04 22:32   ` Geoff Russell
  0 siblings, 0 replies; 5+ messages in thread
From: Geoff Russell @ 2010-10-04 22:32 UTC (permalink / raw)
  To: Matthieu Moy, tom; +Cc: git

On Thu, Sep 30, 2010 at 10:02 PM, Matthieu Moy
<Matthieu.Moy@grenoble-inp.fr> wrote:
> Geoff Russell <geoffrey.russell@gmail.com> writes:
>
>> Hi,
>>
>> $ git show XXXX:data/path/object.c
>>
>> Gives me what I want, a cat of the objects contents. However
>> for some files I get a message about ambiguous argument telling me to
>> separate paths from revisions with '--'.
>
> This happens if data/path/object.c doesn't exist in XXXX.

Thanks Matthieu and Tom for your explanations on this. It's clearer
now ... even if my intuition failed to match the syntax!

Cheers,
Geoff

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-10-04 22:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-30  5:02 wierd git show syntax Geoff Russell
2010-09-30  8:46 ` Tomas Carnecky
2010-09-30  9:02   ` Tomas Carnecky
2010-09-30 11:32 ` Matthieu Moy
2010-10-04 22:32   ` Geoff Russell

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).