summaryrefslogtreecommitdiffstats
path: root/git-rebase-subtree
diff options
context:
space:
mode:
authorHans Ulrich Niedermann <hun@n-dimensional.de>2007-11-07 18:40:27 +0100
committerHans Ulrich Niedermann <hun@n-dimensional.de>2007-11-07 18:40:27 +0100
commitc6d8622c527ab58018928c617d03f747cef9a70b (patch)
treee985f157144d7d608e4af3e4d203b0d5056c53c3 /git-rebase-subtree
parent797dc152f1885e9eee2c8826a491a52ef2f61699 (diff)
downloadndim-git-utils-c6d8622c527ab58018928c617d03f747cef9a70b.tar.gz
ndim-git-utils-c6d8622c527ab58018928c617d03f747cef9a70b.tar.xz
ndim-git-utils-c6d8622c527ab58018928c617d03f747cef9a70b.zip
Completed rename to git-rebase-subtree
Diffstat (limited to 'git-rebase-subtree')
-rw-r--r--git-rebase-subtree/Makefile-files13
-rw-r--r--git-rebase-subtree/generate-patches.sh45
-rw-r--r--git-rebase-subtree/git-rebase-subtree.in118
-rw-r--r--git-rebase-subtree/git-rebase-subtree.man.in53
-rw-r--r--git-rebase-subtree/rebase-all.sh16
-rw-r--r--git-rebase-subtree/upload-patches.sh7
6 files changed, 252 insertions, 0 deletions
diff --git a/git-rebase-subtree/Makefile-files b/git-rebase-subtree/Makefile-files
new file mode 100644
index 0000000..27e1549
--- /dev/null
+++ b/git-rebase-subtree/Makefile-files
@@ -0,0 +1,13 @@
+# -*- makefile -*-
+bin_SCRIPTS += git-rebase-subtree/git-rebase-subtree
+EXTRA_DIST += git-rebase-subtree/git-rebase-subtree.in
+UPLOAD_FILES += git-rebase-subtree/git-rebase-subtree
+
+man1_MANS += git-rebase-subtree/git-rebase-subtree.man
+EXTRA_DIST += git-rebase-subtree/git-rebase-subtree.man.in
+
+if HAVE_NDIM_MAN2TXT
+dist_doc_DATA += git-rebase-subtree/git-rebase-subtree.txt
+CLEANFILES += git-rebase-subtree/git-rebase-subtree.txt
+UPLOAD_FILES += git-rebase-subtree/git-rebase-subtree.txt
+endif
diff --git a/git-rebase-subtree/generate-patches.sh b/git-rebase-subtree/generate-patches.sh
new file mode 100644
index 0000000..bf2c17a
--- /dev/null
+++ b/git-rebase-subtree/generate-patches.sh
@@ -0,0 +1,45 @@
+#!/bin/sh
+set -x
+
+repourl="http://radeonhd.lauft.net/xf86-video-radeonhd.git/"
+sedhtml="s/&/\&amp;/g; s/@/\&#x40;/g; s/</\&lt;/g; s/>/\&gt;/g;"
+
+rm -f "patches/"*/[0-9][0-9][0-9][0-9]-*.patch
+rmdir "patches/"*
+
+while read start from to dir restofline
+do
+ if echo "$start" | grep '^#' > /dev/null; then continue; fi
+ git format-patch -o "patches/$dir" --start-number "$start" "$from".."$to"
+ if test "x$to" = "x$dir"; then
+ {
+ echo "<h1 style='margin:0;'>${to} branch</h1>"
+ echo "<p><tt>git pull ${repourl} ${to}</tt></p>"
+ } > "patches/$dir/HEADER.html"
+ echo "IndexIgnore .." > "patches/$dir/.htaccess"
+ {
+ sedcmds=""
+ for f in "patches/$dir/"[0-9]*.patch; do
+ b="$(basename "$f")"
+ commit="$(sed -n '1s/^From \([a-z0-9]\{1,\}\).*/\1/p' "$f")"
+ sedcmds="${sedcmds} s|\(${commit}\)|<a href=\"$b\">\1</a>|;"
+ echo "AddDescription \"$(sed -n 's|^Subject: [PATCH[^\]*] \(.*\)|\1|p' "$f" | sed "${sedhtml}")\" ${b}" >> "patches/$dir/.htaccess"
+ done
+ echo "$commits"
+ echo "<pre style=\"\">"
+ git log --stat "${from}..${to}" | sed "${sedhtml}${sedcmds}"
+ echo "</pre>"
+ } > "patches/$dir/README.html"
+ fi
+done<<EOF
+#1 master ndim-trivial-fixes ndim-trivial-fixes
+#1 ndim-trivial-fixes ndim-doc ndim-doc
+1 ndim-trivial-fixes ndim-git-version ndim-git-version
+101 ndim-doc ndim/update-docs manpage-update
+201 ndim-doc ndim/update-docs-auto manpage-update
+301 ndim-doc ndim/update-man-sed manpage-update
+EOF
+
+( cd patches && tar cvfz ndim-all-radeonhd-patches.tar.gz --exclude .htaccess --exclude '*~' --exclude '*.tar.gz' --exclude 'HEADER.html' .)
+
+ls -l patches
diff --git a/git-rebase-subtree/git-rebase-subtree.in b/git-rebase-subtree/git-rebase-subtree.in
new file mode 100644
index 0000000..d2422ab
--- /dev/null
+++ b/git-rebase-subtree/git-rebase-subtree.in
@@ -0,0 +1,118 @@
+#!/bin/sh
+#
+
+unset CDPATH
+SED="${SED-sed}"
+
+self=`basename "$0"`
+selfdir=`dirname "$0"`
+selfdir=`cd "$selfdir" && pwd`
+. "$selfdir/git-ndim-sh"
+
+SUBDIRECTORY_OK="yes"
+USAGE="<command> [params...]"
+
+LONG_USAGE="\
+Let a local subtree of branches follow a remote origin without too much merging.
+For more details, see the ${self}(1) man page."
+. git-sh-setup
+
+require_work_tree
+
+# Abort on error
+set -e
+
+
+cmd() {
+ echo "CMD>" "$@"
+ gitk --all
+ "$@"
+}
+
+
+gf_init() {
+ echo "$self: Examining configuration"
+ git config follow.tree | 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
+}
+
+gf_branch() {
+ branch="$1"
+ newbranch="follow-old/$branch"
+ if git-rev-parse --verify "$branch" > /dev/null 2>&1; then
+ # valid branch
+ if git-rev-parse --verify "$newbranch" > /dev/null 2>&1; then
+ : # branch already exists, do nothing
+ else
+ cmd git-branch "${newbranch}" "${branch}"
+ fi
+ else
+ echo "$self: gf_branch called with invalid branch \"$branch\"" >&2
+ exit 1
+ fi
+}
+
+
+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
+ cmd git-branch -D "${newbranch}"
+ fi
+ fi
+}
+
+
+gf_rebase_tree() {
+ 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
+ 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
+ if test "x#" = "x$(echo "$from" | sed -n '1s/^\(.\).*/\1/p')"; then continue; fi
+ cmd git-rebase --onto "$from" "follow-old/$from" "$to"
+ done
+ gitk --all
+ echo
+ echo "$self: Cleaning up after subtree rebase"
+ git config follow.tree | 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
+
+# End of file.
diff --git a/git-rebase-subtree/git-rebase-subtree.man.in b/git-rebase-subtree/git-rebase-subtree.man.in
new file mode 100644
index 0000000..9f51432
--- /dev/null
+++ b/git-rebase-subtree/git-rebase-subtree.man.in
@@ -0,0 +1,53 @@
+.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
+.SH SYNOPSIS
+.B "git\-rebase\-subtree"
+.I "<origin-branch>"
+.I "<master-branch>"
+.SH DESCRIPTION
+So you are tracking some upstream's git repo and maintain your own set
+of interdependent feature branches ("branch subtree").
+.PP
+And you want to keep that "branch subtree" up-to-date in relation to
+upstream so it stays sweet, small, and clean, increasing the chances
+that upstream will finally pick something up from it.
+.PP
+Initial situation: Local branch master tracks remote origin.
+.PP
+Note: Letters A\-Z are branch names, not revs.
+.PP
+Old tree:
+.nf
+ *\-\-F
+ /
+ origin=master\-\-A\-\-B\-\-G
+ \\
+ *\-\-D\-\-H
+ \\
+ *\-\-*\-\-K
+.fi
+.PP
+After "git\-fetch \-v":
+.nf
+ *\-\-F
+ /
+ master\-\-\-A\-\-B\-\-G
+ \\ \\
+ * *\-\-D\-\-H
+ \\ \\
+ origin' *\-\-*\-\-K
+.fi
+.PP
+After hypothetical "git\-rebase\-subtree origin master":
+.nf
+ *'\-\-F'
+ /
+ origin'=master'\-\-A'\-\-B'\-\-G'
+ \\
+ *'\-\-D'\-\-H'
+ \\
+ *'\-\-*'\-\-K'
+.fi
+.SH "SEE ALSO"
+git\-rebase(1).
diff --git a/git-rebase-subtree/rebase-all.sh b/git-rebase-subtree/rebase-all.sh
new file mode 100644
index 0000000..02676c7
--- /dev/null
+++ b/git-rebase-subtree/rebase-all.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+set -x
+while read branch base restofline
+do
+ git rebase "$base" "$branch" || exit "$?"
+done<<EOF
+master origin
+ndim-trivial-fixes master
+ndim-doc ndim-trivial-fixes
+ndim/update-docs ndim-doc
+ndim/update-docs-auto ndim-doc
+ndim/update-man-sed ndim-doc
+fedora/generate-xinf ndim-trivial-fixes
+ndim-conntest-checks ndim-trivial-fixes
+EOF
diff --git a/git-rebase-subtree/upload-patches.sh b/git-rebase-subtree/upload-patches.sh
new file mode 100644
index 0000000..88da064
--- /dev/null
+++ b/git-rebase-subtree/upload-patches.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+set -x
+rsync -avz --delete patches/ "${RSYNC_HOST}:${RSYNC_DIR}/patches/"
+for branch in "" ndim-trivial-fixes ndim-doc ndim-git-version
+do
+ git push -f public ${branch}
+done