From: Junio C Hamano <email@example.com> To: "Mário Guimarães" <firstname.lastname@example.org> Cc: email@example.com Subject: Re: Bug with --abbrev option in git log? Date: Tue, 03 Nov 2020 17:12:42 -0800 [thread overview] Message-ID: <firstname.lastname@example.org> (raw) In-Reply-To: <CAF7CYk51BC0KcsBb0KjKWAj17AMU2c9Y6Y81ddwX6oOAFYhT8w@mail.gmail.com> (=?utf-8?Q?=22M=C3=A1rio_Guimar=C3=A3es=22's?= message of "Wed, 4 Nov 2020 00:55:36 +0000") Mário Guimarães <email@example.com> writes: > In the Git repository run this command: > > git log --raw -r -c --abbrev=6 --pretty=oneline -n1 > a7144d4bc5ab58f306a1e5c73b27196fb999a63d This is not one of my object, so above won't be usable as reproduction recipe. But that is OK. > 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 The above command tells us that you locally have an object whose name begins with 05ba1d3, which I do not have. But my history shared with the entire world has an object whose name begins with 05ba1d7, and I am reasonably sure that your repository has it, since it is a part of 17f26a9e (git-am: fix shell quoting, 2009-01-14). So in my repository, 05ba1d is enough to uniquely identify 05ba1d7, but in your repository 05ba1d is not enough to uniquely identify 05ba1d3, because 05ba1d7 also exists in your repository. And when the object cannot be uniquely specified with the given abbreviation width, Git makes sure its output is usable to uniquely identify the object it wants to name. In short, I think what you observed is totally expected. The documentation has some room for improvement, I also think. How about saying something like this? Documentation/diff-options.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git i/Documentation/diff-options.txt w/Documentation/diff-options.txt index ee52b65e46..114e440c5b 100644 --- i/Documentation/diff-options.txt +++ w/Documentation/diff-options.txt @@ -446,7 +446,8 @@ endif::git-format-patch --abbrev[=<n>]:: Instead of showing the full 40-byte hexadecimal object name in diff-raw format output and diff-tree header - lines, show only a partial prefix. + lines, show only a partial prefix that uses at least '<n>' + hexdigits. In diff-patch output format, `--full-index` takes higher precedence, i.e. if `--full-index` is specified, full blob names will be shown regardless of `--abbrev`.
next prev parent reply other threads:[~2020-11-04 1:12 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-11-04 0:55 Mário Guimarães 2020-11-04 1:12 ` Junio C Hamano [this message] 2020-11-04 1:44 ` [PATCH] doc: clarify that most --abbrev[=<n>] are about minimum length Junio C Hamano 2020-11-04 13:24 ` Derrick Stolee 2020-11-04 22:01 ` [PATCH v2] doc: clarify that --abbrev=<n> is about the " Junio C Hamano 2020-11-07 15:09 ` Derrick Stolee 2020-11-04 2:11 ` Bug with --abbrev option in git log? Mário Guimarães
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style List information: http://vger.kernel.org/majordomo-info.html * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --subject='Re: Bug with --abbrev option in git log?' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Code repositories for project(s) associated with this inbox: https://80x24.org/mirrors/git.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).