Automating merge conflict resolution Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Git: Confusion about merge algorithm, conflict format, and interplay with mergetoolsI ran into a merge conflict. How can I abort the merge?How to resolve merge conflicts in GitHow to selectively merge or pick changes from another branch in Git?When do you use git rebase instead of git merge?Undo a Git merge that hasn't been pushed yetHow can I merge two commits into one if I already started rebase?How do you push a tag to a remote repository using Git?What is the best (and safest) way to merge a Git branch into master?How to undo a git merge with conflictsResolve Git merge conflicts in favor of their changes during a pull

How do I use the new nonlinear finite element in Mathematica 12 for this equation?

How could we fake a moon landing now?

AppleTVs create a chatty alternate WiFi network

Did Deadpool rescue all of the X-Force?

If Windows 7 doesn't support WSL, then what does Linux subsystem option mean?

Denied boarding although I have proper visa and documentation. To whom should I make a complaint?

How to write the following sign?

Dating a Former Employee

Should I use a zero-interest credit card for a large one-time purchase?

Question about debouncing - delay of state change

A term for a woman complaining about things/begging in a cute/childish way

Maximum summed subsequences with non-adjacent items

What is the topology associated with the algebras for the ultrafilter monad?

How to compare two different files line by line in unix?

Why do we need to use the builder design pattern when we can do the same thing with setters?

Is it a good idea to use CNN to classify 1D signal?

What would you call this weird metallic apparatus that allows you to lift people?

How do living politicians protect their readily obtainable signatures from misuse?

What is this clumpy 20-30cm high yellow-flowered plant?

Crossing US/Canada Border for less than 24 hours

How to install press fit bottom bracket into new frame

How were pictures turned from film to a big picture in a picture frame before digital scanning?

Using audio cues to encourage good posture

How would a mousetrap for use in space work?



