# merge smart enough to adapt to renames?

10 messages from 2009-02-19 to 2009-02-22. Participants: Caleb Cushing, Sitaram Chamarty, Rogan Dawes, Kris Shannon.
Thread: https://gitlist.dev/t/17887

## Caleb Cushing, 2009-02-19 06:12

Subject: merge smart enough to adapt to renames?
Message-ID: <81bfc67a0902182212h578e677ck6029c56cb86f7bce@mail.gmail.com>
URL: https://gitlist.dev/e/81bfc67a0902182212h578e677ck6029c56cb86f7bce%40mail.gmail.com

```
branch gentoo.org has a file profiles/package.mask

the software that uses this supports having this be a directory as well.

I'm thinking of mv-ing this file in branch regen2.org to
profiles/package.mask/gentoo.org

since I can't change the location in gentoo.org (for mostly
non-technical reasons) when I run git merge gentoo.org from regen2.org
will git be smart enough to try to merge an updated
profiles/package.mask into profiles/package.mask/gentoo.org in the
future?

-- 
Caleb Cushing

http://xenoterracide.blogspot.com

```

## Sitaram Chamarty, 2009-02-19 14:25

Subject: Re: merge smart enough to adapt to renames?
Message-ID: <slrngpqquq.j03.sitaramc@sitaramc.homelinux.net>
URL: https://gitlist.dev/e/slrngpqquq.j03.sitaramc%40sitaramc.homelinux.net
In-Reply-To: <81bfc67a0902182212h578e677ck6029c56cb86f7bce@mail.gmail.com>

```
On 2009-02-19, Caleb Cushing <xenoterracide@gmail.com> wrote:
> branch gentoo.org has a file profiles/package.mask
>
> the software that uses this supports having this be a directory as well.
>
> I'm thinking of mv-ing this file in branch regen2.org to
> profiles/package.mask/gentoo.org
>
> since I can't change the location in gentoo.org (for mostly
> non-technical reasons) when I run git merge gentoo.org from regen2.org
> will git be smart enough to try to merge an updated
> profiles/package.mask into profiles/package.mask/gentoo.org in the
> future?

Yes.  I maintain two copies of something (in different
repos) like this...

```

## Caleb Cushing, 2009-02-19 19:58

Subject: Re: merge smart enough to adapt to renames?
Message-ID: <81bfc67a0902191158x5f0f92d1p7e4af2f9cda50a12@mail.gmail.com>
URL: https://gitlist.dev/e/81bfc67a0902191158x5f0f92d1p7e4af2f9cda50a12%40mail.gmail.com
In-Reply-To: <slrngpqquq.j03.sitaramc@sitaramc.homelinux.net>

```
> Yes.  I maintain two copies of something (in different
> repos) like this...

nice... now the real kicker if I merge from another branch
sunrise/reviewed and redirect it's package.mask to
package.mask/sunrise will git be smart enough to differentiate from
the gentoo.org one and the sunrise one? I think even more important is
how would I even tell it to do that once I've moved the first one.
-- 
Caleb Cushing

http://xenoterracide.blogspot.com

```

## Sitaram Chamarty, 2009-02-20 00:36

Subject: Re: merge smart enough to adapt to renames?
Message-ID: <slrngprunn.hbo.sitaramc@sitaramc.homelinux.net>
URL: https://gitlist.dev/e/slrngprunn.hbo.sitaramc%40sitaramc.homelinux.net
In-Reply-To: <81bfc67a0902191158x5f0f92d1p7e4af2f9cda50a12@mail.gmail.com>

```
On 2009-02-19, Caleb Cushing <xenoterracide@gmail.com> wrote:
>> Yes.  I maintain two copies of something (in different
>> repos) like this...
>
> nice... now the real kicker if I merge from another branch
> sunrise/reviewed and redirect it's package.mask to
> package.mask/sunrise will git be smart enough to differentiate from
> the gentoo.org one and the sunrise one? I think even more important is
> how would I even tell it to do that once I've moved the first one.

Not sure I understood this completely, but I've found it
helps to make the rename/move as a separate commit, then
start changing stuff.  In other words, do too many things in
the same commit, and you could lose this coolness.

There's some logic somewhere that says "if we can't find a
match to merge this file, let's see if we ever had the same
blob as the parent of the file in the MERGE_HEAD and we'll
use that as a base to do the merge".

```

