Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I use the following script as mergetool which works quite well.</p> <pre><code>#!/bin/bash # test args if [ ! ${#} -ge 3 ]; then echo 1&gt;&amp;2 "Usage: ${0} LOCAL REMOTE MERGED BASE" echo 1&gt;&amp;2 " (LOCAL, REMOTE, MERGED, BASE can be provided by \`git mergetool'.)" exit 1 fi # tools _EMACSCLIENT=/usr/local/bin/emacsclient _BASENAME=/bin/basename _CP=/bin/cp _EGREP=/bin/egrep _MKTEMP=/bin/mktemp # args _LOCAL=${1} _REMOTE=${2} _MERGED=${3} if [ -r ${4} ] ; then _BASE=${4} _EDIFF=ediff-merge-files-with-ancestor _EVAL="${_EDIFF} \"${_LOCAL}\" \"${_REMOTE}\" \"${_BASE}\" nil \"${_MERGED}\"" else _EDIFF=ediff-merge-files _EVAL="${_EDIFF} \"${_LOCAL}\" \"${_REMOTE}\" nil \"${_MERGED}\"" fi # console vs. X if [ "${TERM}" = "linux" ]; then unset DISPLAY _EMACSCLIENTOPTS="-t" else _EMACSCLIENTOPTS="-c" fi # run emacsclient ${_EMACSCLIENT} ${_EMACSCLIENTOPTS} -a "" -e "(${_EVAL})" 2&gt;&amp;1 # check modified file if [ ! $(egrep -c '^(&lt;&lt;&lt;&lt;&lt;&lt;&lt;|=======|&gt;&gt;&gt;&gt;&gt;&gt;&gt;|####### Ancestor)' ${_MERGED}) = 0 ]; then _MERGEDSAVE=$(${_MKTEMP} --tmpdir `${_BASENAME} ${_MERGED}`.XXXXXXXXXX) ${_CP} ${_MERGED} ${_MERGEDSAVE} echo 1&gt;&amp;2 "Oops! Conflict markers detected in $_MERGED." echo 1&gt;&amp;2 "Saved your changes to ${_MERGEDSAVE}" echo 1&gt;&amp;2 "Exiting with code 1." exit 1 fi exit 0 </code></pre> <p>To use it with `git mergetool' put the following in your git config:</p> <pre><code>[merge] tool = ediff [mergetool "ediff"] cmd = /path/to/ediff-merge-script $LOCAL $REMOTE $MERGED $BASE trustExitCode = true </code></pre> <p>Additionally, you should check (in the script) the paths of the tools used and if the poor man's console detection works for you.</p> <p>The script itself starts an emacs client (or emacs followed by an emacs client, <code>-a ""</code>) and evals either <code>ediff-merge-files-with-ancestor</code> or <code>ediff-merge-files</code> if there's no base version (e.g. when merging two branches where the same path/file has been created independently).</p> <p>After the emacs client has finished the merged file is checked for conflict markers. Should those be found, your work will be saved away to a temporary file, the script will exit with code 1 and git will restore the pre-mergetool contents of the merged file.</p> <p>When there are no conflict markers present, the script exits with code 0 and git will regard the merge as successful.</p> <p><strong>Important:</strong> Setting the mergetool option <code>trustExitCode</code> to <code>true</code> as well as the post-edit check for conflict markers will not work if you start <code>emacsclient</code> with the <code>--no-wait</code> option.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload