summaryrefslogtreecommitdiff
path: root/git-rebase--interactive.sh
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2017-07-14 16:45:06 +0200
committerJunio C Hamano <gitster@pobox.com>2017-07-27 15:35:05 -0700
commit1f4044af7f35f9979d464bc2009b554e8e9dfb99 (patch)
treefecc4bbeecb63ac7d569eadd0fe4c2bbcdbb40d4 /git-rebase--interactive.sh
parent4b8b65d706f92887c9b80d586dbdcc2abfde60be (diff)
downloadgit-1f4044af7f35f9979d464bc2009b554e8e9dfb99.tar.gz
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 <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-rebase--interactive.sh')
-rw-r--r--git-rebase--interactive.sh7
1 files changed, 6 insertions, 1 deletions
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 93372c62b2..9d65212b7f 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -760,7 +760,12 @@ transform_todo_ids () {
;;
*)
sha1=$(git rev-parse --verify --quiet "$@" ${rest%%[ ]*}) &&
- rest="$sha1 ${rest#*[ ]}"
+ if test "a$rest" = "a${rest#*[ ]}"
+ then
+ rest=$sha1
+ else
+ rest="$sha1 ${rest#*[ ]}"
+ fi
;;
esac
printf '%s\n' "$command${rest:+ }$rest"