From: Jan Nieuwenhuizen <janneke-list@xs4all.nl>
To: git <git@vger.kernel.org>
Cc: Jan Holesovsky <kendy@suse.cz>
Subject: [TopGit PATCH] tg-create.sh: Introduce --add option to add a dependency.
Date: Wed, 13 Aug 2008 16:25:14 +0200 [thread overview]
Message-ID: <1218637514.7561.30.camel@heerbeest> (raw)
This implements
tg create --add DEP
to add dependency DEP to an already existing topgit branch.
The bad thing is that this does not play well with tg undepend;
it won't work to re-add a previously removed dependency. This
--add is implemented as a merge, and all merge commits are
already present; it is only that lateron they are reverted.
Any ideas on how to fix that?
Signed-off-by: Jan Nieuwenhuizen <janneke@gnu.org>
---
README | 6 +++++-
tg-create.sh | 44 ++++++++++++++++++++++++++++++++++++--------
2 files changed, 41 insertions(+), 9 deletions(-)
diff --git a/README b/README
index 096b9ec..a9957f2 100644
--- a/README
+++ b/README
@@ -215,6 +215,9 @@ tg create
it will detect that you are on a topic branch base ref and
resume the topic branch creation operation.
+ With the --add option, all given arguments are added as
+ dependencies to current topic branch.
+
tg delete
~~~~~~~~~
Remove a TopGit-controlled topic branch of given name
@@ -333,7 +336,8 @@ tg export
tg undepend
~~~~~~~~~~~
Update the current topic branch by removing the given
- branch (required argument) from the list of dependencies.
+ branch (required argument) from the list of dependencies
+ and reverting all its commits.
tg update
~~~~~~~~~
diff --git a/tg-create.sh b/tg-create.sh
index 939af33..c5bc5fb 100644
--- a/tg-create.sh
+++ b/tg-create.sh
@@ -3,9 +3,11 @@
# (c) Petr Baudis <pasky@suse.cz> 2008
# GPLv2
+add= # Set to 1 when adding dependencies to existing topgit branch
deps= # List of dependent branches
restarted= # Set to 1 if we are picking up in the middle of base setup
merge= # List of branches to be merged; subset of $deps
+merged= # List branches actually merged
name=
@@ -14,8 +16,12 @@ name=
while [ -n "$1" ]; do
arg="$1"; shift
case "$arg" in
+ --add)
+ add=1
+ name=$(git symbolic-ref HEAD | cut -b 12-)
+ ;;
-*)
- echo "Usage: tg create NAME [DEPS...]" >&2
+ echo "Usage: tg create --add|NAME [DEPENDENCY]..." >&2
exit 1;;
*)
if [ -z "$name" ]; then
@@ -50,12 +56,22 @@ fi
[ -n "$merge" -o -n "$restarted" ] || merge="$deps "
+if [ -z "$add" ]; then
+ ! git rev-parse --verify "$name" >/dev/null 2>&1 \
+ || die "branch '$name' already exists"
+else
+ dupes=$(grep -E "^${merge// /|}/\$" .topdeps | tr '\n' ' ')
+ [ -z "$dupes" ] || die "already depend on: $dupes"
+ deps=$(echo "$merge" | cat .topdeps - | tr '\n' ' ' | sed -e 's/ \+$//')
+ merged="$merge"
+ merge="$name $merge"
+fi
+
+
for d in $deps; do
git rev-parse --verify "$d" >/dev/null 2>&1 ||
die "unknown branch dependency '$d'"
done
-! git rev-parse --verify "$name" >/dev/null 2>&1 ||
- die "branch '$name' already exists"
# Clean up any stale stuff
rm -f "$git_dir/top-name" "$git_dir/top-deps" "$git_dir/top-merge"
@@ -96,7 +112,13 @@ done
## Set up the topic branch
-git update-ref "refs/top-bases/$name" "HEAD" ""
+if [ -z "$add" ]; then
+ git update-ref "refs/top-bases/$name" "HEAD" ""
+else
+ #[ -n "$add" ] && git -D "$name"
+ git branch -D save/"$name" || :
+ git branch -m "$name" save/$name
+fi
git checkout -b "$name"
echo "$deps" | sed 's/ /\n/g' >"$root_dir/.topdeps"
@@ -104,7 +126,7 @@ git add "$root_dir/.topdeps"
author="$(git var GIT_AUTHOR_IDENT)"
author_addr="${author%> *}>"
-{
+[ -z "$add" ] && {
echo "From: $author_addr"
! header="$(git config topgit.to)" || echo "To: $header"
! header="$(git config topgit.cc)" || echo "Cc: $header"
@@ -120,7 +142,13 @@ EOT
} >"$root_dir/.topmsg"
git add "$root_dir/.topmsg"
+if [ -z "$add" ]; then
+ info "Topic branch $name set up. Please fill .topmsg now and make initial commit."
+ info "To abort: git rm -f .top* && git checkout ${deps%% *} && tg delete $name"
+else
+ git commit -am "Add dependency: $merged"
+fi
-
-info "Topic branch $name set up. Please fill .topmsg now and make initial commit."
-info "To abort: git rm -f .top* && git checkout ${deps%% *} && tg delete $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
next reply other threads:[~2008-08-13 14:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-13 14:25 Jan Nieuwenhuizen [this message]
2008-08-13 16:20 ` [TopGit PATCH] tg-create.sh: Introduce --add option to add a dependency Jonathan Nieder
2008-08-15 8:10 ` Jan Nieuwenhuizen
2008-08-15 15:25 ` Jonathan Nieder
2008-08-18 9:18 ` Jan Nieuwenhuizen
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=1218637514.7561.30.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