Skip to content

Commit e37eae0

Browse files
Denton-Lgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d047154 commit e37eae0

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

contrib/git-resurrect.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,18 @@ search_reflog_merges () {
3737
)
3838
}
3939

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')
4241

4342
search_merges () {
4443
git rev-list --all --grep="Merge branch '$1'" \
4544
--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}"
4746
}
4847

4948
search_merge_targets () {
5049
git rev-list --all --grep="Merge branch '[^']*' into $branch\$" \
5150
--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} "
5352
}
5453

5554
dry_run=

0 commit comments

Comments
 (0)