We are trying to institute a process using git octopus merges to consolidate many topic branches for regular releases. When there is a conflict, it doesn't seem to output which branches were in conflict. Does anyone know a way to determine what branches the conflicts came from after an octopus merge?
Asked
Active
Viewed 5,828 times
1 Answers
7
The git merge
man page mentions:
octopus
This resolves cases with more than two heads, but refuses to do a complex merge that needs manual resolution. It is primarily meant to be used for bundling topic branch heads together. This is the default merge strategy when pulling or merging more than one branch.
And this thread does indeed illustrate that:
The octopus strategy cannot do merges which need manual resolution. Or so the doc says. After trying the merge with 4 2 5, Git tells you:
Trying simple merge with 7ff9b5bd514cb600bac935ebd40eae366bba7d19
Trying simple merge with 6872cd350154743d59cb4d313cbdb122ac43e537
Simple merge did not work, trying automatic merge.
Auto-merging file.txt
ERROR: content conflict in file.txt
fatal: merge program failed
Automated merge did not work.
Should not be doing an Octopus.
Merge with strategy octopus failed.
That is, it aborts the merge completely. If you "resolve" it and commit it's simply a commit that you make.

KennyLog_ins
- 157
- 1
- 15

VonC
- 1,262,500
- 529
- 4,410
- 5,250
-
Thanks, but maybe I didn't phrase my question clearly enough. What I'm looking for is a description of the branches/files in conflict. IE. Let's say I have branches a, b, c, d, e. file1 conflicts on a and c, file2 conflicts on d and e. If I try 'git merge a b c d e', I'm wondering if I can get git to tell me that those two files conflicted across those 3 branches. – Kallin Nagelberg Mar 29 '11 at 17:37
-
@Kallin: that's the problem: there won't be any branches/files to show in an octopus merge: it aborts everything in case of conflict. – VonC Mar 29 '11 at 17:39
-
That seems crazy though.. It must know where there is a conflict if it is detecting it. I would think it should be able to tell you what it knows. – Kallin Nagelberg Mar 29 '11 at 17:44
-
1@Kallin: yes, for a classic merge between two branches, but not between n branches according to the current implementation. That is why it displays "`Should not be doing an Octopus`" – VonC Mar 29 '11 at 17:48
-
OK, so let's say you had to frequently perform merges of dozens of topic branches into master.. How would you go about determining where the conflicts lie? – Kallin Nagelberg Mar 29 '11 at 17:52
-
2@Kallin: I would perform the merges one by one on the destination branch, solving the conflict as they go, then once all the merges are done (and resolved if needed), I would reset --soft HEAD to the initial commit, write all branches SHA1 in `.git/MERGE_HEAD` (stimulating an octopus merge) and commit. See http://stackoverflow.com/questions/5203535/practical-uses-of-git-reset-soft/5203843#5203843 for a practical example of that technique. – VonC Mar 29 '11 at 17:55
-
You could also use `commit-tree` and specify parents on the command line to avoid having to edit anything in the .git directory, but I'm not sure if it's actually any friendlier. – Cascabel Mar 29 '11 at 18:12
-
Thanks VonC. I'm trying to automate this process and keep things as simple as possible. I think for my situation the easiest thing to do is 1) try octopus using all branches. 2) if there is a failure, 'reset --hard HEAD' and then do one by one until error, logging the output for developers to investigate. – Kallin Nagelberg Mar 29 '11 at 18:14
-
2One thing that I could see being very useful is if the octopus merge could be told to, when encountering conflicts, *skip* that merge, and go on to the next one. That would provide a way to, qualitatively, bundle all developers' work up, and tell you which ones you need to go fix (or have them fix). Splitting the "evil" up into separate single merges is also potentially good. – Cascabel Mar 29 '11 at 18:14
-
Ideally it should be able to output all of the conflicting files, and across which branch(es) each file conflicted. – Kallin Nagelberg Mar 29 '11 at 18:31
-
@Kallin: excellent. Don't forget to post the resulting script in an answer of its own right in this page ;) (You will even be able to select your own post as the official answer). – VonC Mar 29 '11 at 18:41