Skip to content

Commit 9f55a77

Browse files
committed
Merge branch 'ks/rebase-i-abbrev'
The insn sheet "git rebase -i" creates did not fully honor core.abbrev settings. * ks/rebase-i-abbrev: rebase -i: use full object name internally throughout the script
2 parents a6c6815 + edb72d5 commit 9f55a77

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

git-rebase--interactive.sh

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -961,14 +961,13 @@ else
961961
revisions=$onto...$orig_head
962962
shortrevisions=$shorthead
963963
fi
964-
git rev-list $merges_option --pretty=oneline --abbrev-commit \
965-
--abbrev=7 --reverse --left-right --topo-order \
964+
git rev-list $merges_option --pretty=oneline --reverse --left-right --topo-order \
966965
$revisions ${restrict_revision+^$restrict_revision} | \
967966
sed -n "s/^>//p" |
968-
while read -r shortsha1 rest
967+
while read -r sha1 rest
969968
do
970969

971-
if test -z "$keep_empty" && is_empty_commit $shortsha1 && ! is_merge_commit $shortsha1
970+
if test -z "$keep_empty" && is_empty_commit $sha1 && ! is_merge_commit $sha1
972971
then
973972
comment_out="$comment_char "
974973
else
@@ -977,9 +976,8 @@ do
977976

978977
if test t != "$preserve_merges"
979978
then
980-
printf '%s\n' "${comment_out}pick $shortsha1 $rest" >>"$todo"
979+
printf '%s\n' "${comment_out}pick $sha1 $rest" >>"$todo"
981980
else
982-
sha1=$(git rev-parse $shortsha1)
983981
if test -z "$rebase_root"
984982
then
985983
preserve=t
@@ -996,7 +994,7 @@ do
996994
if test f = "$preserve"
997995
then
998996
touch "$rewritten"/$sha1
999-
printf '%s\n' "${comment_out}pick $shortsha1 $rest" >>"$todo"
997+
printf '%s\n' "${comment_out}pick $sha1 $rest" >>"$todo"
1000998
fi
1001999
fi
10021000
done
@@ -1020,8 +1018,8 @@ then
10201018
# just the history of its first-parent for others that will
10211019
# be rebasing on top of it
10221020
git rev-list --parents -1 $rev | cut -d' ' -s -f2 > "$dropped"/$rev
1023-
short=$(git rev-list -1 --abbrev-commit --abbrev=7 $rev)
1024-
sane_grep -v "^[a-z][a-z]* $short" <"$todo" > "${todo}2" ; mv "${todo}2" "$todo"
1021+
sha1=$(git rev-list -1 $rev)
1022+
sane_grep -v "^[a-z][a-z]* $sha1" <"$todo" > "${todo}2" ; mv "${todo}2" "$todo"
10251023
rm "$rewritten"/$rev
10261024
fi
10271025
done
@@ -1054,6 +1052,7 @@ has_action "$todo" ||
10541052
return 2
10551053

10561054
cp "$todo" "$todo".backup
1055+
collapse_todo_ids
10571056
git_sequence_editor "$todo" ||
10581057
die_abort "Could not execute editor"
10591058

t/t3404-rebase-interactive.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,4 +1039,11 @@ test_expect_success 'short SHA-1 collide' '
10391039
)
10401040
'
10411041

1042+
test_expect_success 'respect core.abbrev' '
1043+
git config core.abbrev 12 &&
1044+
set_cat_todo_editor &&
1045+
test_must_fail git rebase -i HEAD~4 >todo-list &&
1046+
test 4 = $(grep -c "pick [0-9a-f]\{12,\}" todo-list)
1047+
'
1048+
10421049
test_done

0 commit comments

Comments
 (0)