From: Junio C Hamano <gitster@pobox.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: "Laďa Tesařík" <lada.tesarik@olc.cz>,
"git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: Lost file after git merge
Date: Thu, 28 Jul 2022 10:11:00 -0700 [thread overview]
Message-ID: <xmqqilnhcgd7.fsf@gitster.g> (raw)
In-Reply-To: <220728.865yjhl8wk.gmgdl@evledraar.gmail.com> ("Ævar Arnfjörð Bjarmason"'s message of "Thu, 28 Jul 2022 14:17:51 +0200")
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
> On Thu, Jul 28 2022, Laďa Tesařík wrote:
>
>> 1. I added a file called 'new_file' to a master branch.
>> 2. Then I created branch feature/2 and deleted the file in master
>> 3. Then I deleted the file in branch feature/2 as well.
>> 4. I created 'new_file' on branch feature/2 again.
It heavily depends on how this creation is done, i.e. what went into
the created file. Imagine that a file existed with content A at
commit 0, both commits 1 and 2 removed it on their forked history,
and then commit 3 added exactly the same content A to the same path:
1---3
/ \
----0---2---4---->
When you are about to merge 2 and 3 to create 4, what would a
three-way merge see?
0 had content A at path P
2 said "no we do not want content A at path P"
3 said "we are happy with content A at path P"
So the net result is that 0-->3 "one side did not touch A at P" and
0-->2 "one side removed A at P".
Three-way merge between X and Y is all about taking what X did if Y
didn't have any opinion on what X touched. This is exactly that
case. The history 0--->3 didn't have any opinion on what should be
in P or whether P should exist, and that is why there is no change
between these two endpoints. The history 0--->2 does care---it feels
that it is detrimental to the project to have P hence it removed.
So the end result will remove P, if 3 added identical content as
existed at 0 and removed at 1.
If 3 added something different, then the picture becomes entirely
different. The history 0--->3 no longer has "no opinion". It
strongly believes that P having content A at 0 was wrong, and it
should have content B, hence it changed it. Now when that opinion
collides with the opinion of the history 0--->2 that says it is
wrong to have content A at path P, the person who is creating the
merge at 4 needs to think and resolve.
next prev parent reply other threads:[~2022-07-28 17:11 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-28 8:23 Lost file after git merge Laďa Tesařík
2022-07-28 12:17 ` Ævar Arnfjörð Bjarmason
2022-07-28 17:11 ` Junio C Hamano [this message]
2022-07-29 20:23 ` René Scharfe
2022-07-29 22:04 ` Junio C Hamano
2022-07-30 2:16 ` Elijah Newren
2022-07-30 14:44 ` René Scharfe
2022-07-31 1:45 ` Elijah Newren
2022-07-28 21:23 ` brian m. carlson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqilnhcgd7.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=lada.tesarik@olc.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.