git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
From: "Mário Guimarães" <mario.luis.guimaraes@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: Bug with --abbrev option in git log?
Date: Wed, 4 Nov 2020 02:11:13 +0000	[thread overview]
Message-ID: <CAF7CYk6SVx396=fLZ2yMVTaS2XK58M_=kT7J+th_T8VqM+HmaQ@mail.gmail.com> (raw)
In-Reply-To: <xmqqk0v1q60l.fsf@gitster.c.googlers.com>

Hello

Junio C Hamano <gitster@pobox.com> escreveu no dia quarta, 4/11/2020 à(s) 01:12:
>
> Mário Guimarães  <mario.luis.guimaraes@gmail.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`.

What about this? It makes clear that the prefix is still one that can
be used to identify the object in the repository.

diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index ee52b65e46..c15b4adb28 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -446,8 +446,9 @@ 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.
-       In diff-patch output format, `--full-index` takes higher
+       lines, show only the minimal prefix that identifies
+       the object using 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`.
        Non default number of digits can be specified with `--abbrev=<n>`.

      parent reply	other threads:[~2020-11-04  2:11 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
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   ` Mário Guimarães [this message]

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 \
    --in-reply-to='CAF7CYk6SVx396=fLZ2yMVTaS2XK58M_=kT7J+th_T8VqM+HmaQ@mail.gmail.com' \
    --to=mario.luis.guimaraes@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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).