From d55abcb432155f549d3b842299f7f7a80f32b7fa Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Thu, 24 Jul 2008 16:10:12 +0200 Subject: git-rebase-subtree: Not obsolete just yet Mark git-rebase-subtree as not being obsolete, and use a better config mechanism than before: Multi-line config options are much more maintainable than a single string with lots of \n linefeeds in it. --- README | 7 ++-- git-rebase-subtree/git-rebase-subtree.in | 42 +++++++++++++++-------- git-rebase-subtree/git-rebase-subtree.man.in | 51 +++++++++++++++++++++------- 3 files changed, 70 insertions(+), 30 deletions(-) diff --git a/README b/README index 727b705..ec1f01b 100644 --- a/README +++ b/README @@ -12,19 +12,20 @@ The utilities in detail some source tree built with automake easy, clean and flexible. The name stands for "git *a*uto*m*ake *b*uild". For details, see git-amb(1) man page. - git-amb(1) is about to be obsoleted by the generalized nbb(1) tool. + git-amb(1) is about to be obsoleted by the generalized nbb(1) + tool which is being developed as a separate project. git-buildmsg (status: testing) Generate .h file containing information about the current git working tree. Useful for programs' version messages in logs etc. Generating the version message from git describe output appears - to be much cleaner, though. + to be much cleaner, though, especially when done at autoconf time. git-rebase-subtree (status: stale) Rebase not only a single branch, but a whole "subtree of branches". Useful for maintaining your own subtree of branches close to some upstream's branch, but is in dire need of proper error handling. - Probably obsoleted by automatic branch..rebase setup in git 1.5.6. + NOT obsoleted by automatic branch..rebase setup in git 1.5.6. Resources diff --git a/git-rebase-subtree/git-rebase-subtree.in b/git-rebase-subtree/git-rebase-subtree.in index 9f7e78a..60efcff 100644 --- a/git-rebase-subtree/git-rebase-subtree.in +++ b/git-rebase-subtree/git-rebase-subtree.in @@ -47,26 +47,38 @@ cmd() { gf_init() { - configvar="rebase-subtree.subtree" echo "$self: Examining configuration" - 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" - echo " To: $to" + config_found=no + for configvar in "rebase-subtree.rebase" "rebase-subtree.subtree" + do + if test -n "$(git config --get-all "$configvar")" + then + if test "x$configvar" = "xrebase-subtree.subtree"; then + echo "$self: WARNING: Using deprecated config variable rebase-subtree.subtree." + echo " Better use rebase-subtree.rebase lines instead." + fi + git config --get-all "$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" + echo " To: $to" + done + config_found=yes + break + fi done + test "x$config_found" = "xyes" || die "Unset or empty git config var \"rebase-subtree.rebase\"" } gf_branch() { branch="$1" newbranch="follow-old/$branch" - if git-rev-parse --verify "$branch" > /dev/null 2>&1; then + if git rev-parse --verify "$branch" > /dev/null 2>&1; then # valid branch - if git-rev-parse --verify "$newbranch" > /dev/null 2>&1; then + if git rev-parse --verify "$newbranch" > /dev/null 2>&1; then : # branch already exists, do nothing else - cmd git-branch "${newbranch}" "${branch}" + cmd git branch "${newbranch}" "${branch}" fi else echo "$self: gf_branch called with invalid branch \"$branch\"" >&2 @@ -78,8 +90,8 @@ gf_branch() { gf_rmbranch() { branch="$1" newbranch="follow-old/$branch" - if git-rev-parse --verify "$branch" > /dev/null 2>&1; then - if git-rev-parse --verify "$newbranch" > /dev/null 2>&1; then + if git rev-parse --verify "$branch" > /dev/null 2>&1; then + if git rev-parse --verify "$newbranch" > /dev/null 2>&1; then cmd git-branch -D "${newbranch}" fi fi @@ -101,14 +113,14 @@ gf_rebase_tree() { read echo echo "$self: Preparing subtree rebase" - git config "$configvar" | while read from to restofline; do + git config --get-all "$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 echo echo "$self: Executing subtree rebase" - git config "$configvar" | while read from to restofline; do + git config --get-all "$configvar" | while read from to restofline; do if test "x#" = "x$(echo "$from" | sed -n '1s/^\(.\).*/\1/p')"; then continue; fi if test "x$reverse" = "xno" && test "x$from" = "x$oldroot"; then cmd git-rebase "$newroot" "$oldroot" @@ -121,7 +133,7 @@ gf_rebase_tree() { done echo echo "$self: Cleaning up after subtree rebase" - git config "$configvar" | while read from to restofline; do + git config --get-all "$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" diff --git a/git-rebase-subtree/git-rebase-subtree.man.in b/git-rebase-subtree/git-rebase-subtree.man.in index 67202b8..e2679ce 100644 --- a/git-rebase-subtree/git-rebase-subtree.man.in +++ b/git-rebase-subtree/git-rebase-subtree.man.in @@ -1,3 +1,5 @@ +.\" shorthand for double quote that works everywhere. +.ds q \N'34' .TH GIT-REBASE-SUBTREE 1 "@PACKAGE_TARNAME@ @PACKAGE_VERSION@" "2007\-11\-02" "@PACKAGE_NAME@ @PACKAGE_VERSION@" .SH NAME git\-rebase\-subtree \- rebase set of interdependant git branches @@ -34,15 +36,15 @@ Old tree: .fi .PP Generate the following configuration using -.I "git config rebase-subtree.subtree" +.IR "git config" : .nf - master A - A B - B F - B G - A D - D H - D K + git config --add rebase-subtree.rebase \*qmaster A\*q + git config --add rebase-subtree.rebase \*qA B\*q + git config --add rebase-subtree.rebase \*qB F\*q + git config --add rebase-subtree.rebase \*qB G\*q + git config --add rebase-subtree.rebase \*qA D\*q + git config --add rebase-subtree.rebase \*qD H\*q + git config --add rebase-subtree.rebase \*qD K\*q .fi .PP After "git\-fetch \-v": @@ -89,11 +91,36 @@ After hypothetical "git\-rebase\-subtree \-\-reverse master Y": \\ *'\-\-*'\-\-K' .fi -.SH "BUGS" +.SH "GIT CONFIGURATION" +Configuration for +.B "git-rebase-subtree" +only makes sense on a per-repository basis, not on a +.I "--global" +basis. +.TP +.B "rebase-subtree.rebase" +Add a new line to the config option for each +.IR "orig" - "branch" +pair. Each +.B "rebase-subtree.rebase" +option line defines an edge in the branch subtree to rebase. +.TP +.B "rebase-subtree.subtree" +.br +.I "(Deprecated because it is unreadable)" +.br +String of \*qorig branch\norig2 branch2\*q form. Becomes very unreadable +when the branch subtree to rebase contains more than a couple of branches. +Use +.B "rebase-subtree.rebase" +instead. +.SH "NOT BUGS" .TP .B "Obsoleted by git 1.5.6" -git 1.5.6 can trigger branch rebases on pulls automatically without -external tools. +git 1.5.6 can trigger branch rebases on pulls instead of standard merges. +It cannot rebase entire subtrees, through, neither by manual command nor +automatically. +.SH "BUGS" .TP .B "Lacks generality (fixation about 'master')" Yes. @@ -107,7 +134,7 @@ error happens during the rebase. .TP .B "Needs proper error handling" Definitely. Possibly just renaming the -.I rebasetree-old/foo +.I rebase-subtree/old/foo branches to .I foo could do the job. Needs more investigation, though. -- cgit