# wierd git show syntax

5 messages from 2010-09-30 to 2010-10-04. Participants: Geoff Russell, Tomas Carnecky, Matthieu Moy.
Thread: https://gitlist.dev/t/25295

## Geoff Russell, 2010-09-30 05:02

Subject: wierd git show syntax
Message-ID: <AANLkTi=Zz-1dSC0imJ3NZXWcdvhXWXt-Kk94zwKe8+6Y@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTi%3DZz-1dSC0imJ3NZXWcdvhXWXt-Kk94zwKe8%2B6Y%40mail.gmail.com

```
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

```

## Tomas Carnecky, 2010-09-30 08:46

Subject: Re: wierd git show syntax
Message-ID: <4CA44E7D.7090901@dbservice.com>
URL: https://gitlist.dev/e/4CA44E7D.7090901%40dbservice.com
In-Reply-To: <AANLkTi=Zz-1dSC0imJ3NZXWcdvhXWXt-Kk94zwKe8+6Y@mail.gmail.com>

```
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

```

## Tomas Carnecky, 2010-09-30 09:02

Subject: Re: wierd git show syntax
Message-ID: <4CA4520F.30809@dbservice.com>
URL: https://gitlist.dev/e/4CA4520F.30809%40dbservice.com
In-Reply-To: <4CA44E7D.7090901@dbservice.com>

```
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

```

## Matthieu Moy, 2010-09-30 11:32

Subject: Re: wierd git show syntax
Message-ID: <vpqtyl7fovk.fsf@bauges.imag.fr>
URL: https://gitlist.dev/e/vpqtyl7fovk.fsf%40bauges.imag.fr
In-Reply-To: <AANLkTi=Zz-1dSC0imJ3NZXWcdvhXWXt-Kk94zwKe8+6Y@mail.gmail.com>

```
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/

```

## Geoff Russell, 2010-10-04 22:32

Subject: Re: wierd git show syntax
Message-ID: <AANLkTineQDgVUvbjR-9LvtuVVw3RX_gB=urY5Fn4K6QE@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTineQDgVUvbjR-9LvtuVVw3RX_gB%3DurY5Fn4K6QE%40mail.gmail.com
In-Reply-To: <vpqtyl7fovk.fsf@bauges.imag.fr>

```
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

```
