From e97499e1d31f20d19231ec7e5cda558eeffa7e28 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 26 Jan 2009 00:48:46 -0800 Subject: [PATCH] Add Meta/Reintegrate In a workflow that uses topic branches heavily, you would need to keep updating test integration branch(es) all the time. If they are managed like my 'next' by merging the tips of topics that have grown since the last integration, it is not so difficult. You only need to review output from "git branch --no-merged next" to see if there are topics that can and needs to be merged to 'next'. But sometimes it is easier to rebuild a test integration branch from scratch all the time, especially if you do not publish it for others to build on. I've been using this script for some time to rebuild jch and pu branches in my workflow. jch's tip is supposed to always match 'next', but it is rebuilt from scratch on top of 'master' by merging the same topics that are in 'next'. You can use the same script in your work. To use it, you give a commit range base..tip to the script, and you will see a shell script that uses a series of 'git-merge'. "base" is the more stable branch that you rebuild your test integration branch on top (in my case, 'master'), and "tip" is where the tip of the test integration branch is from the last round (in my case, 'jch' or 'pu'). Then you can run the resulting script, fix conflicted merge and use 'git-commit', and then repeat until all the branches are re-integrated on top of the base branch. $ Meta/Reintegrate master..jch >/var/tmp/redo-jch.sh $ cat /var/tmp/redo-jch.sh #!/bin/sh while read branch eh do case "$eh" in "") git merge "$branch" || break ;; ?*) echo >&2 "Eh? $branch $eh"; break ;; esac done < --- Reintegrate | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 Reintegrate diff --git a/Reintegrate b/Reintegrate new file mode 100755 index 0000000000..dfdb73ed9f --- /dev/null +++ b/Reintegrate @@ -0,0 +1,42 @@ +#!/bin/sh + +merge_msg="Merge branch '\(.*\)'" +x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' +x40="$x40$x40$x40$x40$x40$x40$x40$x40" +LF=' +' + +echo '#!/bin/sh +while read branch eh +do + case "$eh" in + "") git merge "$branch" || break ;; + ?*) echo >&2 "Eh? $branch $eh"; break ;; + esac +done </dev/null) && + merged=$(git name-rev --refs="refs/heads/$branch" "$other" 2>/dev/null) && + merged=$(expr "$merged" : "$x40 \(.*\)") && + test "$merged" != undefined || { + other=$(git log -1 --pretty='format:%s' $other) && + merged="$branch :rebased? $other" + } + if test -z "$series" + then + series="$merged" + else + series="$merged$LF$series" + fi + done + echo "$series" +} + +echo 'EOF' -- 2.11.4.GIT