git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Johnathon Wright <jw@mustmodify.com>
To: git@vger.kernel.org
Subject: Please explain why this merge ignored changes from one branch in favor of another rather than showing a conflict
Date: Sat, 24 Oct 2020 17:06:40 -0400	[thread overview]
Message-ID: <CAD6JFnNX03MLBSUjdTjvK1TsBR-sntqgXMDKR9z2OjdUKBERKQ@mail.gmail.com> (raw)

Your Excellencies:

I'm a new tech lead trying to figure out what caused a significant
production issue. I want to know why the merge described below
discards the content of a certain file from one branch and uses
content from another branch, while saying that the file was "added by
them". More importantly, I want to know how to prevent this in the
future.

DETAILS

A dev wrote a feature across many files, including
app/events/checkout_event.rb. Once merged and deployed, it was
discovered that his changes to that file didn't make it to
production... but many other changes from the same commit(s) did make
it.

After much research, we have isolated the issue to a specific ref -- a
merge. It appears that, during the merge where both branches had
changed that file, git decided to throw out changes to a from one
branch and to use the other branch.

I created three tags so my small brain didn't have to remember refs:
* "working" (aa29d0f4)
* other_parent (7f9ebfa5).
* broken (ccbeb88)

----
jw@logopolis:/projects/unity/atlantis$ git show broken

commit cbbeb883428a468e9c906c646becdf751ecff99a (broken)
Merge: 7f9ebfa5 aa29d0f4
Author: Johnathon Wright <jw@mustmodify.com>
Date:   Fri Oct 16 13:17:43 2020 -0400

    merge

...
----

'git show broken' doesn't show any changes to the file in question.

Here, you can see that the files were different:

----
jw@logopolis:/projects/unity/atlantis$ git ls-tree working
app/events/checkout_event.rb

100644 blob 077013dc52f03b336143b892c1468516cae29dce
app/events/checkout_event.rb
----

and

----
jw@logopolis:/projects/unity/atlantis$ git ls-tree other_parent
app/events/checkout_event.rb

100644 blob 21b3d4e9b5ac4903c2aadbed28ab5b60eb77e8ce
app/events/checkout_event.rb
-----

Then I tried to reproduce the merge:

----
jw@logopolis:/projects/unity/atlantis$ git checkout working

HEAD is now at aa29d0f4 Track instances of price changing

jw@logopolis:/projects/unity/atlantis$ git merge other_parent

CONFLICT (rename/delete): spec/events/single_payment_event_spec.rb
deleted in HEAD and renamed to spec/events/checkout_event_spec.rb in
other_parent. Version other_parent of
spec/events/checkout_event_spec.rb left in tree.
Removing spec/commands/generate_ticket_and_send_command_spec.rb
Auto-merging db/schema.rb
CONFLICT (content): Merge conflict in db/schema.rb
Auto-merging config/routes.rb
Auto-merging app/models/user.rb
CONFLICT (rename/delete): app/events/single_payment_event.rb deleted
in HEAD and renamed to app/events/checkout_event.rb in other_parent.
Version other_parent of app/events/checkout_event.rb left in tree.
Auto-merging app/controllers/products_controller.rb
Auto-merging app/controllers/priceline/price_points_controller.rb
Automatic merge failed; fix conflicts and then commit the result.


jw@logopolis:/projects/unity/atlantis$ git status

HEAD detached at working
You have unmerged paths.
  (fix conflicts and run "git commit")
  (use "git merge --abort" to abort the merge)

Changes to be committed:

        new file:   app/controllers/criteria_sets_controller.rb
        modified:   app/controllers/priceline/price_points_controller.rb
        modified:   app/controllers/products_controller.rb
        modified:   app/events/search_hotels_event.rb
        modified:   app/forms/search_hotels_form.rb
        modified:   app/interfaces/priceline_api.rb
        modified:   app/models/priceline/criteria_set.rb
        modified:   app/models/user.rb
        modified:   app/queries/hotels_filter_query.rb
        new file:   app/views/products/waiting.html.erb
        modified:   app/workers/generate_booking_ticket_worker.rb
        modified:   app/workers/update_priceline_hotels_worker.rb
        modified:   config/routes.rb
        new file:
db/migrate/20201009200507_add_timestamps_to_pl_criteria_sets.rb
        new file:
db/migrate/20201009235952_add_completion_flag_to_criteria_sets.rb
        deleted:    spec/commands/generate_ticket_and_send_command_spec.rb
        modified:   spec/forms/search_hotels_form_spec.rb

Unmerged paths:
  (use "git add <file>..." to mark resolution)

        added by them:   app/events/checkout_event.rb
        both modified:   db/schema.rb
        added by them:   spec/events/checkout_event_spec.rb
----

note that even though app/events/checkout_event.rb exists in both the
"working" and "other_parent" branches, git here says "added by them".

Note that "working" and "other_parent" both have parent nodes which
rename the file in question from something else TO
app/events/checkout_event.rb (same for the spec.) The two ancestors
have different refs but the same datetime and commit message.

This might also be of interest, or perhaps not.

----
jw@logopolis:/projects/unity/atlantis$ git diff working..broken --
app/events/checkout_event.rb | grep "^-" | wc -l

158

jw@logopolis:/projects/unity/atlantis$ git diff working..broken --
app/events/checkout_event.rb | grep "^+" | wc -l

51
----

Final bit of information:

----
jw@logopolis:/projects/unity/atlantis$ git --version

git version 2.17.1
----

So, why does git say that this file was "added by them" instead of
saying it had a conflict that needed merging?

It has been suggested that this might have something to do with some
team members using merge and others using rebase. Or possibly rebasing
shared history. I don't know how to determine whether that's the case
or whether that might have caused this.

If so, I would appreciate seeing a set of instructions from a blank
repo that cause this same thing to happen, so that I can help my team
to understand the situation and how it can be avoided.

If it is not related to rebasing and then merging, any help would be
appreciated in diagnosing this issue.

Thanks,

jw

             reply	other threads:[~2020-10-24 21:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-24 21:06 Johnathon Wright [this message]
2020-10-25  0:05 ` Please explain why this merge ignored changes from one branch in favor of another rather than showing a conflict Elijah Newren

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAD6JFnNX03MLBSUjdTjvK1TsBR-sntqgXMDKR9z2OjdUKBERKQ@mail.gmail.com \
    --to=jw@mustmodify.com \
    --cc=git@vger.kernel.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).