git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Trouble with file specific merge strategies
@ 2012-03-10 23:47 suvayu ali
  2012-03-11  8:57 ` Junio C Hamano
  0 siblings, 1 reply; 7+ messages in thread
From: suvayu ali @ 2012-03-10 23:47 UTC (permalink / raw)
  To: git

Hi git devs,

I have a repo with two branches where some files are absent in one of
the branches. Say the two branches are <allfiles> and <somefiles>. Until now
I was using

$ git merge -s ours <allfiles> # with <somefiles> checked out

to merge commits which touches the absent files. But this clutters up
history and is very inconvenient to do sometimes. So when I came across
the possibility of using .gitattributes for file specific merge
strategies, I tried the following:

pattern merge=ours

However I get the following conflict message:

CONFLICT (rename/delete): org-mode-config.el deleted in HEAD and
renamed in 74288bb. Version 74288bb of org-mode-config.el left in
tree.

This file was deleted from <somefiles> in the past[1] and was renamed in
<allfiles> since the last merge. I was expecting this file to be ignored
(or in other words, merged with ours) since the .gitattributes file has
entries like these:

org-mode-config.el	   merge=ours  # new name in allfiles branch
lisp/org-mode-settings.el  merge=ours  # old name deleted in somefiles

I also see other new files in <allfiles> which are mentioned in
.gitattributes being merged in <somefiles>.

$ git status -sb
## somefiles
M  abbrev_defs
A  cpp-config.el
A  email-config.el                 # <-- this should be ignored
A  gui-config.el                   # <-- this should be ignored
UU init.el
A  keybindings.el
M  lisp/skeletons.el
D  lisp/text-mode-like-settings.el
UA org-mode-config.el              # <-- this should be ignored
A  text-mode-config.el

What am I doing wrong here? My git version is 1.7.7.6.

Thanks in advance,


Footnotes:

[1] There has been several successful merges since then.

-- 
Suvayu

Open source is the future. It sets us free.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Trouble with file specific merge strategies
  2012-03-10 23:47 Trouble with file specific merge strategies suvayu ali
@ 2012-03-11  8:57 ` Junio C Hamano
  2012-03-11 10:10   ` suvayu ali
  0 siblings, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2012-03-11  8:57 UTC (permalink / raw)
  To: suvayu ali; +Cc: git

suvayu ali <fatkasuvayu+linux@gmail.com> writes:

> ... So when I came across
> the possibility of using .gitattributes for file specific merge
> strategies, I tried the following:
>
> pattern merge=ours

I do not think we say .gitattributes can give merge strategy
anywhere in our document.

You can choose one of the few built-in merge drivers but "ours" is
not one of them.  Have you defined your own merge driver "ours"
following the example in the gitattributes documentation (look for
"feel-free merge driver")?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Trouble with file specific merge strategies
  2012-03-11  8:57 ` Junio C Hamano
@ 2012-03-11 10:10   ` suvayu ali
  2012-03-11 11:18     ` Junio C Hamano
  0 siblings, 1 reply; 7+ messages in thread
From: suvayu ali @ 2012-03-11 10:10 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Hi Junio,

On Sun, Mar 11, 2012 at 09:57, Junio C Hamano <gitster@pobox.com> wrote:
> suvayu ali <fatkasuvayu+linux@gmail.com> writes:
>
>> ... So when I came across
>> the possibility of using .gitattributes for file specific merge
>> strategies, I tried the following:
>>
>> pattern merge=ours
>
> I do not think we say .gitattributes can give merge strategy
> anywhere in our document.
>
> You can choose one of the few built-in merge drivers but "ours" is
> not one of them.  Have you defined your own merge driver "ours"
> following the example in the gitattributes documentation (look for
> "feel-free merge driver")?

Ah, that explains it. You are absolutely correct in saying that the
docs don't imply this. I was having doubts about this while reading the
docs (man gitattributes). I got confused by this[1] example on progit
and several pointers to it on stackoverflow. And no, I don't have a
custom merge driver.

This brings up the question, is that discussion on progit talking about
something else? Is there a way to setup file specific merge strategies
in a repo?

Thanks a lot for your response. :)

Cheers,

Footnotes:

[1] http://progit.org/book/ch7-2.html#merge_strategies

-- 
Suvayu

Open source is the future. It sets us free.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Trouble with file specific merge strategies
  2012-03-11 10:10   ` suvayu ali
@ 2012-03-11 11:18     ` Junio C Hamano
  2012-03-11 11:27       ` suvayu ali
  2012-03-11 15:17       ` Thomas Hochstein
  0 siblings, 2 replies; 7+ messages in thread
From: Junio C Hamano @ 2012-03-11 11:18 UTC (permalink / raw)
  To: suvayu ali; +Cc: git

suvayu ali <fatkasuvayu+linux@gmail.com> writes:

> ... is that discussion on progit talking about
> something else?

