Skip to content

Commit f70d6b4

Browse files
committed
rebase -i: do not invent onelines when expanding/collapsing SHA-1s
To avoid problems with short SHA-1s that become non-unique during the rebase, we rewrite the todo script with short/long SHA-1s before and after letting the user edit the script. Since SHA-1s are not intuitive for humans, rebase -i also provides the onelines (commit message subjects) in the script, purely for the user's convenience. It is very possible to generate a todo script via different means than rebase -i and then to let rebase -i run with it; In this case, these onelines are not required. And this is where the expand/collapse machinery has a bug: it *expects* that oneline, and failing to find one reuses the previous SHA-1 as "oneline". It was most likely an oversight, and made implementation in the (quite limiting) shell script language less convoluted. However, we are about to reimplement performance-critical parts in C (and due to spawning a git.exe process for every single line of the todo script, the expansion/collapsing of the SHA-1s *is* performance-hampering on Windows), therefore let's fix this bug to make cross-validation with the C version of that functionality possible. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 5876ed5 commit f70d6b4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

git-rebase--interactive.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,12 @@ transform_todo_ids () {
750750
;;
751751
*)
752752
sha1=$(git rev-parse --verify --quiet "$@" ${rest%%[ ]*}) &&
753-
rest="$sha1 ${rest#*[ ]}"
753+
if test "a$rest" = "a${rest#*[ ]}"
754+
then
755+
rest=$sha1
756+
else
757+
rest="$sha1 ${rest#*[ ]}"
758+
fi
754759
;;
755760
esac
756761
printf '%s\n' "$command${rest:+ }$rest"

0 commit comments

Comments
 (0)