git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: lists@haller-berlin.de (Stefan Haller)
To: gitster@pobox.com (Junio C Hamano)
Cc: dev+git@drbeat.li (Beat Bolli),
	git@vger.kernel.org, paulus@samba.org (Paul Mackerras)
Subject: Re: [PATCH v2] gitk: Add a "Copy commit summary" command
Date: Fri, 17 Jul 2015 10:50:56 +0200	[thread overview]
Message-ID: <1m7p7z9.36ajnyli8ph2M%lists@haller-berlin.de> (raw)
In-Reply-To: <xmqq380o593i.fsf@gitster.dls.corp.google.com>

Junio C Hamano <gitster@pobox.com> wrote:

> Beat Bolli <dev+git@drbeat.li> writes:
> 
> > When referring to earlier commits in commit messages or other text, one
> > of the established formats is
> >
> >     <abbrev-sha> ("<summary>", <author-date>)
> > ...
> > +proc copysummary {} {
> > +    global rowmenuid commitinfo
> > +
> > +    set id [string range $rowmenuid 0 7]
> > +    set info $commitinfo($rowmenuid)
> > +    set commit [lindex $info 0]
> 
> 7 hexdigits is not always an appropriate value for all projects.
> The minimum necessary to guarantee uniqueness varies on project, and
> it is not a good idea to hardcode such a small value.  Not-so-old
> Linux kernel history seems to use at least 12, for example.
> 
> I believe that the "one of the established formats" comes from a
> "git one" alias I published somewhere long time ago, that did
> something like this:
> 
>   git show -s --abbrev=8 --pretty='format:%h (%s, %ai' "$@" |
>   sed -e 's/ [012][0-9]:[0-5][0-9]:[0-5][0-9] [-+][0-9][0-9][0-9][0-9]$/)/'
> 
> where the combination of --abbrev=8 and format:%h asks for a unique
> abbreviation that is at least 8 hexdigits long but can use more than
> 8 if it is not long enough to uniquely identify the given commit.

For the intended use case of this feature (referring to earlier commits
in commit messages), guaranteeing uniqueness isn't sufficiant either.
What is unique at the time of creating the commit might no longer be
unique a few years later.

So one strategy would be to add one or two digits to what %h returns, to
give some future leeway; or rely on the user to configure core.abbrev
appropriatly for their project; or just make the hard-coded value
configurable, as Hannes suggests.

FWIW, a discussion of this that I find useful can be found here:
<http://blog.cuviper.com/2013/11/10/how-short-can-git-abbreviate/>.


-- 
Stefan Haller
Berlin, Germany
http://www.haller-berlin.de/

  reply	other threads:[~2015-07-17  8:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-16 15:29 [PATCH v2] gitk: Add a "Copy commit summary" command Beat Bolli
2015-07-16 17:02 ` Junio C Hamano
2015-07-17  8:50   ` Stefan Haller [this message]
2015-07-17  9:16     ` Beat Bolli
2015-07-16 20:48 ` Johannes Sixt
2015-07-17  9:22 ` Paul Mackerras
2015-07-17 15:30   ` Junio C Hamano
2015-07-18 12:23     ` Paul Mackerras
2015-07-18 12:45       ` Beat Bolli

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=1m7p7z9.36ajnyli8ph2M%lists@haller-berlin.de \
    --to=lists@haller-berlin.de \
    --cc=dev+git@drbeat.li \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=paulus@samba.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public 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).