git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] cg-commit --review may permanently delete changes

From
DSDennis Stosberg <dennis@stosberg.net>
Date
Jul 28, 2006, 17:11 UTC
Message-ID
<20060728171152.G3a9ef049@leonov.stosberg.net>

If the patch is changed in the editor in such a way that cg-patch can not apply it, all changes made since the last commit are irrecoverably lost, which is _really_ bad.

This patch lets cg-commit reapply the old patch and keep the edited patch for manual fix-up.

Signed-off-by: Dennis Stosberg <dennis@stosberg.net>
---
 cg-commit |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/cg-commit b/cg-commit
index 0cec58f..9604ad7 100755
--- a/cg-commit
+++ b/cg-commit
@@ -524,8 +524,11 @@ if [ "$review" ]; then
 		fi
 		echo "Applying the edited patch..."
 		if ! cg-patch < "$PATCH2"; then
-			rm "$PATCH" "$PATCH2" "$LOGMSG"
-			die "unable to apply the edited patch"
+			echo "The edited patch does not apply. Reapplying old patch."
+			cg-patch <"$PATCH" >/dev/null
+			edited_patch="$(mktemp -t edited-patch.XXXXXX)"
+			mv "$PATCH2" "$edited_patch"
+			die "You can find the edited patch in \"$edited_patch\" for manual review."
 		fi
 	fi
 fi
-- 
1.4.1
Next: Petr Baudis
Message 1 of 2 in “cg-commit --review may permanently delete changes”
  1. cg-commit --review may permanently delete changesDennis Stosberg, Jul 28, 2006
  2. Petr BaudisSep 24, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.