{"thread":{"id":"944","subject":"[PATCH 2/2] Adds support to git-commit-script for an optional .nextmsg file.","startedAt":"2005-06-15T05:45:33Z","lastAt":"2005-06-15T05:45:33Z","messageCount":1,"participants":["Jon Seymour"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"4965","messageId":"20050615054533.9981.qmail@blackcubes.dyndns.org","threadId":"944","inReplyTo":null,"subject":"[PATCH 2/2] Adds support to git-commit-script for an optional .nextmsg file.","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2005-06-15T05:45:33Z","receivedAt":"2005-06-15T05:45:33Z","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\n git-commit-script |   34 ++++++++++++++++++++++++++++++++--\n 1 files changed, 32 insertions(+), 2 deletions(-)\n\ndiff --git a/git-commit-script b/git-commit-script\n--- a/git-commit-script\n+++ b/git-commit-script\n@@ -5,7 +5,7 @@ print_status() {\n \t\tif [ -z \"$(git-ls-files)\" ]; then\n \t\t\techo Nothing to commit 1>&2\n \t\t\treturn 1\n-\t\tfi\n+\tfi\n cat <<EOF\n #\n # Initial commit\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+\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+\tgrep -v \"^#\" < $status > $next\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 .nextmsg ] && rm .nextmsg\n fi\n------------\n"}]}