Re: Git, merging, and News/Relnotes files

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

 




On Sat, 5 Jul 2008, Edward Z. Yang wrote:
> 
> Something that I've noticed recently, as we've started migrating away
> from the ghetto SVN development model to the Git branchy model, is that
> this NEWS file ends up being the source of a lot of conflicts. Granted,
> they're easy conflicts to resolve, but still, they make a pull a little
> more complicated than it should be.

I don't think anybody really _uses_ the functionality, but git does have 
the capability to specify special merge drivers based on filenames.

So you can

 (a) create a merge strategy that automaticaly does what you want. There's 
     a built-in driver called "union" that may or may not work for your 
     use case.

     See "Defining a custom merge driver" in "man gitattributes" for more 
     details about this.

 (b) Say which files you want to merge with this driver, by having 
     something like

	NEWS merge=news-merge

     in your .gitattributes file (or in ".git/info/attributes", if you 
     want to keep this all private to your own setup rather than in a 
     committed file that gets distributed to everybody else too).

and now your NEWS file will be merged using your special "news-merge" 
custom merge function.

Of course, the custom merge driver is only done for non-trivial merges. 
Git will do all the trivial fast-forward merges on its own, and only call 
the custom merge driver for things that have actual possible data 
conflicts (ie changes in both branches).

NOTE! Keeping an ordered list (like a ChangeLog or a NEWS file) is 
fundamentally not an easy thing to do in a distributed environment. The 
"union" merge strategy may well work for you (and if it does, this is all 
going to be very easy), but it's also entirely possible that you will find 
that the ordering in a distributed environment is so unspecified, you'll 
prefer to do the merges by hand _anyway_ in the end.

So the first thing you should do is probably to just *try* adding that

	NEWS merge=union

line to your .gitattributes file, and see if it works for you. My personal 
guess is that you'll realize that you really prefer doing the trivial 
merges manually after all, but hey, maybe not. And as mentioned, you *can* 
create your very own merge strategy that knows about the particular rules 
of the files in question, but that gets more complex.

For example, the default 'union' merge will literally _duplicate_ 
identical that were added in both branches. So if you cherry-pick a commit 
so that it exists both in the branch you are merging _and_ the branch you 
are merging into, then any additions to the NEWS file will basically show 
up twice, and yet auto-merge "cleanly".

Which is very understandable, but is almost certainly not what you want.

			Linus
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[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]

  Powered by Linux