Re: Weird behavior of git rev-parse

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Junio C Hamano wrote:
Yakup Akbay <yakbay@xxxxxxxxxx> 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


--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]