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

Questions about git-rev-parse

From
Theodore Ts'o <tytso@mit.edu>
Date
Feb 28, 2007, 02:23 UTC
Message-ID
<E1HMETh-0004BO-Lw@candygram.thunk.org>

So I was looking at git-rev-parse trying to understand the man page, as I was trying to understand how various commands can accept lists (or ranges) of commits, and the man page raised a number of questions. First of all, the DESCRIPTION section doesn't quite parse as English:

       Many  git  porcelainish commands take mixture of flags (i.e. parameters
       that  begin  with  a  dash  -)  and  parameters  meant  for  underlying
       git-rev-list  command  they use internally and flags and parameters for
       other commands they use as the downstream of git-rev-list. 

But, as best as I can gather that it's a helper function meant to do some basic options parsing for those git porcelain commands that expect to take a set of revision ID's.

This raises some additional questions, though. If the goal of this command is to parse out those options and arguments which are meant for git-rev-list, why does it translate tag names to SHA id's:

% git-rev-parse v1.5.0..v1.5.0.1 dedb0faa48787839dbc47b7ca2507bda5924ec2c ^6db027ffe03210324939b3dd655c4223ca023b45

After all, git-rev-list can just as easily accept:
	git-rev-list dedb0faa48787839dbc47b7ca2507bda5924ec2c \
		^6db027ffe03210324939b3dd655c4223ca023b45
as
	git-rev-list v1.5.0..v1.5.0.1

Also, there are a number of options in git-rev-list which make it appear to be a general dumping ground of miscellaneous options.

For example, it's not clear what 
	git-rev-parse --show-prefix
and
	git-rev-parse --show-cdup

have to do with the description of git-rev-parse as described in the DESCRIPTION section. It seems to be completely miscellaneous extras that were tacked on. Or am I missing something?

Finally, it seems rather unfortunate that certain bits of functionality such as --since and --until were hidden into git-rev-parse, since it means that some commands which are implemented as shell scripts are more likely to use git-rev-parse, and will therefore support --since and --until, where as other commands which are implemented as built-in's, such as git-log, don't accept --since and --until.

So I'm wondering if I'm missing something about historical context, since from looking at git-rev-parse, it looks like not a lot of thought went into its design, and it has a bunch of stuff that grew via accretion; or maybe I'm not understanding why it was designed the way it was?

Regards,
						- Ted
Next: Junio C Hamano
Message 1 of 9 in “Questions about git-rev-parse”
  1. Theodore Ts'oFeb 28, 2007
  2. Junio C HamanoFeb 28, 2007
  3. Theodore TsoFeb 28, 2007
  4. Linus TorvaldsFeb 28, 2007
  5. Theodore TsoFeb 28, 2007
  6. Andy ParkinsFeb 28, 2007
  7. Linus TorvaldsFeb 28, 2007
  8. Linus TorvaldsFeb 28, 2007
  9. Willhelm BuschMar 1, 2007

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.