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

git-rev-parse question.

From
Junio C Hamano <junkio@cox.net>
Date
Aug 23, 2005, 08:02 UTC
Message-ID
<7v7jedulli.fsf@assigned-by-dhcp.cox.net>

I have been looking at what git-rev-parse does and could not figure out a way to convince it to give me only arguments with a '-' prefix. Specifically, I wanted to remove the hardcoded -p and -M flags from git-diff-script. Running

    $ sh -x git-diff-script -C HEAD^ HEAD

reveals that none of the following would pick up "-C" from the command line:

    rev=($(git-rev-parse --revs-only "$@")) || exit
    flags=($(git-rev-parse --no-revs --flags "$@"))
    files=($(git-rev-parse --no-revs --no-flags "$@"))

I am not even sure if the current implementation of rev-parse matches what you originally wanted it to do; I suspect it does not. I would like to know what was the intended behaviour first, so that I can enhance it to be usable for my purpose without breaking things.

What I want the rev-parse flags to mean is as follows. By "rev argument", I mean what get_sha1() can understand. I have to admit that some flags are what I introduced while I was butchering it without really knowing the original intention:

  output format:
  --sq		output in a format usable for shell "eval".
  --symbolic	output rev argument in symbolic form, not SHA1.
  output selection:
  --flags	show only arguments with '-' prefix.
  --no-flags	do not show arguments with '-' prefix.
  --revs-only	show only arguments meant for rev-list.
  --no-revs	show arguments not meant for rev-list.
  input munging:
  --default R	if no revision, pretend R is given.
  --not		pretend all rev arguments without prefix ^ have
                prefix ^, and the ones with prefix ^ do not.
  --all		pretend all refs under $GIT_DIR/refs are given
  		on the command line.
  special:
  --verify	make sure only one rev argument is given, nothing else.

I think flags/no-flags and revs-only/no-revs *should* be orthogonal. That is, "rev-parse --flags --no-revs" should give parameters that start with '-' and not meant for rev-list (e.g. '-C' in earlier example); "rev-parse --revs-only --merge-order HEAD Documentation/" should yield "--merge-order HEAD".

Also there is an undocumented --show-prefix.  What is it?
-jc
PS. BTW, any response about unsuspecting companies?
Next: Linus Torvalds
Message 1 of 3 in “git-rev-parse question.”
  1. Junio C HamanoAug 23, 2005
  2. Linus TorvaldsAug 23, 2005
  3. Linus TorvaldsAug 23, 2005

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.