Helpful Script for Maintaining Integration Branches

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Attached is a script I wrote today to help manage integration branches.  I'd 
like to share this with anyone that might find it useful, and possibly get it 
included in mainline Git.

I'm calling it git-integrate-branch.sh, but I'm open to a rename, as well as 
any review you might want to provide.

The use case is when you have a branch for a particular bug fix, but master 
has had other commits that cause a conflict.  In addition, some users or 
features may have branched from master, so you'd like to maintain as 
integration branch so they can merge in "just" the bug fix without other 
changes to master.

Your tree:

*-*-*-...-*-* (master)
 \
  * (bug-3010681)

You run this script and it see if the bug fix branch has any merge conflict 
with master.  If not, you can leave your tree alone.  If so, it tells you the 
exact commit that causes a conflict and prompts you to update your bug fix 
branch.  Once you resolve the merge manually you get:

*-*-*-...-*-...-*-* (master)
 \         \
  *---------* (bug-3010681)

At this point, you repeat the process.  Either the bug fix branch can be 
cleanly merged with master, or it needs to be further updated due to other 
conflicts.

If someone is maintaining an installation that was snapshotted from master, 
their tree looks like:

*-*-...-* (production) -*-...-*-* (master)
 \                       \
  *-----------------------* (bug-301681)

They can run something like this to merge in just the bug fix without the 
other changes from master:

git rev-list bug-3010681 '^production' |
while read rev; do
	merge_bases=$(git merge-base production "$rev")
	if [ $(git rev-parse production) != "$merge_bases" ]; then
		printf >&2 'Merge %s into %s.' "$rev" 'production'
		break
	fi
done

Of course, this assumed the bug fix has been backported or was originally 
written against the buggy commit, instead of being based off of master.
-- 
Boyd Stephen Smith Jr.           	 ,= ,-_-. =.
bss@xxxxxxxxxxxxxxxxx            	((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy 	 `-'(. .)`-'
http://iguanasuicide.net/        	     \_/

PS Last time I wrote to this list, CC was the norm.  I am not subscribed, so 
please CC me even if it is no longer the norm.

Attachment: git-integrate-branch.sh
Description: application/shellscript

Attachment: signature.asc
Description: This is a digitally signed message part.


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]