## Caleb Cushing, 2009-02-20 02:17

Subject: Re: merge smart enough to adapt to renames?
Message-ID: <81bfc67a0902191817u11361d0bw1f2215a53e284f8f@mail.gmail.com>
URL: https://gitlist.dev/e/81bfc67a0902191817u11361d0bw1f2215a53e284f8f%40mail.gmail.com
In-Reply-To: <slrngprunn.hbo.sitaramc@sitaramc.homelinux.net>

```
> Not sure I understood this completely, but I've found it
> helps to make the rename/move as a separate commit, then
> start changing stuff.  In other words, do too many things in
> the same commit, and you could lose this coolness.

well I the problem is.. in a sense I need to unmerge 2 files that I
once merged... they currently have the same name and are in the same
place, and where I merge them from they'll continue to have that  name
(although they are different files with the same purpose) but I want
them to have different names and spots in my tree/repo.

-- 
Caleb Cushing

http://xenoterracide.blogspot.com

```

## Rogan Dawes, 2009-02-20 07:24

Subject: Re: merge smart enough to adapt to renames?
Message-ID: <499E5A9C.6090900@dawes.za.net>
URL: https://gitlist.dev/e/499E5A9C.6090900%40dawes.za.net
In-Reply-To: <81bfc67a0902191817u11361d0bw1f2215a53e284f8f@mail.gmail.com>

```
Caleb Cushing wrote:
>> Not sure I understood this completely, but I've found it
>> helps to make the rename/move as a separate commit, then
>> start changing stuff.  In other words, do too many things in
>> the same commit, and you could lose this coolness.
> 
> well I the problem is.. in a sense I need to unmerge 2 files that I
> once merged... they currently have the same name and are in the same
> place, and where I merge them from they'll continue to have that  name
> (although they are different files with the same purpose) but I want
> them to have different names and spots in my tree/repo.
> 

Not having done this myself, I'd take this following suggestion with a
grain of salt! :-)

It seems to me that git is smart enough to figure out where contents get
moved to, once. Of course, if you have conflicting moves in the same
repo, git's automation falls down. So, if you need to move the "same"
file in different repositories to different places, you need to do it
via an intermediate repo that will be able to "remember" which movement
you chose.

e.g.
upstream A:
data <- contains one set of data

upstream B:
data <- contains another set of data

pull upstream A into intermediate A, move the file as desired, and commit:
Intermediate A:
data/upstreamA

pull upstream B into intermediate B, move the file as desired, and commit:
Intermediate B:
data/upstreamB

merge Intermediate A and Intermediate B in master:
master:
data/upstreamA
data/upstreamB

Then, subsequent pulling from upstream A into Intermediate A will
"remember" the move of "data" to "data/upstreamA", and similarly with B.
Subsequent merges of Intermediates A & B into master will end in the
desied result.

Hope this helps.

Rogan

```

## Kris Shannon, 2009-02-21 04:48

Subject: Re: merge smart enough to adapt to renames?
Message-ID: <e51f4f550902202048g9a210f0t8fefaee4d8376f6c@mail.gmail.com>
URL: https://gitlist.dev/e/e51f4f550902202048g9a210f0t8fefaee4d8376f6c%40mail.gmail.com
In-Reply-To: <499E5A9C.6090900@dawes.za.net>

```
Rogan Dawes wrote:
> It seems to me that git is smart enough to figure out where contents get
> moved to, once. Of course, if you have conflicting moves in the same
> repo, git's automation falls down. So, if you need to move the "same"
> file in different repositories to different places, you need to do it
> via an intermediate repo that will be able to "remember" which movement
> you chose.

You don't need a whole different repo,  branches are good enough.

git checkout gentoo-integration
git pull gentoo

git checkout sunrise-integration
git pull sunrise

git checkout master
git merge gentoo
git merge sunrise

The integration branches can remember your local changes to
the remotes (like the move of packages.mask)

```

## Rogan Dawes, 2009-02-21 11:12

