Skip to content

Commit dda6346

Browse files
bk2204gitster
authored andcommitted
submodule: make zero-oid comparison hash function agnostic
With SHA-256, the length of the all-zeros object ID is longer. Add a function to git-submodule.sh to check if a full hex object ID is the all-zeros value, and use it to check the output we're parsing from git diff-files or diff-index. Signed-off-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent eccb5a5 commit dda6346

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

git-submodule.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ isnumber()
8282
n=$(($1 + 0)) 2>/dev/null && test "$n" = "$1"
8383
}
8484

85+
# Given a full hex object ID, is this the zero OID?
86+
is_zero_oid () {
87+
echo "$1" | sane_egrep '^0+$' >/dev/null 2>&1
88+
}
89+
8590
# Sanitize the local git environment for use within a submodule. We
8691
# can't simply use clear_local_git_env since we want to preserve some
8792
# of the settings from GIT_CONFIG_PARAMETERS.
@@ -780,7 +785,7 @@ cmd_summary() {
780785
while read -r mod_src mod_dst sha1_src sha1_dst status name
781786
do
782787
if test -z "$cached" &&
783-
test $sha1_dst = 0000000000000000000000000000000000000000
788+
is_zero_oid $sha1_dst
784789
then
785790
case "$mod_dst" in
786791
160000)

0 commit comments

Comments
 (0)