Sorry, I do not read or write progit, so I do not know offhand what
it says in the section you read and I cannot judge if it was you who
misread, or if it was book that misspoke.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Trouble with file specific merge strategies
  2012-03-11 11:18     ` Junio C Hamano
@ 2012-03-11 11:27       ` suvayu ali
  2012-03-11 15:17       ` Thomas Hochstein
  1 sibling, 0 replies; 7+ messages in thread
From: suvayu ali @ 2012-03-11 11:27 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Hi Junio,

On Sun, Mar 11, 2012 at 12:18, Junio C Hamano <gitster@pobox.com> wrote:
> suvayu ali <fatkasuvayu+linux@gmail.com> writes:
>
>> ... is that discussion on progit talking about
>> something else?
>
> Sorry, I do not read or write progit, so I do not know offhand what
> it says in the section you read and I cannot judge if it was you who
> misread, or if it was book that misspoke.
>

Okay, thanks. I'll switch back to the tried and tested,

$ git merge -s ours

I'll take up the progit issue on the relevant discussion boards.

-- 
Suvayu

Open source is the future. It sets us free.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Trouble with file specific merge strategies
  2012-03-11 11:18     ` Junio C Hamano
  2012-03-11 11:27       ` suvayu ali
@ 2012-03-11 15:17       ` Thomas Hochstein
  2012-03-11 18:01         ` suvayu ali
  1 sibling, 1 reply; 7+ messages in thread
From: Thomas Hochstein @ 2012-03-11 15:17 UTC (permalink / raw)
  To: git

Junio C Hamano wrote:

> suvayu ali <fatkasuvayu+linux@gmail.com> writes:
>
>> ... is that discussion on progit talking about
>> something else?
>
> Sorry, I do not read or write progit, so I do not know offhand what
> it says in the section you read and I cannot judge if it was you who
> misread, or if it was book that misspoke.

The book says:
> You can also use Git attributes to tell Git to use different merge
> strategies for specific files in your project. One very useful option
> is to tell Git to not try to merge specific files when they have
> conflicts, but rather to use your side of the merge over someone
> else’s.
>
> This is helpful if a branch in your project has diverged or is
> specialized, but you want to be able to merge changes back in from
> it, and you want to ignore certain files. Say you have a database
> settings file called database.xml that is different in two branches,
> and you want to merge in your other branch without messing up the
> database file. You can set up an attribute like this:
>
>| database.xml merge=ours
>
> If you merge in the other branch, instead of having merge conflicts
> with the database.xml file, you see something like this:
>
>| $ git merge topic
>| Auto-merging database.xml
>| Merge made by recursive.
>
> In this case, database.xml stays at whatever version you originally had.

That seems to be incorrect, as far as I understand the gitattributes
man page.

-thh

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Trouble with file specific merge strategies
  2012-03-11 15:17       ` Thomas Hochstein
@ 2012-03-11 18:01         ` suvayu ali
  0 siblings, 0 replies; 7+ messages in thread
From: suvayu ali @ 2012-03-11 18:01 UTC (permalink / raw)
  To: Thomas Hochstein; +Cc: git

Hello Thomas,

On Sun, Mar 11, 2012 at 16:17, Thomas Hochstein <thh@inter.net> wrote:
> Junio C Hamano wrote:
>
>> suvayu ali <fatkasuvayu+linux@gmail.com> writes:
>>
>>> ... is that discussion on progit talking about
>>> something else?
>>
>> Sorry, I do not read or write progit, so I do not know offhand what
>> it says in the section you read and I cannot judge if it was you who
>> misread, or if it was book that misspoke.
>
> The book says:
>> You can also use Git attributes to tell Git to use different merge
>> strategies for specific files in your project. One very useful option
>> is to tell Git to not try to merge specific files when they have
>> conflicts, but rather to use your side of the merge over someone
>> else’s.
>>
>> This is helpful if a branch in your project has diverged or is
>> specialized, but you want to be able to merge changes back in from
>> it, and you want to ignore certain files. Say you have a database
>> settings file called database.xml that is different in two branches,
>> and you want to merge in your other branch without messing up the
>> database file. You can set up an attribute like this:
>>
>>| database.xml merge=ours
>>
>> If you merge in the other branch, instead of having merge conflicts
>> with the database.xml file, you see something like this:
>>
>>| $ git merge topic
>>| Auto-merging database.xml
>>| Merge made by recursive.
>>
>> In this case, database.xml stays at whatever version you originally had.
>
> That seems to be incorrect, as far as I understand the gitattributes
> man page.
>

Thank you for confirming the error. I have opened a ticket on the progit
repo on github. If you are interested, you can follow it on the page
linked below.

<https://github.com/progit/progit.github.com/issues/5>

Cheers,

-- 
Suvayu

Open source is the future. It sets us free.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-03-11 18:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-10 23:47 Trouble with file specific merge strategies suvayu ali
2012-03-11  8:57 ` Junio C Hamano
2012-03-11 10:10   ` suvayu ali
2012-03-11 11:18     ` Junio C Hamano
2012-03-11 11:27       ` suvayu ali
2012-03-11 15:17       ` Thomas Hochstein
2012-03-11 18:01         ` suvayu ali

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).