提交 0586a438 编写于 作者: S Sven van Haastregt 提交者: Junio C Hamano

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: NSven van Haastregt <svenvh@gmail.com>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 0d0ac382
......@@ -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")"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册