{"thread":{"id":"27060","subject":"[RFC PATCH] Chain squash!/fixup! commits on autosquash","startedAt":"2011-04-11T15:34:24Z","lastAt":"2011-04-11T15:34:24Z","messageCount":1,"participants":["Carlos Martín Nieto"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"165627","messageId":"1302536064-3922-1-git-send-email-cmn@elego.de","threadId":"27060","inReplyTo":null,"subject":"[RFC PATCH] Chain squash!/fixup! commits on autosquash","fromName":"Carlos Martín Nieto","fromEmail":"cmn@elego.de","sentAt":"2011-04-11T15:34:24Z","receivedAt":"2011-04-11T15:34:24Z","isPatch":true,"sender":{"key":"cmn@elego.de","avatar":"https://avatars.githubusercontent.com/u/335443?v=4"},"body":"If one has the following commits\n\n    5154127 fixup! fixup! one\n    0d130d8 fixup! one\n    0869d30 one\n\ncurrent code will only rearrange 0d130d8 because it thinks it has\nalready checked for commits that modify it.\n\nSeparate the idea of an 'used' and an 'applied' line. Applied lines\nare the ones that have been moved to modify some commit whilst used\nlines are the ones for which we have tried to find modifications.\n---\n\nThis supports the case I originally mentioned. It however breaks quite\nbadly if one has two chains, such as\n\n    0792561 fixup! squash! squash! six\n    e72100f squash! squash! six\n    90187b8 fixup! fixup! one\n    6facd7d fixup! one\n    4f48f55 one\n    733844b squash! six\n    e9de3cc six\n    76990c9 five\n    db0d525 one\n\nbecause it will try to add 0792561 as a fixup to e72100f. However, as\nit has moved, it is made into a fixup of 90187b8, which is definitely\nbad (not that I think anybody would ever have such a chain in real\nlife).\n\nThis should be fixable by modifying the loop a bit so it doesn't read\nthe next line on each iteration so we can feed it the current\nline. Would you be interested in such a patch?  For me this is a bit\nmore elegant than removing the \"fixup!\" on commit (though my shell\nskills aren't that great).\n\n git-rebase--interactive.sh |   12 +++++++++---\n 1 files changed, 9 insertions(+), 3 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 5873ba4..a681f47 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -692,16 +692,22 @@ rearrange_squash () {\n \ttest -s \"$1.sq\" || return\n \n \tused=\n+\tapplied=\n \twhile read -r pick sha1 message\n \tdo\n \t\tcase \" $used\" in\n \t\t*\" $sha1 \"*) continue ;;\n \t\tesac\n-\t\tprintf '%s\\n' \"$pick $sha1 $message\"\n+\t\t# If it's been applied, we don't want to output the \"pick\" line\n+\t\tcase \" $applied\" in\n+\t\t\t*\" $sha1 \"*) ;;\n+\t\t\t*) printf '%s\\n' \"$pick $sha1 $message\";;\n+\t\tesac\n \t\tused=\"$used$sha1 \"\n \t\twhile read -r squash action msg\n \t\tdo\n-\t\t\tcase \" $used\" in\n+\t\t\t# Ignore the commits we've already dealt with\n+\t\t\tcase \" $used $applied \" in\n \t\t\t*\" $squash \"*) continue ;;\n \t\t\tesac\n \t\t\temit=0\n@@ -716,7 +722,7 @@ rearrange_squash () {\n \t\t\tesac\n \t\t\tif test $emit = 1; then\n \t\t\t\tprintf '%s\\n' \"$action $squash $action! $msg\"\n-\t\t\t\tused=\"$used$squash \"\n+\t\t\t\tapplied=\"$applied$squash \"\n \t\t\tfi\n \t\tdone <\"$1.sq\"\n \tdone >\"$1.rearranged\" <\"$1\"\n-- \n1.7.4.1\n"}]}