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 /git-rebase-subtree/git-rebase-subtree.in | |
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
Diffstat (limited to 'git-rebase-subtree/git-rebase-subtree.in')
-rw-r--r-- | git-rebase-subtree/git-rebase-subtree.in | 44 |
1 files changed, 19 insertions, 25 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. |