contrib/git-resurrect.sh: use hash-agnostic OID pattern
Since Git now supports hashes other than SHA-1, the hash length isn't guaranteed to be 40 characters. Replace $_x40 with a hash-agnostic OID pattern. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Denton Liu committed
Oct 7, 2020 at 23:44 UTC
e37eae0c1e13cb418947383f7c803d9463bfa3d7
1 file changed
+3
-4
contrib/git-resurrect.sh
+3
-4
@@ -37,19 +37,18 @@ search_reflog_merges () {
37
)
38
}
39
40
-_x40="[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]"
41
-_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
40
+oid_pattern=$(git hash-object --stdin </dev/null | sed -e 's/./[0-9a-f]/g')
41
42
search_merges () {
43
git rev-list --all --grep="Merge branch '$1'" \
44
--pretty=tformat:"%P %s" |
46
- sed -ne "/^$_x40 \($_x40\) Merge .*/ {s//\1/p;$early_exit}"
45
+ sed -ne "/^$oid_pattern \($oid_pattern\) Merge .*/ {s//\1/p;$early_exit}"
46
}
47
48
search_merge_targets () {
49
git rev-list --all --grep="Merge branch '[^']*' into $branch\$" \
50
--pretty=tformat:"%H %s" --all |
52
- sed -ne "/^\($_x40\) Merge .*/ {s//\1/p;$early_exit} "
51
+ sed -ne "/^\($oid_pattern\) Merge .*/ {s//\1/p;$early_exit} "
52
}
53
54
dry_run=