{"thread":{"id":"947","subject":"[PATCH 2/2] Adds support to git-commit-script for an optional .nextmsg file. [rev 3]","startedAt":"2005-06-15T07:36:00Z","lastAt":"2005-06-15T07:36:00Z","messageCount":1,"participants":["Jon Seymour"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"4968","messageId":"20050615073600.25144.qmail@blackcubes.dyndns.org","threadId":"947","inReplyTo":null,"subject":"[PATCH 2/2] Adds support to git-commit-script for an optional .nextmsg file. [rev 3]","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2005-06-15T07:36:00Z","receivedAt":"2005-06-15T07:36:00Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"\nIf ${GIT_DIR}/.nextmsg exists, the text will be copied into the .editmsg file\ntogether with a sentinel line prior to invoking the editor.\n\nAfter editing, the edited text (but not the status lines) are saved\nback to the ${GIT_DIR}/.nextmsg file.\n\nIf the sentinel line still exists in .editmsg after editing, the\nfile is truncated, thereby causing the commit to abort (per previous\nbehaviour).\n\nThe ${GIT_DIR}/.nextmsg file is deleted if, and only if,\nthe commit was successful.\n\nThe behaviour of git-commit-script is unchanged with respect to the\nprevious versions if ${GIT_DIR}/.nextmsg does not exist.\n\nSigned-off-by: Jon Seymour <jon.seymour@gmail.com>\n\n---\nThis patch set is a complete replacement for:\n\n     [PATCH 1/1] Add support for an optional .nextmsg file to git-commit-script\n\nI have incorporated most of Junio's feedback, except the prompting\nsuggestion and the suggested restructuring is slightly different.\n\n[rev 2] fixed 2 errors with handling of .nextmsg file\n[rev 3] whitespace fixups\n\n\n---\n\n git-commit-script |   32 +++++++++++++++++++++++++++++++-\n 1 files changed, 31 insertions(+), 1 deletions(-)\n\ndiff --git a/git-commit-script b/git-commit-script\n--- a/git-commit-script\n+++ b/git-commit-script\n@@ -26,12 +26,41 @@ EOF\n \tgit-status-script\n }\n \n+merge_next_message()\n+{\n+\tstatus=$1\n+\tnext=$2\n+\tmv -f $status .status.$$ || exit 1\n+\tcat >$status <<EOF\n+$SENTINEL\n+#---\n+$(cat $next)\n+#---\n+$(cat .status.$$)\n+EOF\n+\trm .status.$$\n+}\n+\n+save_next_message()\n+{\n+\tstatus=$1\n+\tnext=$2\n+\tgrep -v \"^#\" < $status > $next\n+\tif grep \"^$SENTINEL\" < $status >/dev/null; then\n+\t\t:> $status\n+\t\techo \"commit aborted - you must delete the SENTINEL line to confirm the commit\"\n+\tfi\n+}\n+\n edit_message() {\n \tstatus=$1\n \tmsg=$2\n+\tnext=$3\n \n \t:> $msg\n+\t[ -f \"$next\" ] && merge_next_message \"$status\" \"$next\"\n \t${VISUAL:-${EDITOR:-vi}} \"$status\"\n+\t[ -f \"$next\" ] && save_next_message \"$status\" \"$next\"\n \tgrep -v '^#' < $status | git-stripspace >$msg\n \t[ -s $msg ]\n \treturn $?\n@@ -67,8 +96,9 @@ if ! print_status > .editmsg; then\n \texit 1\n fi\n \n-if edit_message .editmsg .cmitmsg; then\n+if edit_message .editmsg .cmitmsg ${GIT_DIR}/.nextmsg ; then\n \texec_commit .cmitmsg\n \t[ -f .editmsg ] && rm .editmsg\n \t[ -f .cmitmsg ] && rm .cmitmsg\n+\t[ -f ${GIT_DIR}/.nextmsg ] && rm ${GIT_DIR}/.nextmsg\n fi\n------------\n"}]}