{"thread":{"id":"457","subject":"[PATCH] cogito: Add cg-undo command","startedAt":"2005-05-03T17:06:25Z","lastAt":"2005-05-08T20:59:27Z","messageCount":4,"participants":["Matt Porter","Petr Baudis"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"2486","messageId":"20050503100624.A29266@cox.net","threadId":"457","inReplyTo":null,"subject":"[PATCH] cogito: Add cg-undo command","fromName":"Matt Porter","fromEmail":"mporter@kernel.crashing.org","sentAt":"2005-05-03T17:06:25Z","receivedAt":"2005-05-03T17:06:25Z","isPatch":true,"sender":{"key":"mporter@kernel.crashing.org","avatar":null},"body":"Adds a cg-undo command which takes a commit ID and resets HEAD\nto the parent of the commit ID...refreshing the tree. This undoes\na single commit or a series of commits.\n\nSigned-off-by: Matt Porter <mporter@kernel.crashing.org>\n\n--- a1aff2a6748c0c0d08058c7d74503e724abc5d03/Makefile  (mode:100644 sha1:6ae0afa0208a8f755d383281a6d049a4ef90fe63)\n+++ 023d9a7929d2f933d8e008f1679f13a58f7b1229/Makefile  (mode:100644 sha1:6c282aeebe86ecee9e634481b3d51fd53a582791)\n@@ -47,7 +47,7 @@\n \tcg-add cg-admin-lsobj cg-cancel cg-clone cg-commit cg-diff \\\n \tcg-export cg-help cg-init cg-log cg-ls cg-merge cg-mkpatch \\\n \tcg-patch cg-pull cg-branch-add cg-branch-ls cg-rm cg-seek cg-status \\\n-\tcg-tag cg-tag-ls cg-update cg-Xlib\n+\tcg-tag cg-tag-ls cg-undo cg-update cg-Xlib\n \n COMMON=\tread-cache.o\n \nIndex: cg-help\n===================================================================\n--- a1aff2a6748c0c0d08058c7d74503e724abc5d03/cg-help  (mode:100755 sha1:1f5d2d79b67490d44ce0f575ff9a4b80134ea47f)\n+++ 023d9a7929d2f933d8e008f1679f13a58f7b1229/cg-help  (mode:100755 sha1:c7dc8f3e03895374cd0dae544570a37a459c2466)\n@@ -43,6 +43,7 @@\n \tcg-status\n \tcg-tag\t\tTNAME [COMMIT_ID]\n \tcg-tag-ls\n+\tcg-undo\t\t[COMMIT_ID]\n \tcg-update\t[BNAME]\n \tcg-version\n \nIndex: cg-undo\n===================================================================\n--- /dev/null  (tree:a1aff2a6748c0c0d08058c7d74503e724abc5d03)\n+++ 023d9a7929d2f933d8e008f1679f13a58f7b1229/cg-undo  (mode:100755 sha1:7fd6d89158fb5aeee42aa05a93f2c81884d9bd34)\n@@ -0,0 +1,20 @@\n+#!/usr/bin/env bash\n+#\n+# Undo a commit or a series of commits\n+# Copyright (C) Matt Porter, 2005\n+#\n+# Takes a commit ID which is the earliest commit to be\n+# removed from the repository.\n+\n+. cg-Xlib\n+\n+PARENT=`git-cat-file commit $1 | grep parent | cut -f 2 -d \" \"`\n+echo \"Undo from $1 to current HEAD\"\n+echo \"Reset HEAD to $PARENT\"\n+echo \"$PARENT\" > .git/HEAD\n+git-read-tree -m \"$PARENT\" || {\n+\techo >&2 \"$PARENT: bad commit\"\n+\texit 1\n+}\n+git-checkout-cache -f -a\n+git-update-cache --refresh\n"},{"id":"2527","messageId":"20050503213204.GC15995@pasky.ji.cz","threadId":"457","inReplyTo":"20050503100624.A29266@cox.net","subject":"Re: [PATCH] cogito: Add cg-undo command","fromName":"Petr Baudis","fromEmail":"pasky@ucw.cz","sentAt":"2005-05-03T21:32:04Z","receivedAt":"2005-05-03T21:32:04Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Tue, May 03, 2005 at 07:06:25PM CEST, I got a letter\nwhere Matt Porter <mporter@kernel.crashing.org> told me that...\n> Index: cg-help\n> ===================================================================\n> --- a1aff2a6748c0c0d08058c7d74503e724abc5d03/cg-help  (mode:100755 sha1:1f5d2d79b67490d44ce0f575ff9a4b80134ea47f)\n> +++ 023d9a7929d2f933d8e008f1679f13a58f7b1229/cg-help  (mode:100755 sha1:c7dc8f3e03895374cd0dae544570a37a459c2466)\n> @@ -43,6 +43,7 @@\n>  \tcg-status\n>  \tcg-tag\t\tTNAME [COMMIT_ID]\n>  \tcg-tag-ls\n> +\tcg-undo\t\t[COMMIT_ID]\n\nIt doesn't seem very optional now.\n\n>  \tcg-update\t[BNAME]\n>  \tcg-version\n>  \n> Index: cg-undo\n> ===================================================================\n> --- /dev/null  (tree:a1aff2a6748c0c0d08058c7d74503e724abc5d03)\n> +++ 023d9a7929d2f933d8e008f1679f13a58f7b1229/cg-undo  (mode:100755 sha1:7fd6d89158fb5aeee42aa05a93f2c81884d9bd34)\n> @@ -0,0 +1,20 @@\n> +#!/usr/bin/env bash\n> +#\n> +# Undo a commit or a series of commits\n> +# Copyright (C) Matt Porter, 2005\n> +#\n> +# Takes a commit ID which is the earliest commit to be\n> +# removed from the repository.\n> +\n> +. cg-Xlib\n> +\n> +PARENT=`git-cat-file commit $1 | grep parent | cut -f 2 -d \" \"`\n\nWhat's wrong with parent-id?\n\n> +echo \"Undo from $1 to current HEAD\"\n> +echo \"Reset HEAD to $PARENT\"\n\nYou talk way too much, I think. I'd just do\n\n\techo \"Rewinding $HEAD -> $PARENT\" >&2\n\n> +echo \"$PARENT\" > .git/HEAD\n> +git-read-tree -m \"$PARENT\" || {\n> +\techo >&2 \"$PARENT: bad commit\"\n> +\texit 1\n> +}\n> +git-checkout-cache -f -a\n> +git-update-cache --refresh\n\nYou really don't want to do this if the tree has any local\nmodifications.\n\n\nPlease make sure the commit you are rewinding to is an ancestor of your\ncurrent HEAD (there should be something like separate cg-branch-rm for\nkilling enemy branches).\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nC++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor\n"},{"id":"2560","messageId":"20050503224007.B637@cox.net","threadId":"457","inReplyTo":"20050503213204.GC15995@pasky.ji.cz","subject":"Re: [PATCH] cogito: Add cg-undo command","fromName":"Matt Porter","fromEmail":"mporter@kernel.crashing.org","sentAt":"2005-05-04T05:40:07Z","receivedAt":"2005-05-04T05:40:07Z","isPatch":true,"sender":{"key":"mporter@kernel.crashing.org","avatar":null},"body":"On Tue, May 03, 2005 at 11:32:04PM +0200, Petr Baudis wrote:\n> Dear diary, on Tue, May 03, 2005 at 07:06:25PM CEST, I got a letter\n> where Matt Porter <mporter@kernel.crashing.org> told me that...\n> > +\tcg-undo\t\t[COMMIT_ID]\n> \n> It doesn't seem very optional now.\n\nYep, changed.\n\n> > +PARENT=`git-cat-file commit $1 | grep parent | cut -f 2 -d \" \"`\n>\n> What's wrong with parent-id?\n\nMissed it...changed to use parent-id.\n\n> > +echo \"Undo from $1 to current HEAD\"\n> > +echo \"Reset HEAD to $PARENT\"\n> \n> You talk way too much, I think. I'd just do\n> \n> \techo \"Rewinding $HEAD -> $PARENT\" >&2\n\nDone.\n\n> > +git-update-cache --refresh\n> \n> You really don't want to do this if the tree has any local\n> modifications.\n\nUgh, yes. I added a check for this. \n\n> Please make sure the commit you are rewinding to is an ancestor of your\n> current HEAD (there should be something like separate cg-branch-rm for\n> killing enemy branches).\n\nAdded a check for this as well as verifying we have an argument.\n \nSigned-off-by: Matt Porter <mporter@kernel.crashing.org>\n\n--- aa6233be6d1b8bf42797c409a7c23b50593afc99/Makefile  (mode:100644 sha1:6ae0afa0208a8f755d383281a6d049a4ef90fe63)\n+++ ce72371d991b15a0ca8db7c2332d215b59b909af/Makefile  (mode:100644 sha1:6c282aeebe86ecee9e634481b3d51fd53a582791)\n@@ -47,7 +47,7 @@\n \tcg-add cg-admin-lsobj cg-cancel cg-clone cg-commit cg-diff \\\n \tcg-export cg-help cg-init cg-log cg-ls cg-merge cg-mkpatch \\\n \tcg-patch cg-pull cg-branch-add cg-branch-ls cg-rm cg-seek cg-status \\\n-\tcg-tag cg-tag-ls cg-update cg-Xlib\n+\tcg-tag cg-tag-ls cg-undo cg-update cg-Xlib\n \n COMMON=\tread-cache.o\n \nIndex: cg-help\n===================================================================\n--- aa6233be6d1b8bf42797c409a7c23b50593afc99/cg-help  (mode:100755 sha1:1f5d2d79b67490d44ce0f575ff9a4b80134ea47f)\n+++ ce72371d991b15a0ca8db7c2332d215b59b909af/cg-help  (mode:100755 sha1:1b75114ee90d2b3b9786fc4f14bf179feef54f87)\n@@ -43,6 +43,7 @@\n \tcg-status\n \tcg-tag\t\tTNAME [COMMIT_ID]\n \tcg-tag-ls\n+\tcg-undo\t\tCOMMIT_ID\n \tcg-update\t[BNAME]\n \tcg-version\n \nIndex: cg-undo\n===================================================================\n--- /dev/null  (tree:aa6233be6d1b8bf42797c409a7c23b50593afc99)\n+++ ce72371d991b15a0ca8db7c2332d215b59b909af/cg-undo  (mode:100644 sha1:7b1cb04c79731b137d88ebd05ee41553af7246d2)\n@@ -0,0 +1,32 @@\n+#!/usr/bin/env bash\n+#\n+# Undo a commit or a series of commits\n+# Copyright (C) Matt Porter, 2005\n+#\n+# Takes a commit ID which is the earliest commit to be\n+# removed from the repository.\n+\n+. cg-Xlib\n+\n+[ \"$1\" ] || die \"usage: cg-undo COMMIT_ID\"\n+\n+HEAD=$(commit-id) || exit 1;\n+PARENT=$(parent-id \"$1\") || exit 1;\n+\n+git-rev-list $HEAD | grep -q $1 || {\n+\techo >&2 \"$1: not an ancestor of HEAD\"\n+\texit 1\n+}\n+[ \"$(git-diff-files -s)\" ] && git-update-cache --refresh\n+if [ \"$(git-diff-files -s)\" ] || [ \"$(git-diff-cache $(tree-id))\" ]; then\n+        die \"Undo blocked: local changes\"\n+fi\n+\n+echo \"Rewinding HEAD -> $PARENT\" >&2\n+echo \"$PARENT\" > .git/HEAD\n+git-read-tree -m \"$PARENT\" || {\n+\techo >&2 \"$PARENT: bad commit\"\n+\texit 1\n+}\n+git-checkout-cache -f -a\n+git-update-cache --refresh\n"},{"id":"2821","messageId":"20050508205927.GK9495@pasky.ji.cz","threadId":"457","inReplyTo":"20050503224007.B637@cox.net","subject":"Re: [PATCH] cogito: Add cg-undo command","fromName":"Petr Baudis","fromEmail":"pasky@ucw.cz","sentAt":"2005-05-08T20:59:27Z","receivedAt":"2005-05-08T20:59:27Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Wed, May 04, 2005 at 07:40:07AM CEST, I got a letter\nwhere Matt Porter <mporter@kernel.crashing.org> told me that...\n> Signed-off-by: Matt Porter <mporter@kernel.crashing.org>\n\nThanks. I took it, hacked upon it for a while and then committed\nsomething similar but largely rewritten as cg-admin-uncommit. ;-)\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nC++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor\n"}]}