{"thread":{"id":"27132","subject":"[RFC PATCH v2] Chain squash!/fixup! commits on autosquash","startedAt":"2011-04-19T15:54:22Z","lastAt":"2011-04-19T15:54:22Z","messageCount":1,"participants":["=?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?="],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"166085","messageId":"20110419155417.GA13042@bee.lab.cmartin.tk","threadId":"27132","inReplyTo":null,"subject":"[RFC PATCH v2] Chain squash!/fixup! commits on autosquash","fromName":"=?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?=","fromEmail":"cmn@elego.de","sentAt":"2011-04-19T15:54:22Z","receivedAt":"2011-04-19T15:54:22Z","isPatch":true,"sender":{"key":"cmn@elego.de","avatar":"https://avatars.githubusercontent.com/u/335443?v=4"},"body":"Separate 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\nmodifications. Applied lines are given priority when looking for\nmodifications. Thus, if one has these commits\n\n    944f57d fixup! squash! six\n    3512067 fixup! squash! squash! six\n    49af780 fixup! fixup! one\n    df6f708 fixup! one\n    6ac57d9 one\n    6e754da squash! squash! six\n    733844b squash! six\n    e9de3cc six\n    76990c9 five\n\nthey will be correctly reordered to\n\n    pick e9de3cc six\n    squash 733844b squash! six\n    squash 6e754da squash! squash! six\n    fixup 944f57d fixup! squash! six\n    fixup 3512067 fixup! squash! squash! six\n    pick 6ac57d9 one\n    fixup df6f708 fixup! one\n    fixup 49af780 fixup! fixup! one\n---\n\nTo be honest, I'm not sure if we want to support something like this,\nbut it seemed too crazy not to try.\n\nThis is an attempt to fix\nhttp://thread.gmane.org/gmane.comp.version-control.git/170883 (rebase\nautosquash doesn't recognise a chain of fixups, 2011-04-05)\n\nCheers,\n   cmn\n\n git-rebase--interactive.sh |   36 +++++++++++++++++++++++++++++++-----\n 1 files changed, 31 insertions(+), 5 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 5873ba4..5e7b393 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -692,16 +692,28 @@ rearrange_squash () {\n \ttest -s \"$1.sq\" || return\n \n \tused=\n+\tapplied=\n+\tRE=\"$1.re\"\n+\tskiplines=0\n+\t# Initialize the list with the first line from the input\n+\thead -n 1 \"$1\" > $RE\n \twhile read -r pick sha1 message\n \tdo\n+\t\techo \"dealing with $sha1 skiplines=$skiplines\" >> \"rebase.log\"\n \t\tcase \" $used\" in\n-\t\t*\" $sha1 \"*) continue ;;\n+\t\t*\" $sha1 \"*) next_input_line \"$skiplines\" \"$1\" \"$RE\"; skiplines=\"$(expr $skiplines + 1)\"; continue ;;\n+\t\tesac\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\tprintf '%s\\n' \"$pick $sha1 $message\"\n \t\tused=\"$used$sha1 \"\n+\t\temitted=0;\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@@ -715,15 +727,29 @@ rearrange_squash () {\n \t\t\t\tcase \"$message\" in \"$msg\"*) emit=1;; esac ;;\n \t\t\tesac\n \t\t\tif test $emit = 1; then\n+\t\t\t\temitted=1\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\t\techo \"$action $squash $action! $msg\" >> \"$RE\"\n \t\t\tfi\n \t\tdone <\"$1.sq\"\n-\tdone >\"$1.rearranged\" <\"$1\"\n+\n+\t\t# If no lines were emitted, it means we don't need take an\n+\t\t# early look to any more lines, so put the next one from the input into the queue\n+\t\tif test \"$emmited\" != 1; then\n+\t\t\tnext_input_line \"$skiplines\" \"$1\" \"$RE\"\n+\t\t\tskiplines=\"$(expr $skiplines + 1)\"\n+\t\tfi\n+\n+\tdone >\"$1.rearranged\" <\"$RE\"\n \tcat \"$1.rearranged\" >\"$1\"\n \trm -f \"$1.sq\" \"$1.rearranged\"\n }\n \n+next_input_line () {\n+\ttail --lines=\"+$1\" \"$2\" | head -n 1 >> \"$3\"\n+}\n+\n LF='\n '\n parse_onto () {\n-- \n1.7.4.2.437.g4fc7e.dirty\n"}]}