From: Junio C Hamano <gitster@pobox.com>
To: Sven van Haastregt <svenvh@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] git-submodule.sh: shorten submodule SHA-1s using rev-parse
Date: Tue, 22 Jan 2019 12:22:45 -0800 [thread overview]
Message-ID: <xmqqfttkfnmy.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <20190120204653.3224-1-svenvh@gmail.com> (Sven van Haastregt's message of "Sun, 20 Jan 2019 20:46:53 +0000")
Sven van Haastregt <svenvh@gmail.com> writes:
> Until now, `git submodule summary` was always emitting 7-character
> SHA-1s that have a higher chance of being ambiguous for larger
> repositories. Use `git rev-parse --short` instead, which will
> determine suitable short SHA-1 lengths.
In general I think it is a good idea to scale as the repository
grows by asking "rev-parse --short" to do the job.
One thing it is not clear to me is that this codepath is prepared to
handle sha1_src and sha1_dst referring to an object that does not
exist (i.e. $missing_(src|dst)=t); the original code will still give
us 7 hexdigit to show on the headline, but does the updated code
that uses "rev-parse --short" give us a reasonable output?
>
> Signed-off-by: Sven van Haastregt <svenvh@gmail.com>
> ---
> git-submodule.sh | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/git-submodule.sh b/git-submodule.sh
> index 5e608f8bad..a422b0728d 100755
> --- a/git-submodule.sh
> +++ b/git-submodule.sh
> @@ -850,8 +850,8 @@ cmd_summary() {
> ;;
> esac
>
> - sha1_abbr_src=$(echo $sha1_src | cut -c1-7)
> - sha1_abbr_dst=$(echo $sha1_dst | cut -c1-7)
> + sha1_abbr_src=$(GIT_DIR="$name/.git" git rev-parse --short $sha1_src)
> + sha1_abbr_dst=$(GIT_DIR="$name/.git" git rev-parse --short $sha1_dst)
> if test $status = T
> then
> blob="$(gettext "blob")"
next prev parent reply other threads:[~2019-01-22 20:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-20 20:46 [PATCH] git-submodule.sh: shorten submodule SHA-1s using rev-parse Sven van Haastregt
2019-01-22 15:24 ` Johannes Schindelin
2019-01-22 20:23 ` Junio C Hamano
2019-01-24 21:49 ` Jeff King
2019-01-25 13:05 ` Johannes Schindelin
2019-01-22 20:22 ` Junio C Hamano [this message]
2019-01-22 21:38 ` Sven van Haastregt
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=xmqqfttkfnmy.fsf@gitster-ct.c.googlers.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=svenvh@gmail.com \
/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 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 NNTP newsgroup(s).