From: Eric Wong Date: Fri, 08 Dec 2006 10:49:28 GMT Subject: [PATCH 3/5] am and rebase resolve states get picked up by status/commit Message-ID: <11655749741136-git-send-email-normalperson@yhbt.net> In-Reply-To: <20061205092126.GE27236@soma> This should help warn of accidental commits in the middle of a rebase operation. It also saves messages in $dotest/resolvemsg and shows it in "git status" so the user can be reminded of how to continue the am or rebase operation. Signed-off-by: Eric Wong --- git-am.sh | 10 ++++++---- git-commit.sh | 28 ++++++++++++++++++++++++++++ git-rebase.sh | 35 ++++++++++++++++++++++------------- 3 files changed, 56 insertions(+), 17 deletions(-) diff --git a/git-am.sh b/git-am.sh index 28ccae3..179b967 100755 --- a/git-am.sh +++ b/git-am.sh @@ -16,7 +16,7 @@ stop_here () { stop_here_user_resolve () { if [ -n "$resolvemsg" ]; then - echo "$resolvemsg" + echo "$resolvemsg" | tee "$dotest/resolvemsg" stop_here $1 fi cmdline=$(basename $0) @@ -32,9 +32,11 @@ stop_here_user_resolve () { then cmdline="$cmdline -d=$dotest" fi - echo "When you have resolved this problem run \"$cmdline --resolved\"." - echo "If you would prefer to skip this patch, instead run \"$cmdline --skip\"." - + cat > "$dotest/resolvemsg" < "$dotest/resolvemsg" + for i in "$@" + do + echo "$i" | tee -a "$dotest/resolvemsg" >&2 + done + echo "$RESOLVEMSG" >> "$dotest/resolvemsg" + die "$RESOLVEMSG" +} + continue_merge () { test -n "$prev_head" || die "prev_head must be defined" test -d "$dotest" || die "$dotest directory does not exist" @@ -48,18 +58,17 @@ continue_merge () { unmerged=$(git-ls-files -u) if test -n "$unmerged" then - echo "You still have unmerged paths in your index" - echo "did you forget update-index?" - die "$RESOLVEMSG" + die_msg "You still have unmerged paths in your index" \ + "did you forget update-index?" fi if test -n "`git-diff-index HEAD`" then if ! git-commit -C "`cat $dotest/current`" then - echo "Commit failed, please do not call \"git commit\"" - echo "directly, but instead do one of the following: " - die "$RESOLVEMSG" + die_msg \ + "Commit failed, please do not call \"git commit\"" \ + "directly, but instead do one of the following: " fi printf "Committed: %0${prec}d" $msgnum else @@ -73,6 +82,7 @@ continue_merge () { echo "$prev_head" > "$dotest/prev_head" # onto the next patch: + rm -f "$dotest/resolvemsg" msgnum=$(($msgnum + 1)) echo "$msgnum" >"$dotest/msgnum" } @@ -88,14 +98,13 @@ call_merge () { ;; 1) test -d "$GIT_DIR/rr-cache" && git-rerere - die "$RESOLVEMSG" + die_msg ;; 2) - echo "Strategy: $rv $strategy failed, try another" 1>&2 - die "$RESOLVEMSG" + die_msg "Strategy: $rv $strategy failed, try another" ;; *) - die "Unknown exit code ($rv) from command:" \ + die_msg "Unknown exit code ($rv) from command:" \ "git-merge-$strategy $cmt^ -- HEAD $cmt" ;; esac @@ -112,9 +121,8 @@ do --continue) diff=$(git-diff-files) case "$diff" in - ?*) echo "You must edit all merge conflicts and then" - echo "mark them as resolved using git update-index" - exit 1 + ?*) die_msg "You must edit all merge conflicts and then" \ + "mark them as resolved using git update-index" ;; esac if test -d "$dotest" @@ -143,6 +151,7 @@ do then git-rerere clear fi + rm -f "$dotest/resolvemsg" prev_head="`cat $dotest/prev_head`" end="`cat $dotest/end`" msgnum="`cat $dotest/msgnum`" -- 1.4.4.2.g860f4