{"thread":{"id":"20108","subject":"Weird behavior of git rev-parse","startedAt":"2009-07-14T07:20:47Z","lastAt":"2009-07-14T11:34:42Z","messageCount":5,"participants":["Yakup Akbay","Santi Béjar","Junio C Hamano","Jakub Narebski"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"117941","messageId":"4A5C31CF.2090204@ubicom.com","threadId":"20108","inReplyTo":null,"subject":"Weird behavior of git rev-parse","fromName":"Yakup Akbay","fromEmail":"yakbay@ubicom.com","sentAt":"2009-07-14T07:20:47Z","receivedAt":"2009-07-14T07:20:47Z","isPatch":false,"sender":{"key":"yakbay@ubicom.com","avatar":"https://gravatar.com/avatar/b1a445348437a895f93c412e183919a84c8b1298747b5e6f285b233225a274cf?d=mp&s=160"},"body":"Hi,\n\ninstead of `git rev-list -2 HEAD` I've tried `git rev-parse -2 HEAD` \njust to see the effect of -N in rev-parse, but I've got this output:\n\n    -2\n    0294cdd1e2c5535f5b87eff4a1aff3390e03af39\n\nThen I've tried\n\n    $ git rev-parse -'hi, this is a test!'\n\nthe output is:\n\n    -hi, this is a test!\n\nIs this an expected behavior?\n\n\nAnother questions is, usage is printed if you omit the commit id in git \nrev-list (E.g. `git rev-list -2`). Is there a reason why HEAD is not \ntaken as the default?\n\nRegards,\nYakup\n"},{"id":"117945","messageId":"adf1fd3d0907140206v691cc27awf4f62397c5a491f8@mail.gmail.com","threadId":"20108","inReplyTo":"4A5C31CF.2090204@ubicom.com","subject":"Re: Weird behavior of git rev-parse","fromName":"Santi Béjar","fromEmail":"santi@agolina.net","sentAt":"2009-07-14T09:06:57Z","receivedAt":"2009-07-14T09:06:57Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"2009/7/14 Yakup Akbay <yakbay@ubicom.com>:\n> Hi,\n>\n> instead of `git rev-list -2 HEAD` I've tried `git rev-parse -2 HEAD` just to\n> see the effect of -N in rev-parse, but I've got this output:\n>\n>   -2\n>   0294cdd1e2c5535f5b87eff4a1aff3390e03af39\n>\n> Then I've tried\n>\n>   $ git rev-parse -'hi, this is a test!'\n>\n> the output is:\n>\n>   -hi, this is a test!\n>\n> Is this an expected behavior?\n\nThere is no \"-N\" flag to \"git rev-parse\", neither \"-'hi, this is a\ntest!'\". The purpuse of git rev-parse is for porcelainish commands to\nparse their argument, as the man page says:\n\ngit-rev-parse - Pick out and massage parameters\n\nMany git porcelainish commands take mixture of flags\n(i.e. parameters that begin with a dash '-') and parameters\nmeant for the underlying 'git-rev-list' command they use internally\nand flags and parameters for the other commands they use\ndownstream of 'git-rev-list'.  This command is used to\ndistinguish between them.\n\n>\n>\n> Another questions is, usage is printed if you omit the commit id in git\n> rev-list (E.g. `git rev-list -2`). Is there a reason why HEAD is not taken\n> as the default?\n\nYou can say what is the default with --default <arg>.\n\nHTH,\nSanti\n"},{"id":"117946","messageId":"7vvdlvhbtg.fsf@alter.siamese.dyndns.org","threadId":"20108","inReplyTo":"4A5C31CF.2090204@ubicom.com","subject":"Re: Weird behavior of git rev-parse","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-07-14T09:07:55Z","receivedAt":"2009-07-14T09:07:55Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Yakup Akbay <yakbay@ubicom.com> writes:\n\n> Then I've tried\n>\n>    $ git rev-parse -'hi, this is a test!'\n>\n> the output is:\n>\n>    -hi, this is a test!\n>\n> Is this an expected behavior?\n\nAbsolutely.  rev-parse was originally written as a way for Porcelain\nscripts to sift parameters into four different categories.\n\n * options and non-options (that's two)\n\n * args meant for rev-list and others (that's another two)\n\nMultiplying two x two gives you four combinations.\n\nBecause you are not giving options like --revs-only, --no-revs, --flags,\nnor --no-flags, rev-parse outputs everything.  You can try these:\n\n$ git rev-parse --no-flags -'Hi'\n$ git rev-parse --no-revs HEAD\n$ git rev-parse --flags --no-revs -Hi HEAD\n\n> Another questions is, usage is printed if you omit the commit id in\n> git rev-list (E.g. `git rev-list -2`). Is there a reason why HEAD is\n> not taken as the default?\n\nThe reason is because that is the way it has been, that is the way it is,\nand changing it will break existing behaviour and scripts.  In other\nwords, it is a historical accident without any deep logic.\n\nBesides, \"git rev-list\" is a plumbing and didn't necessarily want a\nuser-friendliness niceties such as \"defaulting to X when nothing is\ngiven\".\n"},{"id":"117948","messageId":"4A5C5792.3050704@ubicom.com","threadId":"20108","inReplyTo":"7vvdlvhbtg.fsf@alter.siamese.dyndns.org","subject":"Re: Weird behavior of git rev-parse","fromName":"Yakup Akbay","fromEmail":"yakbay@ubicom.com","sentAt":"2009-07-14T10:01:54Z","receivedAt":"2009-07-14T10:01:54Z","isPatch":false,"sender":{"key":"yakbay@ubicom.com","avatar":"https://gravatar.com/avatar/b1a445348437a895f93c412e183919a84c8b1298747b5e6f285b233225a274cf?d=mp&s=160"},"body":"Junio C Hamano wrote:\n> Yakup Akbay <yakbay@ubicom.com> writes:\n>\n>   \n>> Then I've tried\n>>\n>>    $ git rev-parse -'hi, this is a test!'\n>>\n>> the output is:\n>>\n>>    -hi, this is a test!\n>>\n>> Is this an expected behavior?\n>>     \n>\n> Absolutely.  rev-parse was originally written as a way for Porcelain\n> scripts to sift parameters into four different categories.\n>\n>  * options and non-options (that's two)\n>\n>  * args meant for rev-list and others (that's another two)\n>\n> Multiplying two x two gives you four combinations.\n>\n> Because you are not giving options like --revs-only, --no-revs, --flags,\n> nor --no-flags, rev-parse outputs everything.  You can try these:\n>\n> $ git rev-parse --no-flags -'Hi'\n> $ git rev-parse --no-revs HEAD\n> $ git rev-parse --flags --no-revs -Hi HEAD\n>   \nGot it!\n\n>> Another questions is, usage is printed if you omit the commit id in\n>> git rev-list (E.g. `git rev-list -2`). Is there a reason why HEAD is\n>> not taken as the default?\n>>     \n>\n> The reason is because that is the way it has been, that is the way it is,\n> and changing it will break existing behaviour and scripts.  In other\n> words, it is a historical accident without any deep logic.\n>\n> Besides, \"git rev-list\" is a plumbing and didn't necessarily want a\n> user-friendliness niceties such as \"defaulting to X when nothing is\n> given\".\n>\n>   \nMakes sense, thanks!\n\nYakup\n"},{"id":"117950","messageId":"m3iqhvv6ph.fsf@localhost.localdomain","threadId":"20108","inReplyTo":"7vvdlvhbtg.fsf@alter.siamese.dyndns.org","subject":"Re: Weird behavior of git rev-parse","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2009-07-14T11:34:42Z","receivedAt":"2009-07-14T11:34:42Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Yakup Akbay <yakbay@ubicom.com> writes:\n> \n> > Then I've tried\n> >\n> >    $ git rev-parse -'hi, this is a test!'\n> >\n> > the output is:\n> >\n> >    -hi, this is a test!\n> >\n> > Is this an expected behavior?\n> \n> Absolutely.  rev-parse was originally written as a way for Porcelain\n> scripts to sift parameters into four different categories.\n> \n>  * options and non-options (that's two)\n> \n>  * args meant for rev-list and others (that's another two)\n> \n> Multiplying two x two gives you four combinations.\n> \n> Because you are not giving options like --revs-only, --no-revs, --flags,\n> nor --no-flags, rev-parse outputs everything.\n\ngit-rev-parse can also be used to bring parseopt to shell scripts.\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"}]}