All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sam Vilain <sam.vilain@catalyst.net.nz>
To: Petr Baudis <pasky@suse.cz>
Cc: git@vger.kernel.org
Subject: [PATCH] Fix cg-commit -p to not touch the working tree
Date: Mon, 12 Feb 2007 16:14:31 +1300	[thread overview]
Message-ID: <20070212031923.D20B913A382@magnus.utsl.gen.nz> (raw)

Previously, the working tree state was modified with `patch', which
was a fragile operation.  Do everything with `git-apply --cached
--index' instead.
---
 cg-commit |   33 +++++++++++++++++----------------
 1 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/cg-commit b/cg-commit
index 360d5e6..f676e1f 100755
--- a/cg-commit
+++ b/cg-commit
@@ -575,22 +575,6 @@ else
 fi
 rm "$LOGMSG2"
 
-if [ "$review" ]; then
-	if ! cmp -s "$PATCH" "$PATCH2"; then
-		echo "Reverting the original patch..."
-		if ! cg-patch -R < "$PATCH"; then
-			die "unable to revert the original patch; the original patch is available in $PATCH, your edited patch is available in $PATCH2, your log message is in $LOGMSG, your working copy is in undefined state now and the world is about to end in ten minutes, have a nice day"
-		fi
-		echo "Applying the edited patch..."
-		if ! cg-patch < "$PATCH2"; then
-			# FIXME: Do something better to alleviate this situation.
-			# At least restore the tree to the original state.
-			die "unable to apply the edited patch; the original patch is available in $PATCH, your edited patch is available in $PATCH2, your log message is in $LOGMSG, your working copy is in undefined state now and the world is about to end in five minutes, have a nice day"
-		fi
-	fi
-fi
-
-
 precommit_update()
 {
 	queueN=(); queueD=(); queueM=();
@@ -620,6 +604,23 @@ if [ ! "$ignorecache" ]; then
 	precommit_update "${commitfiles[@]}" || die "update-cache failed"
 fi
 
+if [ "$review" ]; then
+	if ! cmp -s "$PATCH" "$PATCH2"; then
+		git-read-tree HEAD
+		while ! git-apply --check --cached --index "$PATCH2"
+		do
+			echo "patch tried was:"
+			cat $PATCH2
+			echo "your patch does not apply cleanly, re-edit it!"
+			echo -n "sleeping 5s..."
+			sleep 4
+			echo "get it right this time OK?"
+			sleep 1
+			${EDITOR:-vi} "$PATCH2"
+		done
+		git-apply --cached --index "$PATCH2"
+	fi
+fi
 
 oldhead=
 oldheadname="$(git-symbolic-ref HEAD)"
-- 
1.5.0.rc2.g84cf66-dirty

             reply	other threads:[~2007-02-12  3:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-12  3:14 Sam Vilain [this message]
2007-02-12  4:25 ` Junio C Hamano
2007-02-12 20:22   ` Sam Vilain
2007-02-12 22:01     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070212031923.D20B913A382@magnus.utsl.gen.nz \
    --to=sam.vilain@catalyst.net.nz \
    --cc=git@vger.kernel.org \
    --cc=pasky@suse.cz \
    --subject='Re: [PATCH] Fix cg-commit -p to not touch the working tree' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.