git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: David Kastrup <dak@gnu.org>
To: git@vger.kernel.org
Cc: Theodore Tso <tytso@mit.edu>
Subject: [Untested! proposal] git-mergetool.sh: introduce ediff option
Date: Sun, 29 Jul 2007 15:51:34 +0200	[thread overview]
Message-ID: <85hcnnwblu.fsf@lola.goethe.zz> (raw)
In-Reply-To: Pine.LNX.4.64.0707291224460.14781@racer.site


This is not yet tested (still have to do that): it's a base for
discussion and something which I think reasonable.  It does not touch
the old behavior of "emerge" apart from calling Emacs with option -q
foregoing user-specific initializations, and preselects "ediff" only
where EDITOR/VISUAL suggest Emacs being used as a normal editor.

Here goes:

Most actual Emacs users prefer ediff to emerge concerning the
consolidation of versions.  In general, people habitually using Emacs
will have this preference reflected in the EDITOR/VISUAL environment
variables.

If such a preference can be found there, ediff will be used/offered in
preference of emerge (which retains its previous behavior).

In ediff mode, success or failure of the merge will be discerned by
Emacs either having written or not written the merge buffer; no
attempt of interpreting the exit code is made.

This is much closer to the working habits of Emacs users than the
emerge behavior which uses Emacs as a one-shot session editor.

In order to bypass things like desktop files being loaded, emerge mode
now passes the "-q" option to Emacs.  This will make it work in more
situations likely to occur, at the price of excluding possibly
harmless user customizations with the rest.
---
 git-mergetool.sh |   50 ++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 36 insertions(+), 14 deletions(-)

diff --git a/git-mergetool.sh b/git-mergetool.sh
index 47a8055..8ed3ed4 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -251,13 +251,27 @@ merge_file () {
 	    ;;
 	emerge)
 	    if base_present ; then
-		emacs -f emerge-files-with-ancestor-command "$LOCAL" "$REMOTE" "$BASE" "$path"
+		emacs -q -f emerge-files-with-ancestor-command "$LOCAL" "$REMOTE" "$BASE" "$path"
 	    else
-		emacs -f emerge-files-command "$LOCAL" "$REMOTE" "$path"
+		emacs -q -f emerge-files-command "$LOCAL" "$REMOTE" "$path"
 	    fi
 	    status=$?
 	    save_backup
 	    ;;
+	ediff)
+	    case "${EDITOR:-${VISUAL:-emacs}}" in
+		*/emacs*|*/gnuclient*|*/xemacs*)
+		    emacs_candidate="${EDITOR:-${VISUAL:-emacs}}";;
+		*)
+		    emacs_candidate=emacs;;
+	    esac
+	    if base_present ; then
+		${emacs_candidate} --eval "(ediff-merge-files-with-ancestor (pop command-line-args-left) (pop command-line-args-left) (pop command-line-args-left) nil (pop-command-line-args-left))" "$LOCAL" "$REMOTE" "$BASE" "$path"
+	    else
+		${emacs_candidate} --eval "(ediff-merge-files (pop command-line-args-left) (pop command-line-args-left) nil (pop-command-line-args-left))" "$LOCAL" "$REMOTE" "$path"
+	    fi
+	    check_unchanged
+	    save_backup
     esac
     if test "$status" -ne 0; then
 	echo "merge of $path failed" 1>&2
@@ -299,7 +313,7 @@ done
 if test -z "$merge_tool"; then
     merge_tool=`git config merge.tool`
     case "$merge_tool" in
-	kdiff3 | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff | "")
+	kdiff3 | tkdiff | xxdiff | meld | opendiff | emerge | ediff | vimdiff | gvimdiff | "")
 	    ;; # happy
 	*)
 	    echo >&2 "git config option merge.tool set to unknown tool: $merge_tool"
@@ -319,23 +333,26 @@ if test -z "$merge_tool" ; then
             merge_tool_candidates="kdiff3 $merge_tool_candidates"
         fi
     fi
