{"thread":{"id":"14980","subject":"[TopGit PATCH] tg-undepend.sh: new command to remove a dependency.","startedAt":"2008-08-13T14:20:52Z","lastAt":"2008-08-13T14:20:52Z","messageCount":1,"participants":["Jan Nieuwenhuizen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"87049","messageId":"1218637253.7561.25.camel@heerbeest","threadId":"14980","inReplyTo":null,"subject":"[TopGit PATCH] tg-undepend.sh: new command to remove a dependency.","fromName":"Jan Nieuwenhuizen","fromEmail":"janneke-list@xs4all.nl","sentAt":"2008-08-13T14:20:52Z","receivedAt":"2008-08-13T14:20:52Z","isPatch":true,"sender":{"key":"janneke-list@xs4all.nl","avatar":null},"body":"Here's a stab at removing a dependency from a topgit branch.\n\nThis is something we think we need for ooo-build to switch to git.\n\nSigned-off-by: Jan Nieuwenhuizen <janneke@gnu.org>\n---\n Makefile       |    2 +-\n README         |    5 ++++\n tg-undepend.sh |   57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 63 insertions(+), 1 deletions(-)\n create mode 100755 tg-undepend.sh\n\ndiff --git a/Makefile b/Makefile\nindex af46399..d40e509 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -5,7 +5,7 @@ sharedir = $(prefix)/share/topgit\n hooksdir = $(cmddir)/hooks\n \n \n-commands_in = tg-create.sh tg-delete.sh tg-export.sh tg-info.sh tg-patch.sh tg-summary.sh tg-update.sh\n+commands_in = tg-create.sh tg-delete.sh tg-export.sh tg-info.sh tg-patch.sh tg-summary.sh tg-undepend.sh tg-update.sh\n hooks_in = hooks/pre-commit.sh\n \n commands_out = $(patsubst %.sh,%,$(commands_in))\ndiff --git a/README b/README\nindex b58a1b4..096b9ec 100644\n--- a/README\n+++ b/README\n@@ -330,6 +330,11 @@ tg export\n \tTODO: Make stripping of [PATCH] and other prefixes configurable\n \tTODO: --mbox option for other mode of operation\n \n+tg undepend\n+~~~~~~~~~~~\n+\tUpdate the current topic branch by removing the given\n+\tbranch (required argument) from the list of dependencies.\n+\n tg update\n ~~~~~~~~~\n \tUpdate the current topic branch wrt. changes in the branches\ndiff --git a/tg-undepend.sh b/tg-undepend.sh\nnew file mode 100755\nindex 0000000..d4c0143\n--- /dev/null\n+++ b/tg-undepend.sh\n@@ -0,0 +1,57 @@\n+#! /bin/sh\n+# TopGit - A different patch queue manager\n+# (c) Petr Baudis <pasky@suse.cz>  2008\n+# (c) 2008  Jan Nieuwenhuizen <janneke@gnu.org>\n+# GNU GPL version 2\n+\n+name=\n+\n+\n+## Parse options\n+\n+while [ -n \"$1\" ]; do\n+\targ=\"$1\"; shift\n+\tcase \"$arg\" in\n+\t-*)\n+\t\techo \"Usage: tg undepend [NAME]\" >&2\n+\t\texit 2;;\n+\t*)\n+\t\t[ -z \"$name\" ] || die \"name already specified ($name)\"\n+\t\tname=\"$arg\";;\n+\tesac\n+done\n+\n+[ -n \"$name\" ] || name=\"$(git symbolic-ref HEAD | sed 's#^refs/heads/##')\"\n+base_rev=\"$(git rev-parse --short --verify \"refs/top-bases/$name\" 2>/dev/null)\" \\\n+\t|| die \"not a TopGit-controlled branch\"\n+\t\n+this_branch=$(git symbolic-ref HEAD | cut -b 12-)\n+\n+# Use a detached head so that this operation can be aborted\n+git checkout -q $(git rev-parse HEAD)\n+\n+unmerge=$(git log --pretty=oneline \"$base_rev\"..\"$name\" | cut -b -40 | tr '\\n' ' ')\n+while [ -n \"$unmerge\" ]; do\n+\tcommit=\"${unmerge%% *}\"\n+\tunmerge=\"${unmerge#* }\"\n+\t[ -n \"$unmerge\" ] || break # skip initial .top* commit\n+\tif ! git revert --no-edit $commit; then\n+\t\tinfo \"Please commit merge resolution and call: tg undepend $name\"\n+\t\tinfo \"It is also safe to abort this operation using:\"\n+\t\tinfo \"git reset --hard some_branch\"\n+\t\tinfo \"(You are on a detached HEAD now.)\"\n+\t\texit 1\n+\tfi\n+done\n+\n+git branch -m $this_branch work/$this_branch.save-undepend\n+git checkout -q -b work/$this_branch.undepend\n+git branch -m work/$this_branch.undepend $this_branch\n+git branch -D work/$this_branch.save-undepend\n+\n+mv .topdeps .topdeps~ && grep -v \"^$name\\$\" .topdeps~ > .topdeps && rm .topdeps~\n+git commit -am \"Remove dependency on $name.\"\n+\n+# Local Variables:\n+# sh-basic-offset:8\n+# End:\n-- \n1.6.0.rc0.44.g67270\n\n\n-- \nJan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond - The music typesetter\nhttp://www.xs4all.nl/~jantien       | http://www.lilypond.org\n"}]}