Reputation:
I'm attempting to merge master branch into new-branch.
I noticed git seems to be eating relevant lines in the output conflicted merged file. What should i be doing differently to achieve the expected output of retaining the DB::select line with the stored proc call? Why is it disappearing?
user@devbox /w/r/a/C/Commands (master)> git branch
new-branch
* master
The call line exists in MyFile.php in the master branch:
user@devbox /w/r/a/C/Commands (master) [2]> grep call MyFile.php
DB::select("call mysql_stored_proc(?)",[$docId]);
user@devbox /w/r/a/C/Commands (master)> git switch new-branch
Switched to branch 'new-branch'
Your branch is up to date with 'origin/new-branch'.
The call line DOES NOT exist in MyFile.php in new-branch, just an old comment:
user@devbox /w/r/a/C/Commands (new-branch)> grep call MyFile.php
//DB::select("call mysql_stored_proc(?)", [$opts['item']]); // FIXME: uncomment when sql stored process is fixed
Merge master branch into new-branch:
user@devbox /w/r/a/C/Commands (new-branch)> git merge master
Auto-merging public/js/app.js
CONFLICT (content): Merge conflict in public/js/app.js
...
Auto-merging app/Console/Commands/MyFile.php
CONFLICT (content): Merge conflict in app/Console/Commands/MyFile.php
Automatic merge failed; fix conflicts and then commit the result.
After merge new call line does not exist in the merged file, only the old commented line:
user@devbox /w/r/a/C/Commands (new-branch|MERGING) [1]> grep call MyFile.php
//DB::select("call mysql_stored_proc(?)", [$opts['item']]); // FIXME: uncomment when sql stored process is fixed
Check the diff, it shows it should be added "+ DB::select("call mysql_stored_proc(?)",[$docId]);"
user@devbox /w/r/a/C/Commands (new-branch|MERGING)> git diff new-branch master -- MyFile.php
- try
- {
- $opts = json_decode($taskManager->ts_options, true);
- $doc = Doc::find($opts['item']);
-
- //DB::select("call mysql_stored_proc(?)", [$opts['item']]); // FIXME: uncomment when sql stored process is fixed
-
+ $options = json_decode($taskManager->ts_options, true);
+ $docId = $options['item'];
+ $user = $options['user'];
+ try{
+ $doc = Doc::find($docId);
+ DB::select("call mysql_stored_proc(?)",[$docId]);
$rows = DB::table('items_table')
- ->select(DB::raw(department AS 'Department', description AS 'Descrption', effective_date AS 'EffectiveDate', expiry_date AS 'ExpiryDate'"))
- ->get()
- ->groupBy('Department');
user@devbox /w/r/a/C/Commands (new-branch|MERGING)>
Why is it missing?
Upvotes: 1
Views: 810
Reputation: 489828
You showed us extracts from two files in two branch-tip commits. You have not shown us the corresponding file (or extracts from it) in the merge base. Without this, we can't say whether Git is operating correctly.
Bugs this deep in the Git merge code are pretty rare, though, so probably Git is operating correctly. It's likely that the lack of your DB::select("call mysql_stored_proc(?)",[$docId]);
in the merge result is because:
and therefore Git took their change, which was to comment out the line.
It's also likely, given that you think the line should be there, that Git got this result by mis-comparing the files. That is, some bogus match-up made Git think that you didn't touch the line and they did, and that there was a conflict somewhere else. But if Git hadn't made the bogus match-up, Git would think both you and they did touch the line, and see that they deleted some other commented-out line (which is where you might now see the conflict).
Remember, Git does not understand the code. Git is merely applying textual substitution rules. Git ran:
git diff --find-renames <hash-of-merge-base> <your-tip-commit>
to see what you changed, and:
git diff --find-renames <hash-of-merge-base> <their-tip-commit>
to see what they changed. Find the hash of the merge base:
git merge-base --all my-branch their-branch
(if this spits out multiple hash IDs, you have a "recursive merge" case which is much more complicated), then run the two git diff
s yourself, perhaps limiting these to the files that Git is having problems with. That way, you can see what Git saw, and hence what led it to merge them this way.
Upvotes: 3