{"thread":{"id":"17367","subject":"[PATCH] Reintegrate script","startedAt":"2009-01-26T09:03:16Z","lastAt":"2009-02-13T18:23:14Z","messageCount":3,"participants":["Junio C Hamano","Johannes Schindelin","Bernt Hansen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"101952","messageId":"7vd4ea8mnf.fsf@gitster.siamese.dyndns.org","threadId":"17367","inReplyTo":null,"subject":"[PATCH] Reintegrate script","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-01-26T09:03:16Z","receivedAt":"2009-01-26T09:03:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"In a workflow that uses topic branches heavily, you would need to keep\nupdating test integration branch(es) all the time.  If they are managed\nlike my 'next' by merging the tips of topics that have grown since the\nlast integration, it is not so difficult.  You only need to review output\nfrom \"git branch --no-merged next\" to see if there are topics that can and\nneeds to be merged to 'next'.\n\nBut sometimes it is easier to rebuild a test integration branch from\nscratch all the time, especially if you do not publish it for others to\nbuild on.\n\nI've been using this script for some time to rebuild jch and pu branches\nin my workflow.  jch's tip is supposed to always match 'next', but it is\nrebuilt from scratch on top of 'master' by merging the same topics that\nare in 'next'.  You can use the same script in your work.\n\nTo use it, you give a commit range base..tip to the script, and you will\nsee a shell script that uses a series of 'git-merge'.  \"base\" is the more\nstable branch that you rebuild your test integration branch on top (in my\ncase, 'master'), and \"tip\" is where the tip of the test integration branch\nis from the last round (in my case, 'jch' or 'pu').\n\nThen you can run the resulting script, fix conflicted merge and use\n'git-commit', and then repeat until all the branches are re-integrated on\ntop of the base branch.\n\n    $ Meta/Reintegrate master..jch >/var/tmp/redo-jch.sh\n    $ cat /var/tmp/redo-jch.sh\n    #!/bin/sh\n    while read branch eh\n    do\n\t    case \"$eh\" in\n\t    \"\") git merge \"$branch\" || break ;;\n\t    ?*) echo >&2 \"Eh? $branch $eh\"; break ;;\n\t    esac\n    done <<EOF\n    jc/blame\n    js/notes\n    ks/maint-mailinfo-folded~3\n    tr/previous-branch\n    EOF\n    $ git checkout jch\n    $ git reset --hard master\n    $ /var/tmp/redo-jch.sh\n    ... if there is conflict, resolve, \"git commit\" here ...\n    $ /var/tmp/redo-jch.sh\n    ... repeat until everything is applied.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\n * This is taken from my 'todo' branch, which I keep a checkout in Meta/\n   directory.\n\n Reintegrate |   42 ++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 42 insertions(+), 0 deletions(-)\n create mode 100755 Reintegrate\n\ndiff --git a/Reintegrate b/Reintegrate\nnew file mode 100755\nindex 0000000..dfdb73e\n--- /dev/null\n+++ b/Reintegrate\n@@ -0,0 +1,42 @@\n+#!/bin/sh\n+\n+merge_msg=\"Merge branch '\\(.*\\)'\"\n+x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'\n+x40=\"$x40$x40$x40$x40$x40$x40$x40$x40\"\n+LF='\n+'\n+\n+echo '#!/bin/sh\n+while read branch eh\n+do\n+\tcase \"$eh\" in\n+\t\"\") git merge \"$branch\" || break ;;\n+\t?*) echo >&2 \"Eh? $branch $eh\"; break ;;\n+\tesac\n+done <<EOF'\n+\n+git log --pretty=oneline --first-parent \"$1\" |\n+{\n+\tseries=\n+\twhile read commit msg\n+\tdo\n+\t\tother=$(git rev-parse --verify \"$commit^2\") &&\n+\t\tbranch=$(expr \"$msg\" : \"$merge_msg\") &&\n+\t\ttip=$(git rev-parse --verify \"refs/heads/$branch\" 2>/dev/null) &&\n+\t\tmerged=$(git name-rev --refs=\"refs/heads/$branch\" \"$other\" 2>/dev/null) &&\n+\t\tmerged=$(expr \"$merged\" : \"$x40 \\(.*\\)\") &&\n+\t\ttest \"$merged\" != undefined || {\n+\t\t\tother=$(git log -1 --pretty='format:%s' $other) &&\n+\t\t\tmerged=\"$branch :rebased? $other\"\n+\t\t}\n+\t\tif test -z \"$series\"\n+\t\tthen\n+\t\t\tseries=\"$merged\"\n+\t\telse\n+\t\t\tseries=\"$merged$LF$series\"\n+\t\tfi\n+\tdone\n+\techo \"$series\"\n+}\n+\n+echo 'EOF'\n-- \n1.6.1.1.248.g7f6d2\n"},{"id":"101964","messageId":"alpine.DEB.1.00.0901261218070.14855@racer","threadId":"17367","inReplyTo":"7vd4ea8mnf.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Reintegrate script","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-01-26T11:18:30Z","receivedAt":"2009-01-26T11:18:30Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 26 Jan 2009, Junio C Hamano wrote:\n\n> In a workflow that uses topic branches heavily, you would need to keep \n> updating test integration branch(es) all the time.  If they are managed \n> like my 'next' by merging the tips of topics that have grown since the \n> last integration, it is not so difficult.  You only need to review \n> output from \"git branch --no-merged next\" to see if there are topics \n> that can and needs to be merged to 'next'.\n> \n> But sometimes it is easier to rebuild a test integration branch from\n> scratch all the time, especially if you do not publish it for others to\n> build on.\n\nFWIW that is exactly what I am aiming at with my rebase -i -p work.\n\nCiao,\nDscho\n"},{"id":"104539","messageId":"87r622yz59.fsf@gollum.intra.norang.ca","threadId":"17367","inReplyTo":"7vd4ea8mnf.fsf@gitster.siamese.dyndns.org","subject":"[PATCH] Meta/Reintegrate: Record all merges to prevent losing topics","fromName":"Bernt Hansen","fromEmail":"bernt@norang.ca","sentAt":"2009-02-13T18:23:14Z","receivedAt":"2009-02-13T18:23:14Z","isPatch":true,"sender":{"key":"bernt@norang.ca","avatar":null},"body":"Rebuilding an integration branch loses the initial topics when merging\nresults in fast-forwarding the history.\n\nForce the integration branch to always record merge commits to ensure\nwe keep all of the topics on future integration branch rebuilds.\n\nSigned-off-by: Bernt Hansen <bernt@norang.ca>\n---\nThanks for this script Junio!\n\nI started using this script today to clean up one of my integration\nbranches by separating the linear history into separate topics.  This\nworks great except for the minor glitch this patch fixes.\n\n Reintegrate |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/Reintegrate b/Reintegrate\nindex dfdb73e..5909821 100755\n--- a/Reintegrate\n+++ b/Reintegrate\n@@ -10,7 +10,7 @@ echo '#!/bin/sh\n while read branch eh\n do\n \tcase \"$eh\" in\n-\t\"\") git merge \"$branch\" || break ;;\n+\t\"\") git merge --no-ff \"$branch\" || break ;;\n \t?*) echo >&2 \"Eh? $branch $eh\"; break ;;\n \tesac\n done <<EOF'\n-- \n1.6.2.rc0.55.g30aa4f\n"}]}