{"thread":{"id":"24057","subject":"Helpful Script for Maintaining Integration Branches","startedAt":"2010-06-09T19:40:38Z","lastAt":"2010-06-09T19:40:38Z","messageCount":1,"participants":["Boyd Stephen Smith Jr."],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"143371","messageId":"201006091440.43409.bss@iguanasuicide.net","threadId":"24057","inReplyTo":null,"subject":"Helpful Script for Maintaining Integration Branches","fromName":"Boyd Stephen Smith Jr.","fromEmail":"bss@iguanasuicide.net","sentAt":"2010-06-09T19:40:38Z","receivedAt":"2010-06-09T19:40:38Z","isPatch":false,"sender":{"key":"bss@iguanasuicide.net","avatar":"https://gravatar.com/avatar/84b95eeff194b816c1568b1339e63e4b229825298664a9037b9f1ec713ead1e3?d=mp&s=160"},"body":"Attached is a script I wrote today to help manage integration branches.  I'd \nlike to share this with anyone that might find it useful, and possibly get it \nincluded in mainline Git.\n\nI'm calling it git-integrate-branch.sh, but I'm open to a rename, as well as \nany review you might want to provide.\n\nThe use case is when you have a branch for a particular bug fix, but master \nhas had other commits that cause a conflict.  In addition, some users or \nfeatures may have branched from master, so you'd like to maintain as \nintegration branch so they can merge in \"just\" the bug fix without other \nchanges to master.\n\nYour tree:\n\n*-*-*-...-*-* (master)\n \\\n  * (bug-3010681)\n\nYou run this script and it see if the bug fix branch has any merge conflict \nwith master.  If not, you can leave your tree alone.  If so, it tells you the \nexact commit that causes a conflict and prompts you to update your bug fix \nbranch.  Once you resolve the merge manually you get:\n\n*-*-*-...-*-...-*-* (master)\n \\         \\\n  *---------* (bug-3010681)\n\nAt this point, you repeat the process.  Either the bug fix branch can be \ncleanly merged with master, or it needs to be further updated due to other \nconflicts.\n\nIf someone is maintaining an installation that was snapshotted from master, \ntheir tree looks like:\n\n*-*-...-* (production) -*-...-*-* (master)\n \\                       \\\n  *-----------------------* (bug-301681)\n\nThey can run something like this to merge in just the bug fix without the \nother changes from master:\n\ngit rev-list bug-3010681 '^production' |\nwhile read rev; do\n\tmerge_bases=$(git merge-base production \"$rev\")\n\tif [ $(git rev-parse production) != \"$merge_bases\" ]; then\n\t\tprintf >&2 'Merge %s into %s.' \"$rev\" 'production'\n\t\tbreak\n\tfi\ndone\n\nOf course, this assumed the bug fix has been backported or was originally \nwritten against the buggy commit, instead of being based off of master.\n-- \nBoyd Stephen Smith Jr.           \t ,= ,-_-. =.\nbss@iguanasuicide.net            \t((_/)o o(\\_))\nICQ: 514984 YM/AIM: DaTwinkDaddy \t `-'(. .)`-'\nhttp://iguanasuicide.net/        \t     \\_/\n\nPS Last time I wrote to this list, CC was the norm.  I am not subscribed, so \nplease CC me even if it is no longer the norm.\n"}]}