-    if echo "${VISUAL:-$EDITOR}" | grep 'emacs' > /dev/null 2>&1; then
-        merge_tool_candidates="$merge_tool_candidates emerge"
-    fi
+    case "${EDITOR:-${VISUAL}}" in
+	*/emacs*|*/gnuclient*|*/xemacs*)
+            merge_tool_candidates="$merge_tool_candidates ediff"
+    esac
     if echo "${VISUAL:-$EDITOR}" | grep 'vim' > /dev/null 2>&1; then
         merge_tool_candidates="$merge_tool_candidates vimdiff"
     fi
     merge_tool_candidates="$merge_tool_candidates opendiff emerge vimdiff"
     echo "merge tool candidates: $merge_tool_candidates"
     for i in $merge_tool_candidates; do
-        if test $i = emerge ; then
-            cmd=emacs
-        else
-            cmd=$i
-        fi
-        if type $cmd > /dev/null 2>&1; then
-            merge_tool=$i
-            break
+	case $i in emerge)
+		cmd=emacs;;
+	    ediff)
+		merge_tool=$i
+		break;;
+	    *) cmd=$i
+	    esac
+	if type $cmd > /dev/null 2>&1; then
+	    merge_tool=$i
+	    break
         fi
     done
     if test -z "$merge_tool" ; then
@@ -357,6 +374,11 @@ case "$merge_tool" in
 	    exit 1
 	fi
 	;;
+    ediff)
+	if ! (set ${EDITOR:-${VISUAL:-emacs}}; type "$1" > /dev/null 2>&1); then
+	    echo "${EDITOR:-${VISUAL:-emacs}} is not available"
+	    exit 1
+	fi
     *)
 	echo "Unknown merge tool: $merge_tool"
 	exit 1
-- 
1.5.2.3

  reply	other threads:[~2007-07-29 14:04 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-13 22:30 What's in git.git (stable) Junio C Hamano
2007-05-17  0:21 ` Junio C Hamano
2007-05-19  5:24   ` Junio C Hamano
2007-05-23 21:46     ` Junio C Hamano
2007-05-29 10:12       ` Junio C Hamano
2007-06-02 21:09         ` Junio C Hamano
2007-06-07  2:08           ` Junio C Hamano
2007-06-13 20:11             ` Junio C Hamano
2007-06-13 22:31               ` Johannes Schindelin
2007-06-14  7:12                 ` Johannes Sixt
2007-06-21  7:21               ` Junio C Hamano
2007-06-25  9:43                 ` Junio C Hamano
2007-07-02  0:16                   ` Junio C Hamano
2007-07-13  6:06                     ` What's in git.git Junio C Hamano
2007-07-13  6:40                       ` Draft release notes for v1.5.3, as of -rc1 Junio C Hamano
2007-07-13  9:29                         ` Sven Verdoolaege
2007-07-14 14:22                           ` Johannes Schindelin
2007-07-14 18:13                             ` Junio C Hamano
2007-07-15 23:53                               ` Johannes Schindelin
2007-07-13 13:50                         ` Brian Downing
2007-07-13 15:31                           ` Junio C Hamano
2007-07-28  8:47                       ` What's in git.git (stable) Junio C Hamano
2007-07-28  8:56                         ` David Kastrup
2007-07-28  9:02                           ` Junio C Hamano
2007-07-28  9:35                           ` David Kastrup
2007-07-29  3:16                             ` Theodore Tso
2007-07-29  9:05                               ` David Kastrup
2007-07-29 16:40                                 ` Theodore Tso
2007-07-29 11:27                               ` Johannes Schindelin
2007-07-29 13:51                                 ` David Kastrup [this message]
2007-07-29 20:52                                   ` [Untested! proposal] git-mergetool.sh: introduce ediff option Theodore Tso
2007-07-29 23:30                                     ` David Kastrup
2007-07-28 12:28                         ` What's in git.git (stable) Thomas Glanzmann
2007-08-07  6:22                         ` Junio C Hamano

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=85hcnnwblu.fsf@lola.goethe.zz \
    --to=dak@gnu.org \
    --cc=git@vger.kernel.org \
    --cc=tytso@mit.edu \
    /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).