* [PATCH] make cg-commit --review restore original tree state afterwards
@ 2006-10-21 1:11 Sam Vilain
2006-10-21 9:40 ` Sam Vilain
0 siblings, 1 reply; 3+ messages in thread
From: Sam Vilain @ 2006-10-21 1:11 UTC (permalink / raw)
To: Petr Baudis; +Cc: git
If you delete hunks from the patch that 'cg-commit -p' shows you, then
they are lost 'forever'. Let's put back everything how it was
beforehand instead.
---
cg-commit | 25 +++++++++++++++++--------
1 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/cg-commit b/cg-commit
index 01a4eb7..81b3619 100755
--- a/cg-commit
+++ b/cg-commit
@@ -568,18 +568,16 @@ else
fi
rm "$LOGMSG2"
+pine_for_darcs() {
+ die "unable to revert the new 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"
+}
+
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
+ cg-patch -R < "$PATCH" || pine_for_darcs
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
+ cg-patch < "$PATCH2" || pine_for_darcs
fi
fi
@@ -625,6 +623,17 @@ if [ "$amend" ]; then
fi
treeid="$(git-write-tree ${missingok})"
+
+if [ "$review" ]; then
+ if ! cmp -s "$PATCH" "$PATCH2"; then
+ echo "Reverting the new patch..."
+ cg-patch -R < "$PATCH2" || pine_for_darcs
+ echo "Applying the old patch..."
+ cg-patch < "$PATCH" || pine_for_darcs
+ fi
+fi
+
+
[ "$treeid" ] || die "git-write-tree failed"
if [ ! "$force" ] && [ ! "$merging" ] && [ "$oldhead" ] &&
[ "$treeid" = "$(cg-object-id -t)" ]; then
--
1.4.2.g0ea2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] make cg-commit --review restore original tree state afterwards
2006-10-21 1:11 [PATCH] make cg-commit --review restore original tree state afterwards Sam Vilain
@ 2006-10-21 9:40 ` Sam Vilain
2006-10-27 2:02 ` Petr Baudis
0 siblings, 1 reply; 3+ messages in thread
From: Sam Vilain @ 2006-10-21 9:40 UTC (permalink / raw)
To: Petr Baudis; +Cc: git
Ok, I ruined the error message.
This could also do with some enhancement; if you edit hunks of the
patch, then the numbers in the hunks could be updated so as to not make
the patch abort. Also, if it does abort you should get the option of
undoing everything, or editing the patch again...
Will try again with this another time.
Sam.
Sam Vilain wrote:
> If you delete hunks from the patch that 'cg-commit -p' shows you, then
> they are lost 'forever'. Let's put back everything how it was
> beforehand instead.
> ---
> cg-commit | 25 +++++++++++++++++--------
> 1 files changed, 17 insertions(+), 8 deletions(-)
>
> diff --git a/cg-commit b/cg-commit
> index 01a4eb7..81b3619 100755
> --- a/cg-commit
> +++ b/cg-commit
> @@ -568,18 +568,16 @@ else
> fi
> rm "$LOGMSG2"
>
> +pine_for_darcs() {
> + die "unable to revert the new 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"
> +}
> +
> 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
> + cg-patch -R < "$PATCH" || pine_for_darcs
> 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
> + cg-patch < "$PATCH2" || pine_for_darcs
> fi
> fi
>
> @@ -625,6 +623,17 @@ if [ "$amend" ]; then
> fi
>
> treeid="$(git-write-tree ${missingok})"
> +
> +if [ "$review" ]; then
> + if ! cmp -s "$PATCH" "$PATCH2"; then
> + echo "Reverting the new patch..."
> + cg-patch -R < "$PATCH2" || pine_for_darcs
> + echo "Applying the old patch..."
> + cg-patch < "$PATCH" || pine_for_darcs
> + fi
> +fi
> +
> +
> [ "$treeid" ] || die "git-write-tree failed"
> if [ ! "$force" ] && [ ! "$merging" ] && [ "$oldhead" ] &&
> [ "$treeid" = "$(cg-object-id -t)" ]; then
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] make cg-commit --review restore original tree state afterwards
2006-10-21 9:40 ` Sam Vilain
@ 2006-10-27 2:02 ` Petr Baudis
0 siblings, 0 replies; 3+ messages in thread
From: Petr Baudis @ 2006-10-27 2:02 UTC (permalink / raw)
To: Sam Vilain; +Cc: git
Dear diary, on Sat, Oct 21, 2006 at 11:40:37AM CEST, I got a letter
where Sam Vilain <sam@vilain.net> said that...
> Ok, I ruined the error message.
>
> This could also do with some enhancement; if you edit hunks of the
> patch, then the numbers in the hunks could be updated so as to not make
> the patch abort. Also, if it does abort you should get the option of
> undoing everything, or editing the patch again...
>
> Will try again with this another time.
Actually, on current master you can now use internal_commit. My idea was
that you internal_commit with the local changes as X, then rollback to
HEAD, apply new patch. If you fail at this point, you can do much saner
recovery since you can reset the tree and timewarp back to X and save
the modified patch at a suitable place.
Besides, you can just timewarp the tree back to X (w/o updating HEAD) at
this point to recover the changes excluded from the committed patch!
I guess timewarping/internal_commit may look like magic to everyone but
me so if the above is unclear, just say so and I'll try to be more
thorough. :-)
--
Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
#!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj
$/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-10-27 2:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-21 1:11 [PATCH] make cg-commit --review restore original tree state afterwards Sam Vilain
2006-10-21 9:40 ` Sam Vilain
2006-10-27 2:02 ` Petr Baudis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).