Automating merge conflict resolution



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!Git: Confusion about merge algorithm, conflict format, and interplay with mergetoolsI ran into a merge conflict. How can I abort the merge?How to resolve merge conflicts in GitHow to selectively merge or pick changes from another branch in Git?When do you use git rebase instead of git merge?Undo a Git merge that hasn't been pushed yetHow can I merge two commits into one if I already started rebase?How do you push a tag to a remote repository using Git?What is the best (and safest) way to merge a Git branch into master?How to undo a git merge with conflictsResolve Git merge conflicts in favor of their changes during a pull



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I'm using git mergetool with beyondcompare4 for solving git merge conflicts.
In my project files I often have tags for date/time/version-list that always gives me an merge conflict.
I would like to automate the resolutions of those conflicts. For e.g. selecting the latest date, or highest version number (there's a clear logic that i could script).



How could I achieve it?



Here's what i tried so far:



  • I tried to look for the git hook, but found none that fits my purpose. There's nothing like pre-merge hook


  • I wrote powershell script that loops through the merge conflicts, solves them according to my logic, and stages the changes. It works well if it's the only conflict within the file. If there are more conflicts, I cannot stage the changes, since it will stage conflicts as well. On another hand, if I run git mergetool after executing my script, BC4 ignores the changes the script have done, and shows those lines as conflicts.


  • Looked for possibilities to run custom script using BC4 but it seems it does not have such a feature.


Any help appreciated,



Gintautas










share|improve this question






















  • Doing this at git mergetool time is later than you should; the place to do them is earlier, in a merge driver. See stackoverflow.com/q/44212642/1256452

    – torek
    Mar 9 at 0:56











  • If I understand it correctly, custom merge driver completely overrides standard default merge driver. Meaning, I have to deal with all merge conflicts, not only the ones I want to fix automatically. Right?

    – Gintautas
    Mar 9 at 16:47











  • Yes. Fortunately, Git provides git merge-file, which implements the same low-level merge as the built in merge driver. So you can read the three inputs, find which input(s) have resolveable dateinfo conflicts, put the desired dateinfo into updated input files, and then run git merge-file on those updated inputs. (Here the word "dateinfo" is meant to cover your "date/time/version-list" combination.)

    – torek
    Mar 9 at 17:51











  • This solution has some issues; in particular you don't get the -X extended flags. The merge driver code in Git really could use more %-directives.

    – torek
    Mar 9 at 17:52

















1















I'm using git mergetool with beyondcompare4 for solving git merge conflicts.
In my project files I often have tags for date/time/version-list that always gives me an merge conflict.
I would like to automate the resolutions of those conflicts. For e.g. selecting the latest date, or highest version number (there's a clear logic that i could script).



How could I achieve it?



Here's what i tried so far:



  • I tried to look for the git hook, but found none that fits my purpose. There's nothing like pre-merge hook


  • I wrote powershell script that loops through the merge conflicts, solves them according to my logic, and stages the changes. It works well if it's the only conflict within the file. If there are more conflicts, I cannot stage the changes, since it will stage conflicts as well. On another hand, if I run git mergetool after executing my script, BC4 ignores the changes the script have done, and shows those lines as conflicts.


  • Looked for possibilities to run custom script using BC4 but it seems it does not have such a feature.


Any help appreciated,



Gintautas










share|improve this question






















  • Doing this at git mergetool time is later than you should; the place to do them is earlier, in a merge driver. See stackoverflow.com/q/44212642/1256452

    – torek
    Mar 9 at 0:56











  • If I understand it correctly, custom merge driver completely overrides standard default merge driver. Meaning, I have to deal with all merge conflicts, not only the ones I want to fix automatically. Right?

    – Gintautas
    Mar 9 at 16:47











  • Yes. Fortunately, Git provides git merge-file, which implements the same low-level merge as the built in merge driver. So you can read the three inputs, find which input(s) have resolveable dateinfo conflicts, put the desired dateinfo into updated input files, and then run git merge-file on those updated inputs. (Here the word "dateinfo" is meant to cover your "date/time/version-list" combination.)

    – torek
    Mar 9 at 17:51











  • This solution has some issues; in particular you don't get the -X extended flags. The merge driver code in Git really could use more %-directives.

    – torek
    Mar 9 at 17:52













1












1








1


1






I'm using git mergetool with beyondcompare4 for solving git merge conflicts.
In my project files I often have tags for date/time/version-list that always gives me an merge conflict.
I would like to automate the resolutions of those conflicts. For e.g. selecting the latest date, or highest version number (there's a clear logic that i could script).



How could I achieve it?



Here's what i tried so far:



  • I tried to look for the git hook, but found none that fits my purpose. There's nothing like pre-merge hook


  • I wrote powershell script that loops through the merge conflicts, solves them according to my logic, and stages the changes. It works well if it's the only conflict within the file. If there are more conflicts, I cannot stage the changes, since it will stage conflicts as well. On another hand, if I run git mergetool after executing my script, BC4 ignores the changes the script have done, and shows those lines as conflicts.


  • Looked for possibilities to run custom script using BC4 but it seems it does not have such a feature.


Any help appreciated,



Gintautas










share|improve this question














I'm using git mergetool with beyondcompare4 for solving git merge conflicts.
In my project files I often have tags for date/time/version-list that always gives me an merge conflict.
I would like to automate the resolutions of those conflicts. For e.g. selecting the latest date, or highest version number (there's a clear logic that i could script).



How could I achieve it?



Here's what i tried so far:



  • I tried to look for the git hook, but found none that fits my purpose. There's nothing like pre-merge hook


  • I wrote powershell script that loops through the merge conflicts, solves them according to my logic, and stages the changes. It works well if it's the only conflict within the file. If there are more conflicts, I cannot stage the changes, since it will stage conflicts as well. On another hand, if I run git mergetool after executing my script, BC4 ignores the changes the script have done, and shows those lines as conflicts.


  • Looked for possibilities to run custom script using BC4 but it seems it does not have such a feature.


Any help appreciated,



Gintautas







git git-merge merge-conflict-resolution git-merge-conflict beyondcompare4






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 8 at 20:14









GintautasGintautas

83




83












  • Doing this at git mergetool time is later than you should; the place to do them is earlier, in a merge driver. See stackoverflow.com/q/44212642/1256452

    – torek
    Mar 9 at 0:56











  • If I understand it correctly, custom merge driver completely overrides standard default merge driver. Meaning, I have to deal with all merge conflicts, not only the ones I want to fix automatically. Right?

    – Gintautas
    Mar 9 at 16:47











  • Yes. Fortunately, Git provides git merge-file, which implements the same low-level merge as the built in merge driver. So you can read the three inputs, find which input(s) have resolveable dateinfo conflicts, put the desired dateinfo into updated input files, and then run git merge-file on those updated inputs. (Here the word "dateinfo" is meant to cover your "date/time/version-list" combination.)

    – torek
    Mar 9 at 17:51











  • This solution has some issues; in particular you don't get the -X extended flags. The merge driver code in Git really could use more %-directives.

    – torek
    Mar 9 at 17:52

















  • Doing this at git mergetool time is later than you should; the place to do them is earlier, in a merge driver. See stackoverflow.com/q/44212642/1256452

    – torek
    Mar 9 at 0:56











  • If I understand it correctly, custom merge driver completely overrides standard default merge driver. Meaning, I have to deal with all merge conflicts, not only the ones I want to fix automatically. Right?

    – Gintautas
    Mar 9 at 16:47











  • Yes. Fortunately, Git provides git merge-file, which implements the same low-level merge as the built in merge driver. So you can read the three inputs, find which input(s) have resolveable dateinfo conflicts, put the desired dateinfo into updated input files, and then run git merge-file on those updated inputs. (Here the word "dateinfo" is meant to cover your "date/time/version-list" combination.)

    – torek
    Mar 9 at 17:51











  • This solution has some issues; in particular you don't get the -X extended flags. The merge driver code in Git really could use more %-directives.

    – torek
    Mar 9 at 17:52
















Doing this at git mergetool time is later than you should; the place to do them is earlier, in a merge driver. See stackoverflow.com/q/44212642/1256452

– torek
Mar 9 at 0:56





Doing this at git mergetool time is later than you should; the place to do them is earlier, in a merge driver. See stackoverflow.com/q/44212642/1256452

– torek
Mar 9 at 0:56













If I understand it correctly, custom merge driver completely overrides standard default merge driver. Meaning, I have to deal with all merge conflicts, not only the ones I want to fix automatically. Right?

– Gintautas
Mar 9 at 16:47





If I understand it correctly, custom merge driver completely overrides standard default merge driver. Meaning, I have to deal with all merge conflicts, not only the ones I want to fix automatically. Right?

– Gintautas
Mar 9 at 16:47













Yes. Fortunately, Git provides git merge-file, which implements the same low-level merge as the built in merge driver. So you can read the three inputs, find which input(s) have resolveable dateinfo conflicts, put the desired dateinfo into updated input files, and then run git merge-file on those updated inputs. (Here the word "dateinfo" is meant to cover your "date/time/version-list" combination.)

– torek
Mar 9 at 17:51





Yes. Fortunately, Git provides git merge-file, which implements the same low-level merge as the built in merge driver. So you can read the three inputs, find which input(s) have resolveable dateinfo conflicts, put the desired dateinfo into updated input files, and then run git merge-file on those updated inputs. (Here the word "dateinfo" is meant to cover your "date/time/version-list" combination.)

– torek
Mar 9 at 17:51













This solution has some issues; in particular you don't get the -X extended flags. The merge driver code in Git really could use more %-directives.

– torek
Mar 9 at 17:52





This solution has some issues; in particular you don't get the -X extended flags. The merge driver code in Git really could use more %-directives.

– torek
Mar 9 at 17:52












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55070400%2fautomating-merge-conflict-resolution%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55070400%2fautomating-merge-conflict-resolution%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved