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

[PATCH] cogito: Add cg-undo command

From
MPMatt Porter <mporter@kernel.crashing.org>
Date
May 3, 2005, 17:06 UTC
Message-ID
<20050503100624.A29266@cox.net>

Adds a cg-undo command which takes a commit ID and resets HEAD to the parent of the commit ID...refreshing the tree. This undoes a single commit or a series of commits.

Signed-off-by: Matt Porter <mporter@kernel.crashing.org>

--- a1aff2a6748c0c0d08058c7d74503e724abc5d03/Makefile (mode:100644 sha1:6ae0afa0208a8f755d383281a6d049a4ef90fe63) +++ 023d9a7929d2f933d8e008f1679f13a58f7b1229/Makefile (mode:100644 sha1:6c282aeebe86ecee9e634481b3d51fd53a582791)

@@ -47,7 +47,7 @@
 	cg-add cg-admin-lsobj cg-cancel cg-clone cg-commit cg-diff \
 	cg-export cg-help cg-init cg-log cg-ls cg-merge cg-mkpatch \
 	cg-patch cg-pull cg-branch-add cg-branch-ls cg-rm cg-seek cg-status \
-	cg-tag cg-tag-ls cg-update cg-Xlib
+	cg-tag cg-tag-ls cg-undo cg-update cg-Xlib
 
 COMMON=	read-cache.o
 
Index: cg-help
===================================================================
--- a1aff2a6748c0c0d08058c7d74503e724abc5d03/cg-help  (mode:100755 sha1:1f5d2d79b67490d44ce0f575ff9a4b80134ea47f)
+++ 023d9a7929d2f933d8e008f1679f13a58f7b1229/cg-help  (mode:100755 sha1:c7dc8f3e03895374cd0dae544570a37a459c2466)
@@ -43,6 +43,7 @@
 	cg-status
 	cg-tag		TNAME [COMMIT_ID]
 	cg-tag-ls
+	cg-undo		[COMMIT_ID]
 	cg-update	[BNAME]
 	cg-version
 
Index: cg-undo
===================================================================
--- /dev/null  (tree:a1aff2a6748c0c0d08058c7d74503e724abc5d03)
+++ 023d9a7929d2f933d8e008f1679f13a58f7b1229/cg-undo  (mode:100755 sha1:7fd6d89158fb5aeee42aa05a93f2c81884d9bd34)
@@ -0,0 +1,20 @@
+#!/usr/bin/env bash
+#
+# Undo a commit or a series of commits
+# Copyright (C) Matt Porter, 2005
+#
+# Takes a commit ID which is the earliest commit to be
+# removed from the repository.
+
+. cg-Xlib
+
+PARENT=`git-cat-file commit $1 | grep parent | cut -f 2 -d " "`
+echo "Undo from $1 to current HEAD"
+echo "Reset HEAD to $PARENT"
+echo "$PARENT" > .git/HEAD
+git-read-tree -m "$PARENT" || {
+	echo >&2 "$PARENT: bad commit"
+	exit 1
+}
+git-checkout-cache -f -a
+git-update-cache --refresh
Next: Petr Baudis
Message 1 of 4 in “cogito: Add cg-undo command”
  1. cogito: Add cg-undo commandMatt Porter, May 3, 2005
  2. Petr BaudisMay 3, 2005
  3. Matt PorterMay 4, 2005
  4. Petr BaudisMay 8, 2005

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.