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

[RFC PATCH] rev-list: clarify --abbrev and --abbrev-commit usage

From
Emily Shaffer <emilyshaffer@google.com>
Date
Jun 13, 2019, 22:15 UTC
Message-ID
<20190613221541.10007-1-emilyshaffer@google.com>

Indicate that --abbrev only works with --abbrev-commit also specified. It seems that simply running `git rev-list --abbrev=5` doesn't abbreviate commit OIDs. But the combination of `git rev-list --abbrev-commit --abbrev=5` works as expected. Clarify in the documentation by indicating that --abbrev is an optional addition to the --abbrev-commit option. --no-abbrev remains on a separate line as it can still be used to disable OID abbreviation even if --abbrev-commit has been specified.

Signed-off-by: Emily Shaffer <emilyshaffer@google.com>
Change-Id: If9b1198938e1a3515ae6740241f7b791fb7a88bd
---
I thought this was odd when I was working on the other rev-list changes
- --abbrev doesn't do anything on its own. It looks like it does work by
itself in other commands, but apparently not in rev-list.

Listed this patch as RFC because maybe instead it's better to fix something so --abbrev can be used alone, or teach --abbrev-commit=<n>. It looks like `git log --abbrev=5` also doesn't work the way one might expect, which makes sense to me, as they use the same internals for option parsing (parse_revisions()).

The manpages for log and rev-list both correctly indicate that --abbrev=<n> is an optional addition to --abbrev-commit. `git log -h` is generated by parse-options tooling and doesn't cover --abbrev-commit at all, but `git rev-list` doesn't use an option parser on its own and the usage is hardcoded.

 - Emily
 builtin/rev-list.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index 9f31837d30..6ae0087b01 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -49,8 +49,8 @@ static const char rev_list_usage[] =
 "    --objects | --objects-edge\n"
 "    --unpacked\n"
 "    --header | --pretty\n"
-"    --abbrev=<n> | --no-abbrev\n"
-"    --abbrev-commit\n"
+"    --abbrev-commit [--abbrev=<n>]\n"
+"    --no-abbrev\n"
 "    --left-right\n"
 "    --count\n"
 "  special purpose:\n"
-- 
2.22.0.rc2.383.gf4fbbf30c2-goog
Next: Junio C Hamano
Message 1 of 8 in “rev-list: clarify --abbrev and --abbrev-commit usage”
  1. rev-list: clarify --abbrev and --abbrev-commit usageEmily Shaffer, Jun 13, 2019
  2. Junio C HamanoJun 14, 2019
  3. Jeff KingJun 14, 2019
  4. Emily ShafferJun 14, 2019
  5. Jeff KingJun 14, 2019
  6. Emily ShafferJun 14, 2019
  7. Jeff KingJun 19, 2019
  8. Emily ShafferJun 19, 2019

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.