git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Helpful Script for Maintaining Integration Branches

From
Boyd Stephen Smith Jr. <bss@iguanasuicide.net>
Date
Jun 9, 2010, 19:40 UTC
Message-ID
<201006091440.43409.bss@iguanasuicide.net>

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@iguanasuicide.net            	((_/)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.
Message 1 of 1 in “Helpful Script for Maintaining Integration Branches”
  1. Boyd Stephen Smith Jr.Jun 9, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.