Re: [TopGit PATCH] tg redepend: New command.
- From
Jonathan Nieder <jrnieder@uchicago.edu>
- Date
- Aug 15, 2008, 18:20 UTC
- Message-ID
- <Pine.GSO.4.62.0808151241300.17250@harper.uchicago.edu>
- In-Reply-To
- <1218808427.25300.2.camel@heerbeest>
Hi,
Jan Nieuwenhuizen wrote:
Show 13 quoted lines
> As discussed previously > > http://kerneltrap.org/mailarchive/git/2008/8/13/2925144 > > Change a topgit branch's dependencies by doing a rebase-by-merge. > > Signed-off-by: Jan Nieuwenhuizen <janneke@gnu.org> > --- > Makefile | 2 +- > README | 5 ++ > tg-redepend.sh | 154 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 160 insertions(+), 1 deletions(-) > create mode 100644 tg-redepend.sh
[...]
> + -h|--help) > + echo "Usage: tg [--add|--remove] DEPENDENCY..." >&2
s/tg/tg redepend/?
[...]
Show 5 quoted lines
> +# 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?
[...]
Show 6 quoted lines
> +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]
> +fi > +git read-tree -m -u $(git rev-parse $p_)
[snip topdeps juggling]
> +git commit -m "Rebased-using-merge onto new dependencies: $redeps." > /dev/null 2>&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
Show 13 quoted lines
> + > +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: >