Re: Is current HEAD pointing at a given revision ?
- From
- Francis Moreau <francis.moro@gmail.com>
- Date
- Jun 14, 2011, 15:56 UTC
- Message-ID
- <BANLkTimMkOS_Q9gb_ta2P3NSMGyNJtKgJA@mail.gmail.com>
- In-Reply-To
- <m3mxhkvlcw.fsf@localhost.localdomain>
On Tue, Jun 14, 2011 at 11:00 AM, Jakub Narebski <jnareb@gmail.com> wrote:
Show 15 quoted lines
> Francis Moreau <francis.moro@gmail.com> writes:
>
>> I have a given revision (tag, sha1 ...) and I'd like to know if that
>> revisions corresponds to what the current HEAD is pointing at.
>>
>> Could anybody give me some advices for achieving this ?
>
> If you want to know if given revision (or ref) points at the same
> thing as HEAD, you can use
>
> [ "$(git rev-parse HEAD)" = "$(git rev-parse $ref^{commit})" ]
>
> or something like that. The '^{commit}' is here in case $ref points
> only indirectly to commit, via a tag object.
>I see thanks.
I'm not sure what the ^{commit} is for because in the case of tag object, git-rev-parse seems to work fine without the suffix:
git rev-parse v2.6.39 8b0753a3df28c21b0570fa21362c5f1b3b4f59bf
This is in a kernel git repository
Thanks
-- Francis