From: Jan Nieuwenhuizen <janneke-list@xs4all.nl>
To: git <git@vger.kernel.org>
Cc: Jan Holesovsky <kendy@suse.cz>
Subject: [TopGit PATCH] tg-undepend.sh: new command to remove a dependency.
Date: Wed, 13 Aug 2008 16:20:52 +0200 [thread overview]
Message-ID: <1218637253.7561.25.camel@heerbeest> (raw)
Here's a stab at removing a dependency from a topgit branch.
This is something we think we need for ooo-build to switch to git.
Signed-off-by: Jan Nieuwenhuizen <janneke@gnu.org>
---
Makefile | 2 +-
README | 5 ++++
tg-undepend.sh | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 63 insertions(+), 1 deletions(-)
create mode 100755 tg-undepend.sh
diff --git a/Makefile b/Makefile
index af46399..d40e509 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@ sharedir = $(prefix)/share/topgit
hooksdir = $(cmddir)/hooks
-commands_in = tg-create.sh tg-delete.sh tg-export.sh tg-info.sh tg-patch.sh tg-summary.sh tg-update.sh
+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
hooks_in = hooks/pre-commit.sh
commands_out = $(patsubst %.sh,%,$(commands_in))
diff --git a/README b/README
index b58a1b4..096b9ec 100644
--- a/README
+++ b/README
@@ -330,6 +330,11 @@ tg export
TODO: Make stripping of [PATCH] and other prefixes configurable
TODO: --mbox option for other mode of operation
+tg undepend
+~~~~~~~~~~~
+ Update the current topic branch by removing the given
+ branch (required argument) from the list of dependencies.
+
tg update
~~~~~~~~~
Update the current topic branch wrt. changes in the branches
diff --git a/tg-undepend.sh b/tg-undepend.sh
new file mode 100755
index 0000000..d4c0143
--- /dev/null
+++ b/tg-undepend.sh
@@ -0,0 +1,57 @@
+#! /bin/sh
+# TopGit - A different patch queue manager
+# (c) Petr Baudis <pasky@suse.cz> 2008
+# (c) 2008 Jan Nieuwenhuizen <janneke@gnu.org>
+# GNU GPL version 2
+
+name=
+
+
+## Parse options
+
+while [ -n "$1" ]; do
+ arg="$1"; shift
+ case "$arg" in
+ -*)
+ echo "Usage: tg undepend [NAME]" >&2
+ exit 2;;
+ *)
+ [ -z "$name" ] || die "name already specified ($name)"
+ name="$arg";;
+ esac
+done
+
+[ -n "$name" ] || name="$(git symbolic-ref HEAD | sed 's#^refs/heads/##')"
+base_rev="$(git rev-parse --short --verify "refs/top-bases/$name" 2>/dev/null)" \
+ || die "not a TopGit-controlled branch"
+
+this_branch=$(git symbolic-ref HEAD | cut -b 12-)
+
+# Use a detached head so that this operation can be aborted
+git checkout -q $(git rev-parse HEAD)
+
+unmerge=$(git log --pretty=oneline "$base_rev".."$name" | cut -b -40 | tr '\n' ' ')
+while [ -n "$unmerge" ]; do
+ commit="${unmerge%% *}"
+ unmerge="${unmerge#* }"
+ [ -n "$unmerge" ] || break # skip initial .top* commit
+ if ! git revert --no-edit $commit; then
+ info "Please commit merge resolution and call: tg undepend $name"
+ info "It is also safe to abort this operation using:"
+ info "git reset --hard some_branch"
+ info "(You are on a detached HEAD now.)"
+ exit 1
+ fi
+done
+
+git branch -m $this_branch work/$this_branch.save-undepend
+git checkout -q -b work/$this_branch.undepend
+git branch -m work/$this_branch.undepend $this_branch
+git branch -D work/$this_branch.save-undepend
+
+mv .topdeps .topdeps~ && grep -v "^$name\$" .topdeps~ > .topdeps && rm .topdeps~
+git commit -am "Remove dependency on $name."
+
+# Local Variables:
+# sh-basic-offset:8
+# End:
--
1.6.0.rc0.44.g67270
--
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond - The music typesetter
http://www.xs4all.nl/~jantien | http://www.lilypond.org
reply other threads:[~2008-08-13 14:22 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1218637253.7561.25.camel@heerbeest \
--to=janneke-list@xs4all.nl \
--cc=git@vger.kernel.org \
--cc=kendy@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).