git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Weird behavior of git rev-parse

From
SBSanti Béjar <santi@agolina.net>
Date
Jul 14, 2009, 09:06 UTC
Message-ID
<adf1fd3d0907140206v691cc27awf4f62397c5a491f8@mail.gmail.com>
In-Reply-To
<4A5C31CF.2090204@ubicom.com>
2009/7/14 Yakup Akbay <yakbay@ubicom.com>:
Show 17 quoted lines
> Hi,
>
> instead of `git rev-list -2 HEAD` I've tried `git rev-parse -2 HEAD` just to
> see the effect of -N in rev-parse, but I've got this output:
>
>   -2
>   0294cdd1e2c5535f5b87eff4a1aff3390e03af39
>
> 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?

There is no "-N" flag to "git rev-parse", neither "-'hi, this is a test!'". The purpuse of git rev-parse is for porcelainish commands to parse their argument, as the man page says:

git-rev-parse - Pick out and massage parameters

Many git porcelainish commands take mixture of flags (i.e. parameters that begin with a dash '-') and parameters meant for the underlying 'git-rev-list' command they use internally and flags and parameters for the other commands they use downstream of 'git-rev-list'. This command is used to distinguish between them.

Show 5 quoted lines
>
>
> 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?
You can say what is the default with --default <arg>.

HTH, Santi

Previous: Yakup AkbayNext: Junio C Hamano
Message 2 of 5 in “Weird behavior of git rev-parse”
  1. Yakup AkbayJul 14, 2009
  2. Santi BéjarJul 14, 2009
  3. Junio C HamanoJul 14, 2009
  4. Yakup AkbayJul 14, 2009
  5. Jakub NarebskiJul 14, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.