All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Heidelberg <markus.heidelberg@web.de>
To: Jeff Epler <jepler@unpythonic.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v2] add --abbrev to 'git cherry'
Date: Sat, 30 May 2009 18:26:11 +0200	[thread overview]
Message-ID: <200905301826.11924.markus.heidelberg@web.de> (raw)
In-Reply-To: <20090530140349.GA25265@unpythonic.net>

Jeff Epler, 30.05.2009:
>  Documentation/git-cherry.txt |    5 ++++-
>  builtin-log.c                |   24 +++++++++++++++++++-----
>  2 files changed, 23 insertions(+), 6 deletions(-)

You could also add --abbrev= to the bash completion.

> diff --git a/Documentation/git-cherry.txt b/Documentation/git-cherry.txt
> index 7deefda..5c03da0 100644
> --- a/Documentation/git-cherry.txt
> +++ b/Documentation/git-cherry.txt
> @@ -49,6 +49,9 @@ OPTIONS
>  -v::
>  	Verbose.
>  
> +--abbrev[=<n>]::
> +	Abbreviate commit ids to the given number of characters

The full stop is missing :)
And you could add "The default value is 7." as in the git-branch docs.
Or even copy the whole description from there for consistency, it also
mentions that this sets the minimum length, the displayed SHA1 may be
longer, but more about this below.

> diff --git a/builtin-log.c b/builtin-log.c
> index f10cfeb..1f3093e 100644
> --- a/builtin-log.c
> +++ b/builtin-log.c
> @@ -1218,12 +1232,12 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
>  			struct strbuf buf = STRBUF_INIT;
>  			pretty_print_commit(CMIT_FMT_ONELINE, commit,
>  			                    &buf, 0, NULL, NULL, 0, 0);
> -			printf("%c %s %s\n", sign,
> +			printf("%c %.*s %s\n", sign, abbrev,
>  			       sha1_to_hex(commit->object.sha1), buf.buf);
>  			strbuf_release(&buf);
>  		}
>  		else {
> -			printf("%c %s\n", sign,
> +			printf("%c %.*s\n", sign, abbrev,
>  			       sha1_to_hex(commit->object.sha1));
>  		}

There is no test for unique ids. "git cherry --abbrev=4" always prints 4
chars per SHA1, so "git show" on these SHA1s mostly gives "error: short
SHA1 xxxx is ambiguous." in git.git.

find_unique_abbrev() will help.

Markus

  reply	other threads:[~2009-05-30 16:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-30 14:03 [PATCH v2] add --abbrev to 'git cherry' Jeff Epler
2009-05-30 16:26 ` Markus Heidelberg [this message]
2009-05-30 16:53   ` [PATCH v3] " Jeff Epler
2009-05-30 21:13     ` Stephen Boyd
2009-05-30 23:08       ` Junio C Hamano
2009-05-30 23:44         ` Markus Heidelberg
2009-05-31  0:16           ` Junio C Hamano
2009-05-31  4:53         ` Stephen Boyd
     [not found]         ` <20090531133804.GB16770@unpythonic.net>
     [not found]           ` <7v8wkdrqys.fsf@alter.siamese.dyndns.org>
2009-06-01 11:54             ` Jeff Epler

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200905301826.11924.markus.heidelberg@web.de \
    --to=markus.heidelberg@web.de \
    --cc=git@vger.kernel.org \
    --cc=jepler@unpythonic.net \
    /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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.