diff options
author | Sven van Haastregt <svenvh@gmail.com> | 2019-02-04 00:00:27 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-02-05 00:33:56 +0300 |
commit | 0586a438f64bc13d6634379cbeeaa96c9e8241d9 (patch) | |
tree | a0bea11a27cc9c805b9801e5d4726592b3a69c70 /git-submodule.sh | |
parent | 0d0ac3826a3bbb9247e39e12623bbcfdd722f24c (diff) |
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>
Diffstat (limited to 'git-submodule.sh')
-rwxr-xr-x | git-submodule.sh | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/git-submodule.sh b/git-submodule.sh index 5e608f8bad3..e26146e7211 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")" |