Force Confirmation for Dropping Changed Lines

4 messages, 2 authors, 2017-01-25 · open the first message on its own page

Force Confirmation for Dropping Changed Lines

From: Hilco Wijbenga <hidden>
Date: 2017-01-25 22:16:51

Hi all,

Most of the time, when a later commit changes a line in an identical
fashion during, say, a rebase, you want Git to silently continue by
dropping the duplicate change from the later commit. I have a common
(for me) scenario where I want Git to specifically ask me to resolve
this "conflict" myself instead of simply assuming that the change has
already been applied.

Let's say I have a file my-code.x that starts with a line indicating
its version:

===== my-code.x =====
VERSION=1.2
line 1
line 2
line 3
=====

In my branch my-branch off of master, I make a change:

===== my-code.x =====
VERSION=1.3
line 1
line 2
line 2a
line 3
=====

Now someone else makes a different change on master and pushes it ([1]):

===== my-code.x =====
VERSION=1.3
line 1
line 2
line 3
line 4
=====

When I rebase my-branch onto origin/master, I get no conflicts and
everything seems fine ([2]):

===== my-code.x =====
VERSION=1.3
line 1
line 2
line 2a
line 3
line 4
=====

Except that I should have used VERSION=1.4, not VERSION=1.3 because I
made a change to my-code.x. Obviously, for a single file this is easy
to remember/check but when it's hidden among lots of files and commits
it becomes very hard to find these types of errors.

How can I force Git to not assume my change to the first line is "redundant"?

Cheers,
Hilco

[1] Note that this someone is (correctly) using the same, new version of 1.3.
[2] If my example is actually incorrect, then please just pretend
there are no conflicts.

Re: Force Confirmation for Dropping Changed Lines

From: Jacob Keller <hidden>
Date: 2017-01-25 22:25:10

On Wed, Jan 25, 2017 at 2:16 PM, Hilco Wijbenga
[off-list ref] wrote:
How can I force Git to not assume my change to the first line is "redundant"?
My guess is that you probably want a custom merge driver for your file
types. That's where I would look initially.

Thanks,
Jake
Cheers,
Hilco

[1] Note that this someone is (correctly) using the same, new version of 1.3.
[2] If my example is actually incorrect, then please just pretend
there are no conflicts.

Re: Force Confirmation for Dropping Changed Lines

From: Hilco Wijbenga <hidden>
Date: 2017-01-25 22:52:15

On 25 January 2017 at 14:24, Jacob Keller [off-list ref] wrote:
On Wed, Jan 25, 2017 at 2:16 PM, Hilco Wijbenga
[off-list ref] wrote:
quoted
How can I force Git to not assume my change to the first line is "redundant"?
My guess is that you probably want a custom merge driver for your file
types. That's where I would look initially.
Mmm, that sounds complex. The "my-code.x" is made up so I could keep
my example as simple as possible. In reality, it's Maven's POM files
(pom.xml).

So there is no setting for any of this? There is no way to switch off
auto merging for certain files?

Re: Force Confirmation for Dropping Changed Lines

From: Jacob Keller <hidden>
Date: 2017-01-25 22:54:34

On Wed, Jan 25, 2017 at 2:51 PM, Hilco Wijbenga
[off-list ref] wrote:
On 25 January 2017 at 14:24, Jacob Keller [off-list ref] wrote:
quoted
On Wed, Jan 25, 2017 at 2:16 PM, Hilco Wijbenga
[off-list ref] wrote:
quoted
How can I force Git to not assume my change to the first line is "redundant"?
My guess is that you probably want a custom merge driver for your file
types. That's where I would look initially.
Mmm, that sounds complex. The "my-code.x" is made up so I could keep
my example as simple as possible. In reality, it's Maven's POM files
(pom.xml).

So there is no setting for any of this? There is no way to switch off
auto merging for certain files?
Not really sure, but a quick google search revealed
https://github.com/ralfth/pom-merge-driver

Maybe that will help you?

Thanks,
Jake
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help