From: Sven van Haastregt <svenvh@gmail.com>
To: git@vger.kernel.org
Cc: Sven van Haastregt <svenvh@gmail.com>
Subject: [PATCH v2] git-submodule.sh: shorten submodule SHA-1s using rev-parse
Date: Sun, 27 Jan 2019 19:27:40 +0000 [thread overview]
Message-ID: <20190127192740.8678-1-svenvh@gmail.com> (raw)
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.
We cannot rely on always successfully invoking `git rev-parse` in the
submodule directory. Keep the old method using `cut` as a fallback.
Signed-off-by: Sven van Haastregt <svenvh@gmail.com>
---
Differences since v1: Keep the old method using `cut` as a fallback.
git-submodule.sh | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/git-submodule.sh b/git-submodule.sh
index 5e608f8bad..5bd724e63b 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -850,8 +850,16 @@ cmd_summary() {
;;
esac
+ # Ensure we have crudely abbreviated SHA-1s as fallback in case
+ # rev-parse fails to shorten the SHA-1s.
sha1_abbr_src=$(echo $sha1_src | cut -c1-7)
sha1_abbr_dst=$(echo $sha1_dst | cut -c1-7)
+
+ sha1_abbrev=$(GIT_DIR="$name/.git" git rev-parse --short $sha1_src) &&
+ sha1_abbr_src=$sha1_abbrev
+ sha1_abbrev=$(GIT_DIR="$name/.git" git rev-parse --short $sha1_dst) &&
+ sha1_abbr_dst=$sha1_abbrev
+
if test $status = T
then
blob="$(gettext "blob")"
--
2.20.1.dirty
next reply other threads:[~2019-01-27 19:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-27 19:27 Sven van Haastregt [this message]
2019-01-27 23:46 ` [PATCH v2] git-submodule.sh: shorten submodule SHA-1s using rev-parse Eric Sunshine
2019-01-28 2:33 ` Junio C Hamano
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=20190127192740.8678-1-svenvh@gmail.com \
--to=svenvh@gmail.com \
--cc=git@vger.kernel.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.
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).