diff options
author | Hans Ulrich Niedermann <hun@n-dimensional.de> | 2007-11-07 20:18:33 +0100 |
---|---|---|
committer | Hans Ulrich Niedermann <hun@n-dimensional.de> | 2007-11-07 20:18:33 +0100 |
commit | 065882698b0c31f12f7bdbdcf0562c1c6d318f7e (patch) | |
tree | 6ca612251b71bc607654e9549967d9d2cca73182 | |
parent | dda530f08dbe8a4649d8d4356e09d9a402d509e5 (diff) | |
download | ndim-git-utils-065882698b0c31f12f7bdbdcf0562c1c6d318f7e.tar.gz ndim-git-utils-065882698b0c31f12f7bdbdcf0562c1c6d318f7e.tar.xz ndim-git-utils-065882698b0c31f12f7bdbdcf0562c1c6d318f7e.zip |
git-rebase-subtree: support reverse operation
-rw-r--r-- | git-rebase-subtree/git-rebase-subtree.in | 44 | ||||
-rw-r--r-- | git-rebase-subtree/git-rebase-subtree.man.in | 48 |
2 files changed, 65 insertions, 27 deletions
diff --git a/git-rebase-subtree/git-rebase-subtree.in b/git-rebase-subtree/git-rebase-subtree.in index 1798942..3b3274d 100644 --- a/git-rebase-subtree/git-rebase-subtree.in +++ b/git-rebase-subtree/git-rebase-subtree.in @@ -40,14 +40,15 @@ set -e cmd() { echo "CMD>" "$@" - gitk --all "$@" } gf_init() { + configvar="rebase-subtree.subtree" echo "$self: Examining configuration" - git config follow.tree | while read from to restofline; do + test -n "$(git config "$configvar")" || die "Unset or empty git config var \"$configvar\"" + git config "$configvar" | while read from to restofline; do if test "x#" = "x$(echo "$from" | sed -n '1s/^\(.\).*/\1/p')"; then continue; fi echo "" echo " From: $from" @@ -84,50 +85,43 @@ gf_rmbranch() { gf_rebase_tree() { + reverse="no" + case "$1" in + --reverse) reverse=yes; shift ;; + esac newroot="$1" test "x$newroot" = "x" && die "Need <newroot> parameter" oldroot="$2" test "x$oldroot" = "x" && die "Need <oldroot> parameter" echo echo "$self: Preparing subtree rebase" - git config follow.tree | while read from to restofline; do + git config "$configvar" | while read from to restofline; do if test "x#" = "x$(echo "$from" | sed -n '1s/^\(.\).*/\1/p')"; then continue; fi gf_branch "$from" gf_branch "$to" done - gitk --all echo echo "$self: Executing subtree rebase" - git config follow.tree | while read from to restofline; do + git config "$configvar" | while read from to restofline; do if test "x#" = "x$(echo "$from" | sed -n '1s/^\(.\).*/\1/p')"; then continue; fi - cmd git-rebase --onto "$from" "follow-old/$from" "$to" + if test "x$reverse" = "xno" && test "x$from" = "x$oldroot"; then + cmd git-rebase --onto "$newroot" "follow-old/$from" "$to" + elif test "x$reverse" = "xyes" && test "x$from" = "x$newroot"; then + cmd git-rebase --onto "$newroot" "$oldroot" "$to" + else + cmd git-rebase --onto "$from" "follow-old/$from" "$to" + fi done - gitk --all echo echo "$self: Cleaning up after subtree rebase" - git config follow.tree | while read from to restofline; do + git config "$configvar" | while read from to restofline; do if test "x#" = "x$(echo "$from" | sed -n '1s/^\(.\).*/\1/p')"; then continue; fi gf_rmbranch "$from" gf_rmbranch "$to" done - gitk --all } - -# The great command case -command="$1" -if shift; then - case "$command" in - rebase-subtree) - gf_init - gf_rebase_tree "$@" - ;; - *) - die "Invalid command line parameter: \"$command\"" - ;; - esac -else - gf_init -fi +gf_init +gf_rebase_tree "$@" # End of file. diff --git a/git-rebase-subtree/git-rebase-subtree.man.in b/git-rebase-subtree/git-rebase-subtree.man.in index 295dfc5..01a21cb 100644 --- a/git-rebase-subtree/git-rebase-subtree.man.in +++ b/git-rebase-subtree/git-rebase-subtree.man.in @@ -5,6 +5,11 @@ git\-rebase\-subtree \- rebase set of interdependant git branches .B "git\-rebase\-subtree" .I "<origin-branch>" .I "<master-branch>" +.PP +.B "git\-rebase\-subtree" +.I "\-\-reverse" +.I "<master-branch>" +.I "<master-branch-plus-x>" .SH DESCRIPTION So you are tracking some upstream's git repo and maintain your own set of interdependent feature branches ("branch subtree"). @@ -19,8 +24,8 @@ Note: Letters A\-Z are branch names, not revs. .PP Old tree: .nf - *\-\-F - / + *\-\-F + / origin=master\-\-A\-\-B\-\-G \\ *\-\-D\-\-H @@ -28,6 +33,18 @@ Old tree: *\-\-*\-\-K .fi .PP +Generate the following configuration using +.I "git config rebase-subtree.subtree" +.nf + master A + A B + B F + B G + A D + D H + D K +.fi +.PP After "git\-fetch \-v": .nf *\-\-F @@ -46,8 +63,35 @@ After hypothetical "git\-rebase\-subtree origin master": origin'=master'\-\-A'\-\-B'\-\-G' \\ *'\-\-D'\-\-H' + \\ + *'\-\-*'\-\-K' +.fi +.SS "REVERSE OPERATION" +.PP +Old tree: +.nf + *\-\-F + / + master\-\-Y\-\-A\-\-B\-\-G + \\ + *\-\-D\-\-H + \\ + *\-\-*\-\-K +.fi +.PP +After hypothetical "git\-rebase\-subtree \-\-reverse master Y": +.nf + Y *'\-\-F' + / / + master\-\-A'\-\-B'\-\-G' + \\ + *'\-\-D'\-\-H' \\ *'\-\-*'\-\-K' .fi +.SH "BUGS" +.TP +.B "Lacks generality (fixation about 'master')" +Yes. .SH "SEE ALSO" git\-rebase(1). |