{"thread":{"id":"27619","subject":"Is current HEAD pointing at a given revision ?","startedAt":"2011-06-14T06:59:57Z","lastAt":"2011-06-14T19:17:39Z","messageCount":5,"participants":["Francis Moreau","Jakub Narebski"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"169982","messageId":"BANLkTikFTHc4Qiu1YLxXgPhweNnVqMO11Q@mail.gmail.com","threadId":"27619","inReplyTo":null,"subject":"Is current HEAD pointing at a given revision ?","fromName":"Francis Moreau","fromEmail":"francis.moro@gmail.com","sentAt":"2011-06-14T06:59:57Z","receivedAt":"2011-06-14T06:59:57Z","isPatch":false,"sender":{"key":"francis.moro@gmail.com","avatar":null},"body":"Hello,\n\nI have a given revision (tag, sha1 ...) and I'd like to know if that\nrevisions corresponds to what the current HEAD is pointing at.\n\nCould anybody give me some advices for achieving this ?\n\nThanks\n-- \nFrancis\n"},{"id":"169985","messageId":"m3mxhkvlcw.fsf@localhost.localdomain","threadId":"27619","inReplyTo":"BANLkTikFTHc4Qiu1YLxXgPhweNnVqMO11Q@mail.gmail.com","subject":"Re: Is current HEAD pointing at a given revision ?","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2011-06-14T09:00:55Z","receivedAt":"2011-06-14T09:00:55Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Francis Moreau <francis.moro@gmail.com> writes:\n\n> I have a given revision (tag, sha1 ...) and I'd like to know if that\n> revisions corresponds to what the current HEAD is pointing at.\n> \n> Could anybody give me some advices for achieving this ?\n\nIf you want to know if given revision (or ref) points at the same\nthing as HEAD, you can use\n\n  [ \"$(git rev-parse HEAD)\" = \"$(git rev-parse $ref^{commit})\" ]\n\nor something like that.  The '^{commit}' is here in case $ref points\nonly indirectly to commit, via a tag object.\n\nIf you want to kow if current HEAD is tagged, you can use instead\n\n  git describe --exact-match HEAD\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"170013","messageId":"BANLkTimMkOS_Q9gb_ta2P3NSMGyNJtKgJA@mail.gmail.com","threadId":"27619","inReplyTo":"m3mxhkvlcw.fsf@localhost.localdomain","subject":"Re: Is current HEAD pointing at a given revision ?","fromName":"Francis Moreau","fromEmail":"francis.moro@gmail.com","sentAt":"2011-06-14T15:56:43Z","receivedAt":"2011-06-14T15:56:43Z","isPatch":false,"sender":{"key":"francis.moro@gmail.com","avatar":null},"body":"On Tue, Jun 14, 2011 at 11:00 AM, Jakub Narebski <jnareb@gmail.com> wrote:\n> Francis Moreau <francis.moro@gmail.com> writes:\n>\n>> I have a given revision (tag, sha1 ...) and I'd like to know if that\n>> revisions corresponds to what the current HEAD is pointing at.\n>>\n>> Could anybody give me some advices for achieving this ?\n>\n> If you want to know if given revision (or ref) points at the same\n> thing as HEAD, you can use\n>\n>  [ \"$(git rev-parse HEAD)\" = \"$(git rev-parse $ref^{commit})\" ]\n>\n> or something like that.  The '^{commit}' is here in case $ref points\n> only indirectly to commit, via a tag object.\n>\n\nI see thanks.\n\nI'm not sure what the ^{commit} is for because in the case of tag\nobject, git-rev-parse seems to work fine without the suffix:\n\ngit rev-parse v2.6.39\n8b0753a3df28c21b0570fa21362c5f1b3b4f59bf\n\nThis is in a kernel git repository\n\nThanks\n-- \nFrancis\n"},{"id":"170014","messageId":"201106141817.23585.jnareb@gmail.com","threadId":"27619","inReplyTo":"BANLkTimMkOS_Q9gb_ta2P3NSMGyNJtKgJA@mail.gmail.com","subject":"Re: Is current HEAD pointing at a given revision ?","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2011-06-14T16:17:22Z","receivedAt":"2011-06-14T16:17:22Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Francis Moreau wrote:\n> On Tue, Jun 14, 2011 at 11:00 AM, Jakub Narebski <jnareb@gmail.com> wrote:\n> > Francis Moreau <francis.moro@gmail.com> writes:\n> >\n> > > I have a given revision (tag, sha1 ...) and I'd like to know if that\n> > > revisions corresponds to what the current HEAD is pointing at.\n> > >\n> > > Could anybody give me some advices for achieving this ?\n> >\n> > If you want to know if given revision (or ref) points at the same\n> > thing as HEAD, you can use\n> >\n> >  [ \"$(git rev-parse HEAD)\" = \"$(git rev-parse $ref^{commit})\" ]\n> >\n> > or something like that.  The '^{commit}' is here in case $ref points\n> > only indirectly to commit, via a tag object.\n> >\n> \n> I see thanks.\n> \n> I'm not sure what the ^{commit} is for because in the case of tag\n> object, git-rev-parse seems to work fine without the suffix:\n> \n> git rev-parse v2.6.39\n> 8b0753a3df28c21b0570fa21362c5f1b3b4f59bf\n> \n> This is in a kernel git repository\n\nBut that is the SHA-1 id of a _tag object_, not of commit (revision)\nit points to. '^{}' means peel to not tag, '^{commit}' means peel to\ncommit.\n\nIn git repository:\n\n $ git rev-parse v1.7.5\n 4d2f8aeba22578022e2d2a56dac37fcdf78d82d4\n $ git rev-parse v1.7.5^{}\n ec014eac0e9e6f30cbbca616090fa2ecf74797e7\n $ git rev-parse v1.7.5^{commit}\n ec014eac0e9e6f30cbbca616090fa2ecf74797e7\n $ git cat-file -t 4d2f8aeba22578022e2d2a56dac37fcdf78d82d4\n tag\n $ git cat-file -t ec014eac0e9e6f30cbbca616090fa2ecf74797e7\n commit\n\n $ git cat-file -t HEAD\n commit\n\n-- \nJakub Narebski\nPoland\n"},{"id":"170021","messageId":"BANLkTikMQxEFEB0wMV0T6DfCFWiiU4ukmg@mail.gmail.com","threadId":"27619","inReplyTo":"201106141817.23585.jnareb@gmail.com","subject":"Re: Is current HEAD pointing at a given revision ?","fromName":"Francis Moreau","fromEmail":"francis.moro@gmail.com","sentAt":"2011-06-14T19:17:39Z","receivedAt":"2011-06-14T19:17:39Z","isPatch":false,"sender":{"key":"francis.moro@gmail.com","avatar":null},"body":"On Tue, Jun 14, 2011 at 6:17 PM, Jakub Narebski <jnareb@gmail.com> wrote:\n> Francis Moreau wrote:\n>> On Tue, Jun 14, 2011 at 11:00 AM, Jakub Narebski <jnareb@gmail.com> wrote:\n>> > Francis Moreau <francis.moro@gmail.com> writes:\n>> >\n>> > > I have a given revision (tag, sha1 ...) and I'd like to know if that\n>> > > revisions corresponds to what the current HEAD is pointing at.\n>> > >\n>> > > Could anybody give me some advices for achieving this ?\n>> >\n>> > If you want to know if given revision (or ref) points at the same\n>> > thing as HEAD, you can use\n>> >\n>> >  [ \"$(git rev-parse HEAD)\" = \"$(git rev-parse $ref^{commit})\" ]\n>> >\n>> > or something like that.  The '^{commit}' is here in case $ref points\n>> > only indirectly to commit, via a tag object.\n>> >\n>>\n>> I see thanks.\n>>\n>> I'm not sure what the ^{commit} is for because in the case of tag\n>> object, git-rev-parse seems to work fine without the suffix:\n>>\n>> git rev-parse v2.6.39\n>> 8b0753a3df28c21b0570fa21362c5f1b3b4f59bf\n>>\n>> This is in a kernel git repository\n>\n> But that is the SHA-1 id of a _tag object_, not of commit (revision)\n> it points to. '^{}' means peel to not tag, '^{commit}' means peel to\n> commit.\n>\n\nOh I see now, thanks a lot !\n\n-- \nFrancis\n"}]}