Subject: Re: merge smart enough to adapt to renames?
Message-ID: <499FE1A5.9020301@dawes.za.net>
URL: https://gitlist.dev/e/499FE1A5.9020301%40dawes.za.net
In-Reply-To: <e51f4f550902202048g9a210f0t8fefaee4d8376f6c@mail.gmail.com>

```
Kris Shannon wrote:
> Rogan Dawes wrote:
>> It seems to me that git is smart enough to figure out where contents get
>> moved to, once. Of course, if you have conflicting moves in the same
>> repo, git's automation falls down. So, if you need to move the "same"
>> file in different repositories to different places, you need to do it
>> via an intermediate repo that will be able to "remember" which movement
>> you chose.
> 
> You don't need a whole different repo,  branches are good enough.
> 

Yes, of course.

Rogan

```

## Caleb Cushing, 2009-02-22 01:00

Subject: Re: merge smart enough to adapt to renames?
Message-ID: <81bfc67a0902211700m7a0d0ae8jd17a871ba102fd9f@mail.gmail.com>
URL: https://gitlist.dev/e/81bfc67a0902211700m7a0d0ae8jd17a871ba102fd9f%40mail.gmail.com
In-Reply-To: <e51f4f550902202048g9a210f0t8fefaee4d8376f6c@mail.gmail.com>

```
On Fri, Feb 20, 2009 at 11:48 PM, Kris Shannon <kris@shannon.id.au> wrote:
> Rogan Dawes wrote:
>> It seems to me that git is smart enough to figure out where contents get
>> moved to, once. Of course, if you have conflicting moves in the same
>> repo, git's automation falls down. So, if you need to move the "same"
>> file in different repositories to different places, you need to do it
>> via an intermediate repo that will be able to "remember" which movement
>> you chose.
>
> You don't need a whole different repo,  branches are good enough.
>
> git checkout gentoo-integration
> git pull gentoo
>
> git checkout sunrise-integration
> git pull sunrise
>
> git checkout master
> git merge gentoo
> git merge sunrise
>
> The integration branches can remember your local changes to
> the remotes (like the move of packages.mask)
>

it sounds like a decent plan on paper... but when you realize each
checkout is 100,000+ files...to where as if I create a repo just for
it... it ends up being like 5 files... and I'm not entirely sure that
has much of a negative side effect... other than... yet another
remote...

-- 
Caleb Cushing

http://xenoterracide.blogspot.com

```

## Rogan Dawes, 2009-02-22 17:13

Subject: Re: merge smart enough to adapt to renames?
Message-ID: <49A187CD.2020403@dawes.za.net>
URL: https://gitlist.dev/e/49A187CD.2020403%40dawes.za.net
In-Reply-To: <81bfc67a0902211700m7a0d0ae8jd17a871ba102fd9f@mail.gmail.com>

```
Caleb Cushing wrote:
> On Fri, Feb 20, 2009 at 11:48 PM, Kris Shannon <kris@shannon.id.au> wrote:
>> Rogan Dawes wrote:
>>> It seems to me that git is smart enough to figure out where contents get
>>> moved to, once. Of course, if you have conflicting moves in the same
>>> repo, git's automation falls down. So, if you need to move the "same"
>>> file in different repositories to different places, you need to do it
>>> via an intermediate repo that will be able to "remember" which movement
>>> you chose.
>> You don't need a whole different repo,  branches are good enough.
>>
>> git checkout gentoo-integration
>> git pull gentoo
>>
>> git checkout sunrise-integration
>> git pull sunrise
>>
>> git checkout master
>> git merge gentoo
>> git merge sunrise
>>
>> The integration branches can remember your local changes to
>> the remotes (like the move of packages.mask)
>>
> 
> it sounds like a decent plan on paper... but when you realize each
> checkout is 100,000+ files...to where as if I create a repo just for
> it... it ends up being like 5 files... and I'm not entirely sure that
> has much of a negative side effect... other than... yet another
> remote...
> 

Well, if you use an "integration branch", rather than a whole separate
repository, that should simplify things, I think.

And, if the differences between the branches are limited to those 5
files, a checkout (if you even really need to check it out) will only
update those files that are different between the branches. It may even
be possible to do an "in index" merge, without even having a checkout,
if there are no conflicts.

Rogan

```
