public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Yakup Akbay <yakbay@ubicom•com>
To: Junio C Hamano <gitster@pobox•com>
Cc: git@vger•kernel.org
Subject: Re: Weird behavior of git rev-parse
Date: Tue, 14 Jul 2009 13:01:54 +0300	[thread overview]
Message-ID: <4A5C5792.3050704@ubicom.com> (raw)
In-Reply-To: <7vvdlvhbtg.fsf@alter.siamese.dyndns.org>

Junio C Hamano wrote:
> Yakup Akbay <yakbay@ubicom•com> writes:
>
>   
>> Then I've tried
>>
>>    $ git rev-parse -'hi, this is a test!'
>>
>> the output is:
>>
>>    -hi, this is a test!
>>
>> Is this an expected behavior?
>>     
>
> Absolutely.  rev-parse was originally written as a way for Porcelain
> scripts to sift parameters into four different categories.
>
>  * options and non-options (that's two)
>
>  * args meant for rev-list and others (that's another two)
>
> Multiplying two x two gives you four combinations.
>
> Because you are not giving options like --revs-only, --no-revs, --flags,
> nor --no-flags, rev-parse outputs everything.  You can try these:
>
> $ git rev-parse --no-flags -'Hi'
> $ git rev-parse --no-revs HEAD
> $ git rev-parse --flags --no-revs -Hi HEAD
>   
Got it!

>> Another questions is, usage is printed if you omit the commit id in
>> git rev-list (E.g. `git rev-list -2`). Is there a reason why HEAD is
>> not taken as the default?
>>     
>
> The reason is because that is the way it has been, that is the way it is,
> and changing it will break existing behaviour and scripts.  In other
> words, it is a historical accident without any deep logic.
>
> Besides, "git rev-list" is a plumbing and didn't necessarily want a
> user-friendliness niceties such as "defaulting to X when nothing is
> given".
>
>   
Makes sense, thanks!

Yakup

  reply	other threads:[~2009-07-14 10:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-14  7:20 Weird behavior of git rev-parse Yakup Akbay
2009-07-14  9:06 ` Santi Béjar
2009-07-14  9:07 ` Junio C Hamano
2009-07-14 10:01   ` Yakup Akbay [this message]
2009-07-14 11:34   ` Jakub Narebski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A5C5792.3050704@ubicom.com \
    --to=yakbay@ubicom$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=gitster@pobox$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox