# force "unmerged" for same-file auto-merges

5 messages from 2010-03-24 to 2010-03-27. Participants: Neal Kreitzinger, Junio C Hamano, Sitaram Chamarty, Dilip M.
Thread: https://gitlist.dev/t/23158

## Neal Kreitzinger, 2010-03-24 01:44

Subject: force "unmerged" for same-file auto-merges
Message-ID: <hobqoc$5h3$1@dough.gmane.org>
URL: https://gitlist.dev/e/hobqoc%245h3%241%40dough.gmane.org

```
Scenario:  "same-file auto-merge":  when two different people change the 
same file in their separate repos.  Their changes do not conflict in the 
sense that they are changes to the same lines.  However, their changes do 
conflict in the sense that the resulting merged logic is incorrect.

Concern:
The same-file auto-merge results are overlooked (not reviewed) by the 
programmer because there is nothing preventing a git-commit immediately 
after the auto-merge completes.

Desired Solution:
Perform same-file auto-merge and produce auto-merge results, but mark all 
such auto-merged files as "unmerged" so that they must be reviewed/resolved 
before a git-commit.  The "unmerged" status allows git-mergetool to be run 
(e.g. kdiff3) so that the merged lines can be reviewed.  In this way, all 
auto-merged files are reviewed.

Does anyone know if there are configuration and/or command-line options in 
git that can accomplish this in a fairly straightforward manner?  For 
example, something like this:


Example config:
$ cat gitconfig
[merge]
            samefileauto = forceconflict


Example command:
$ git merge -s sameautoforceconflict branchx


Example results:
$ git merge -s sameautoforceconflict branchx
Merging:
11a99zz examplecommitb
virtual branchx
found 1 common ancestor(s):
22b88yy examplecommita
Auto-merging examplepgm
Merge made by recursive.
 examplepgm |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
$git status
examplepgm: needs merge
# On branch branchx
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working 
directory)
#
#       unmerged:   examplepgm
#
no changes added to commit (use "git add" and/or "git commit -a")


v/r,
Neal 

```

## Neal Kreitzinger, 2010-03-26 01:04

Subject: Re: force "unmerged" for same-file auto-merges
Message-ID: <hoh16f$koe$1@dough.gmane.org>
URL: https://gitlist.dev/e/hoh16f%24koe%241%40dough.gmane.org
In-Reply-To: <hobqoc$5h3$1@dough.gmane.org>

```
In other words, when two people modify the same file in different places I 
want the automerge results file, but I want the resulting file marked as 
unmerged so the programmer can then run git-mergetool to review the merge 
results.  This also prevents the programmer from running git-commit 
immediately after the automerge without reviewing the merge results.  Can 
"mark automerge of samefile as 'unmerged'" be done in git via config 
settings or command options?



v/r,

Neal



"Neal Kreitzinger" <neal@rsss.com> wrote in message 
news:hobqoc$5h3$1@dough.gmane.org...
> Scenario:  "same-file auto-merge":  when two different people change the 
> same file in their separate repos.  Their changes do not conflict in the 
> sense that they are changes to the same lines.  However, their changes do 
> conflict in the sense that the resulting merged logic is incorrect.
>
> Concern:
> The same-file auto-merge results are overlooked (not reviewed) by the 
> programmer because there is nothing preventing a git-commit immediately 
> after the auto-merge completes.
>
> Desired Solution:
> Perform same-file auto-merge and produce auto-merge results, but mark all 
> such auto-merged files as "unmerged" so that they must be 
> reviewed/resolved before a git-commit.  The "unmerged" status allows 
> git-mergetool to be run (e.g. kdiff3) so that the merged lines can be 
> reviewed.  In this way, all auto-merged files are reviewed.
>
> Does anyone know if there are configuration and/or command-line options in 
> git that can accomplish this in a fairly straightforward manner?  For 
> example, something like this:
>
>
> Example config:
> $ cat gitconfig
> [merge]
>            samefileauto = forceconflict
>
>
> Example command:
> $ git merge -s sameautoforceconflict branchx
>
>
> Example results:
> $ git merge -s sameautoforceconflict branchx
> Merging:
> 11a99zz examplecommitb
> virtual branchx
> found 1 common ancestor(s):
> 22b88yy examplecommita
> Auto-merging examplepgm
> Merge made by recursive.
> examplepgm |    2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
> $git status
> examplepgm: needs merge
> # On branch branchx
> # Changed but not updated:
> #   (use "git add <file>..." to update what will be committed)
> #   (use "git checkout -- <file>..." to discard changes in working 
> directory)
> #
> #       unmerged:   examplepgm
> #
> no changes added to commit (use "git add" and/or "git commit -a")
>
>
> v/r,
> Neal
>
> 

```

