Tracking a fragment of a file in two places with git
Posted
by mabraham
on Stack Overflow
See other posts from Stack Overflow
or by mabraham
Published on 2010-05-06T07:12:44Z
Indexed on
2010/05/06
7:18 UTC
Read the original article
Hit count: 172
Hi,
I have code such as
void myfunc()
{
introduction();
while(condition())
{
complex();
loop();
interior();
code();
}
cleanup();
}
which I wish to duplicate into two versions, viz:
void myfuncA()
{
introduction();
minorchangeA();
while(condition())
{
complex();
loop();
interior();
code();
}
cleanup();
}
void myfuncB()
{
introduction();
minorchangeB();
while(condition())
{
complex();
modifiedB();
loop();
interior();
code();
}
cleanup();
extracleanupB();
}
git claims to track content rather than files, so do I need to tell it that there are chunks here that are common to both myfuncA
and myfuncB
so that when merging with upstream changes to myfunc
that those changes should propagate to both myfuncA
and myfuncB
? If so, how?
The code could be written so that myfuncAB
did the correct thing at each point by testing for condition A or B, but that could seriously hinder readability or performance.
© Stack Overflow or respective owner