tg redepend: New command.
PATCH 1/1 tg redepend: New command.
As discussed previously
http://kerneltrap.org/mailarchive/git/2008/8/13/2925144
Change a topgit branch's dependencies by doing a rebase-by-merge.
--- Makefile | 2 +- README | 5 ++ tg-redepend.sh | 154 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 160 insertions(+), 1 deletions(-) create mode 100644 tg-redepend.sh
Makefile +1 -1
@@ -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-redepend.sh tg-summary.sh tg-update.sh hooks_in = hooks/pre-commit.sh commands_out = $(patsubst %.sh,%,$(commands_in))
README +5 -0
@@ -330,6 +330,11 @@ tg export TODO: Make stripping of [PATCH] and other prefixes configurable TODO: --mbox option for other mode of operation +tg redepend +~~~~~~~~~~~ + Change the current topic branch's list of dependencies + by doing a rebase-by-merge onto the new dependencies. + tg update ~~~~~~~~~ Update the current topic branch wrt. changes in the branches
tg-redepend.sh new file +154 -0
154 lines not on this page · raw message
Signature · 6 lines
1.6.0.rc0.44.g67270 -- Jan Nieuwenhuizen <[email protected]> | GNU LilyPond - The music typesetter http://www.xs4all.nl/~jantien | http://www.lilypond.org
On Fri, Aug 15, 2008 at 15:53, Jan Nieuwenhuizen <[email protected]> wrote:
Why don't you call this command 'depend', as per README TODO?
tg-redepend.sh line 154
Quoted 4 lines
tg-redepend.sh new file +4
-0+ +# Local Variables: +# sh-basic-offset:8 +# End:
This would be the first file in this project with such editor infos. IMHO this shouldn't belong to a patch.
Regards
Bert
Hi,
Quoted 13 lines · Jan Nieuwenhuizen
As discussed previously
http://kerneltrap.org/mailarchive/git/2008/8/13/2925144Change a topgit branch's dependencies by doing a rebase-by-merge.
Signed-off-by Jan Nieuwenhuizen <[email protected]>--- Makefile | 2 +- README | 5 ++ tg-redepend.sh | 154 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 160 insertions(+), 1 deletions(-) create mode 100644 tg-redepend.sh
[...]
Review
Quoted 2 lines
(quoted diff) +2
-0+ -h|--help) + echo "Usage: tg [--add|--remove] DEPENDENCY..." >&2
s/tg/tg redepend/?
[...]
tg-redepend.sh line 105
Quoted 5 lines
tg-redepend.sh new file +5
-0+# Create new base B' -- does not have to be a topgit branch, but that's easiest +if [ -z "$restarted" ]; then + git branch -D $p_ > /dev/null 2>&1 || : + + tg create $b_ $redeps
Why not move the base-creation code in tg-create.sh to a new function in tg.sh to use here?
[...]
tg-redepend.sh line 129
Quoted 6 lines
tg-redepend.sh new file +6
-0+if [ "$restarted" != "merge" ]; then + git checkout $(git rev-parse $p) + if ! git merge --no-ff --no-commit $b_; then + touch "$git_dir/top-merge" + fail merge + fi
[snip continuing-a-merge case]
Review
Quoted 2 lines
(quoted diff) +2
-0+fi +git read-tree -m -u $(git rev-parse $p_)
[snip topdeps juggling]
Quoted 1 line
+git commit -m "Rebased-using-merge onto new dependencies: $redeps." >
/dev/null2>&1
I know I suggested that code before, but the merge with B' is wasted, so perhaps
git checkout P head=$(git rev-parse --verify HEAD^0) result_tree=$(git log -1 --pretty=format:%T P') result_commit=$(git commit-tree "$result_tree" -p P -p B') git update-ref -m "commit (merge): tg-redepend" HEAD \ "$result_commit" "$head" || ... (fail) test -x "$GIT_DIR/hooks/post-merge" && $GIT_DIR/hooks/post-merge 0
I'm not sure. Is there some more porcelain-ish way to do this (create a merge commit when you already know the resulting and parents)?
But with that change the entire restarted=merge branch would go away, so I hope there is a nice way to do it. I'll think more.
Hope that helps,
Jonathan
Quoted 13 lines
tg-redepend.sh new file +12
-0+ +git branch -f $p +git checkout $p + +tg delete $b_ > /dev/null 2>&1 +git branch -D $p_ + +info "Rebased-using-merge onto new dependencies: $redeps." + +# Local Variables: +# sh-basic-offset:8 +# End:
On vr, 2008-08-15 at 13:20 -0500, Jonathan Nieder wrote:
Hi,
Quoted 1 line
s/tg/tg redepend/?
Yes.
Quoted 2 lines
Why not move the base-creation code in
tg-create.shto a new function intg.shto use here?
Yes, that's better.
Quoted 11 lines
I know I suggested that code before, but the merge with B' is wasted, so perhaps
git checkout P head=$(git rev-parse --verify HEAD^0) result_tree=$(git log -1 --pretty=format:%T P') result_commit=$(git commit-tree "$result_tree" -p P -p B') git update-ref -m "commit (merge): tg-redepend" HEAD \ "$result_commit" "$head" || ... (fail) test -x "$GIT_DIR/hooks/post-merge" && $GIT_DIR/hooks/post-merge 0
Quoted 5 lines
I'm not sure. Is there some more porcelain-ish way to do this (create a merge commit when you already know the resulting and parents)?
But with that change the entire restarted=merge branch would go away, so I hope there is a nice way to do it. I'll think more.
Yes, the user should get a nice chance to resolve any conflicts...
Thanks!
Jan.
Signature · 2 lines
Jan Nieuwenhuizen <[email protected]> | GNU LilyPond - The music typesetter http://www.xs4all.nl/~jantien | http://www.lilypond.org
Hi,
Quoted 7 lines · Jan Nieuwenhuizen
As discussed previously
http://kerneltrap.org/mailarchive/git/2008/8/13/2925144Change a topgit branch's dependencies by doing a rebase-by-merge.
is this script in use by you, or is it abandoned in favor of another idea?
Anyway, I have tried it today but it looks like the top-bases wasn't updated to the new deps. It points still to the old base. Second, I got an empty line in my .topdeps file.
Quoted 5 lines
tg-redepend.sh new file +5
-0+ +if [ -n "$add" ]; then + add="${add/# }" + add="${add// / }" + dupes=$(grep -E "^${add// /|}/\$" "$root_dir/.topdeps" | tr '\n' ' ')
tg-redepend.sh line 49
Quoted 10 lines
tg-redepend.sh new file +10
-0+ [ -z "$dupes" ] || die "already depend on: $dupes" + redeps=$(echo "$add" | cat "$root_dir/.topdeps" - | tr '\n' ' ' | sed -e 's/ \+$//') +elif [ -n "$remove" ]; then + remove="${remove// / }" + remove="${remove/# }" + avail=$(grep -E "^${remove// /|}/\$" "$root_dir/.topdeps" | sort | tr '\n' ' ') + remove_sorted=$(echo "$remove" | tr ' ' '\n' | grep -v '^$' | sort | tr '\n' ' ') + [ "$avail" = "$remove_sorted" ] || die "not depending on some of: $remove" + redeps=$(grep -vE "^${remove// /|}/\$" "$root_dir/.topdeps" | tr '\n' ' ') +fi
IMHO all these "| tr '\n' ' '" aren't needed. bash do the right thing here.
Bert
On ma, 2008-09-01 at 11:31 +0200, Bert Wesarg wrote:
Hi Bert,
Quoted 10 lines · Jan Nieuwenhuizen
Quoted 7 lines
As discussed previously
http://kerneltrap.org/mailarchive/git/2008/8/13/2925144Change a topgit branch's dependencies by doing a rebase-by-merge.
is this script in use by you, or is it abandoned in favor of another idea?
I haven't had the time to digest the several new takes on this, esp.
http://kerneltrap.org/mailarchive/git/2008/8/15/2954214 and combining my previous attempt's use of git revert and git cherry-pick with git read-tree to make for a much faster adding or removal of dependencies.
Quoted 2 lines
Anyway, I have tried it today but it looks like the top-bases wasn't updated to the new deps.
How odd. It also looks like "redeps" contains the new set of dependencies, which is written to .topdeps. I guess that most of this script will be abandoned anyway, but a nice bug report ie: how to reproduce this error never hurts ;-)
Quoted 2 lines
IMHO all these "| tr '\n' ' '" aren't needed. bash do the right thing here.
Thanks, I'll have a look. You did try --add, --remove and "new dep list" right?
Greetings,
Jan.
Signature · 2 lines
Jan Nieuwenhuizen <[email protected]> | GNU LilyPond - The music typesetter http://www.xs4all.nl/~jantien | http://www.lilypond.org
Quoted 21 lines · Jan Nieuwenhuizen
On ma, 2008-09-01 at 11:31 +0200, Bert Wesarg wrote:
Hi Bert,
Quoted 10 lines · Jan Nieuwenhuizen
Quoted 7 lines
As discussed previously
http://kerneltrap.org/mailarchive/git/2008/8/13/2925144Change a topgit branch's dependencies by doing a rebase-by-merge.
is this script in use by you, or is it abandoned in favor of another idea?
I haven't had the time to digest the several new takes on this, esp.
http://kerneltrap.org/mailarchive/git/2008/8/15/2954214 and combining my previous attempt's use of git revert and git cherry-pick with git read-tree to make for a much faster adding or removal of dependencies.
Quoted 7 lines
Quoted 2 lines
Anyway, I have tried it today but it looks like the top-bases wasn't updated to the new deps.
How odd. It also looks like "redeps" contains the new set of dependencies, which is written to .topdeps. I guess that most of this script will be abandoned anyway, but a nice bug report ie: how to reproduce this error never hurts ;-)
Yeah, sorry, here comes part two:
I have tried to switch the order of two topics, which are the only two in this 'series'. T1 depdens on master, and T2 on T1 with definitive merge conflicts.
first step was to redepend T2 to master:
$ tg redepend master
after that, I saw the above odds, i.e.:
* the refs/top-bases/T2 points still to T1 not master
* (NEW) the .topmsg is lost (which I discovered after step two)
* a trailing empty line is in .topdeps
(NEW) step two was to redpend T1 on T2:
$ git checkout T2 $ tg redepend T2
after that, my T1 changes were lost, i.e. the worktree is in state of T2.
I have attached the log of this session (slightly edited).
Thanks anyway for working on this.
Regards
Bert
Quoted 2 lines
Greetings,
Jan.