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

Bug with --abbrev option in git log?

From
Mário Guimarães <mario.luis.guimaraes@gmail.com>
Date
Nov 4, 2020, 00:55 UTC
Message-ID
<CAF7CYk51BC0KcsBb0KjKWAj17AMU2c9Y6Y81ddwX6oOAFYhT8w@mail.gmail.com>
Hello Git community,

please see next what I believe to be a bug with the --abbrev option in git log. If this is not a bug, can someone explain why Git is giving this output?

Thanks Mário Guimarães

====================================================== Thank you for filling out a Git bug report! Please answer the following questions to help us understand your issue.

What did you do before the bug happened? (Steps to reproduce your issue)
In the Git repository run this command:

git log --raw -r -c --abbrev=6 --pretty=oneline -n1 a7144d4bc5ab58f306a1e5c73b27196fb999a63d

What did you expect to happen? (Expected behavior)
I was expecting to get this line in the output
::100644 100644 100644 639a41 111378 05ba1d MM Documentation/git-rebase.txt
What happened instead? (Actual behavior)
I got the following line instead
::100644 100644 100644 639a41 111378 05ba1d3 MM Documentation/git-rebase.txt
What's different between what you expected and what actually happened?
Since `--abbrev` is set to 6 the expected hash is `05ba1d` not `05ba1d3`.
Anything else you want to add:

If --abbrev is set to N then the size of all hashes should be the first N hex digits.

The problem with `--abbrev` is more evident with values below 7. Try with 1, 2, 3, 4, and 5, to see for yourself.

Please review the rest of the bug report below. You can delete any lines you don't wish to share.

[System Info] git version: git version 2.29.2 cpu: x86_64 no commit associated with this build sizeof-long: 8 sizeof-size_t: 8 shell-path: /bin/sh uname: Darwin 19.6.0 Darwin Kernel Version 19.6.0: Mon Aug 31 22:12:52 PDT 2020; root:xnu-6153.141.2~1/RELEASE_X86_64 x86_64 compiler info: clang: 12.0.0 (clang-1200.0.32.21) libc info: no libc information available $SHELL (typically, interactive shell): /bin/bash

[Enabled Hooks] ======================================================

Next: Junio C Hamano
Message 1 of 7 in “Bug with --abbrev option in git log?”
  1. Mário GuimarãesNov 4, 2020
  2. Junio C HamanoNov 4, 2020
  3. doc: clarify that most --abbrev[=<n>] are about minimum lengthJunio C Hamano, Nov 4, 2020
  4. Derrick StoleeNov 4, 2020
  5. doc: clarify that --abbrev=<n> is about the minimum lengthJunio C Hamano, Nov 4, 2020
  6. Derrick StoleeNov 7, 2020
  7. Mário GuimarãesNov 4, 2020

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.