summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven van Haastregt <svenvh@gmail.com>2019-02-03 21:00:27 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-02-04 21:33:56 (GMT)
commit0586a438f64bc13d6634379cbeeaa96c9e8241d9 (patch)
treea0bea11a27cc9c805b9801e5d4726592b3a69c70
parent0d0ac3826a3bbb9247e39e12623bbcfdd722f24c (diff)
downloadgit-0586a438f64bc13d6634379cbeeaa96c9e8241d9.zip
git-0586a438f64bc13d6634379cbeeaa96c9e8241d9.tar.gz
git-0586a438f64bc13d6634379cbeeaa96c9e8241d9.tar.bz2
git-submodule.sh: shorten submodule SHA-1s using rev-parse
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. When a submodule hasn't been initialized with "submodule init" or not cloned, `git rev-parse` would not work in it yet; as a fallback, use the original method of cutting at 7 hexdigits. Signed-off-by: Sven van Haastregt <svenvh@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rwxr-xr-xgit-submodule.sh7
1 files changed, 5 insertions, 2 deletions
diff --git a/git-submodule.sh b/git-submodule.sh
index 5e608f8..e26146e 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -850,8 +850,11 @@ 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 2>/dev/null ||
+ echo $sha1_src | cut -c1-7)
+ sha1_abbr_dst=$(GIT_DIR="$name/.git" git rev-parse --short $sha1_dst 2>/dev/null ||
+ echo $sha1_dst | cut -c1-7)
+
if test $status = T
then
blob="$(gettext "blob")"