If ${GIT_DIR}/.nextmsg exists, the text will be copied into the .editmsg file together with a sentinel line prior to invoking the editor. After editing, the edited text (but not the status lines) are saved back to the ${GIT_DIR}/.nextmsg file. If the sentinel line still exists in .editmsg after editing, the file is truncated, thereby causing the commit to abort (per previous behaviour). The ${GIT_DIR}/.nextmsg file is deleted if, and only if, the commit was successful. The behaviour of git-commit-script is unchanged with respect to the previous versions if ${GIT_DIR}/.nextmsg does not exist. Signed-off-by: Jon Seymour <jon.seymour@gmail.com> --- This patch set is a complete replacement for: [PATCH 1/1] Add support for an optional .nextmsg file to git-commit-script I have incorporated most of Junio's feedback, except the prompting suggestion and the suggested restructuring is slightly different. [rev 2] fixed 2 errors with handling of .nextmsg file [rev 3] whitespace fixups --- git-commit-script | 32 +++++++++++++++++++++++++++++++- 1 files changed, 31 insertions(+), 1 deletions(-) diff --git a/git-commit-script b/git-commit-script --- a/git-commit-script +++ b/git-commit-script @@ -26,12 +26,41 @@ EOF git-status-script } +merge_next_message() +{ + status=$1 + next=$2 + mv -f $status .status.$$ || exit 1 + cat >$status <<EOF +$SENTINEL +#--- +$(cat $next) +#--- +$(cat .status.$$) +EOF + rm .status.$$ +} + +save_next_message() +{ + status=$1 + next=$2 + grep -v "^#" < $status > $next + if grep "^$SENTINEL" < $status >/dev/null; then + :> $status + echo "commit aborted - you must delete the SENTINEL line to confirm the commit" + fi +} + edit_message() { status=$1 msg=$2 + next=$3 :> $msg + [ -f "$next" ] && merge_next_message "$status" "$next" ${VISUAL:-${EDITOR:-vi}} "$status" + [ -f "$next" ] && save_next_message "$status" "$next" grep -v '^#' < $status | git-stripspace >$msg [ -s $msg ] return $? @@ -67,8 +96,9 @@ if ! print_status > .editmsg; then exit 1 fi -if edit_message .editmsg .cmitmsg; then +if edit_message .editmsg .cmitmsg ${GIT_DIR}/.nextmsg ; then exec_commit .cmitmsg [ -f .editmsg ] && rm .editmsg [ -f .cmitmsg ] && rm .cmitmsg + [ -f ${GIT_DIR}/.nextmsg ] && rm ${GIT_DIR}/.nextmsg fi ------------ - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.htmlReceived on Wed Jun 15 17:36:42 2005
This archive was generated by hypermail 2.1.8 : 2005-06-15 17:36:43 EST