## Junio C Hamano, 2010-03-26 19:29

Subject: Re: force "unmerged" for same-file auto-merges
Message-ID: <7vtys2lw4z.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vtys2lw4z.fsf%40alter.siamese.dyndns.org
In-Reply-To: <hobqoc$5h3$1@dough.gmane.org>

```
"Neal Kreitzinger" <neal@rsss.com> writes:

> Does anyone know if there are configuration and/or command-line options in 
> git that can accomplish this in a fairly straightforward manner?

I know there isn't.

Essentially what you are asking for is

    read-tree -m -u --trivial O A B

followed by no file-level automerge.  I think you can write a custom merge
strategy, perhaps using "resolve" as a template, to do that.

In practice, you will get too many false "conflicts" with such a strategy
and the quality of your "review" would degrade from fatigue, I suspect.

```

## Sitaram Chamarty, 2010-03-27 08:56

Subject: Re: force "unmerged" for same-file auto-merges
Message-ID: <2e24e5b91003270156r11ae9155s6e00a2ab27e9f479@mail.gmail.com>
URL: https://gitlist.dev/e/2e24e5b91003270156r11ae9155s6e00a2ab27e9f479%40mail.gmail.com
In-Reply-To: <hobqoc$5h3$1@dough.gmane.org>

```
On Wed, Mar 24, 2010 at 7:14 AM, Neal Kreitzinger <neal@rsss.com> wrote:
> Scenario:  "same-file auto-merge":  when two different people change the
> same file in their separate repos.  Their changes do not conflict in the
> sense that they are changes to the same lines.  However, their changes do
> conflict in the sense that the resulting merged logic is incorrect.

You're not being pessimistic enough :-)  A ".h" file that changed only
on one side can cause the same logic issues

> Desired Solution:
> Perform same-file auto-merge and produce auto-merge results, but mark all
> such auto-merged files as "unmerged" so that they must be reviewed/resolved
> before a git-commit.  The "unmerged" status allows git-mergetool to be run
> (e.g. kdiff3) so that the merged lines can be reviewed.  In this way, all
> auto-merged files are reviewed.

No.  What you need is a full blown diff for the merge, with both sides
being compared with respect to the common merge-base.  That diff will
be pretty big, although I'm not sure what diff options would actually
produce that (but I'll bet "-m" figures somewhere).

```

## Dilip M, 2010-03-27 17:22

Subject: Re: force "unmerged" for same-file auto-merges
Message-ID: <c94f8e121003271022v2b30ef52j3bd4015f12938f7a@mail.gmail.com>
URL: https://gitlist.dev/e/c94f8e121003271022v2b30ef52j3bd4015f12938f7a%40mail.gmail.com
In-Reply-To: <hoh16f$koe$1@dough.gmane.org>

```
On Fri, Mar 26, 2010 at 6:34 AM, Neal Kreitzinger <neal@rsss.com> wrote:

> In other words, when two people modify the same file in different places I
> want the automerge results file, but I want the resulting file marked as
> unmerged so the programmer can then run git-mergetool to review the merge
> results.  This also prevents the programmer from running git-commit
> immediately after the automerge without reviewing the merge results.  Can
> "mark automerge of samefile as 'unmerged'" be done in git via config
> settings or command options?

What about merge with '--no-commit' option and than doing 'diff --cached'. You
have option of still seeing what merged and decide to reset or commit.

-- 
Dilip

```
