git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [Untested! proposal] git-mergetool.sh: introduce ediff option

From
David Kastrup <dak@gnu.org>
Date
Jul 29, 2007, 23:30 UTC
Message-ID
<853az6vldf.fsf@lola.goethe.zz>
In-Reply-To
<20070729205232.GA10148@thunk.org>
Theodore Tso <tytso@mit.edu> writes:
Show 5 quoted lines
> On Sun, Jul 29, 2007 at 03:51:34PM +0200, David Kastrup wrote:
>
> For the past two decades, I have EDITOR set to emacs, but I am not
> an ediff fan.  Yes, that's anecdotal evidence, but so are your
> assertions.
Ok.
Show 7 quoted lines
>> 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.
>
> Sometimes resolving the merge file results in no changes.  So the fact
> that ediff is buggy in that it doesn't return an exit code is a real
> problem.

Ediff starts out with a changed buffer when merging files. git-mergetool can check for modification times (which is done on several backends), so it can catch whether or not the ediff buffer has been saved.

> We could possibly work around the problem saving and then checking
> the modtime --- but only if ediff actually ends up rewriting the
> file.
See above.
Show 10 quoted lines
>> 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.
>
> But that screws over users who want their customizations, but who
> don't use the desktop package.  (And I have a news flash for you;
> the desktop package is *not* include as part of emacs21.  It's not
> part of Debian's emacs21 package, version 21.4.)  So do not believe
> your claim that emacs's desktop package is commonly used.
Sigh.

$ dpkg -L emacs21-el|grep desktop /usr/share/emacs/21.4/lisp/desktop.el

Show 12 quoted lines
>> +	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"
>
> ... and this will blow up if EMACS is set to emacsclient, and emacs
> version is 21.

I am currently working on ironing this out. It is easy to check whether emacsclient supports --eval and revert to emacs in that case. Unfortunately, it turns out that the above also blows up with emacsclient 22.1 (I hope to get some patches into Emacs so that this will actually work in 22.2). So I am currently reworking this, and it is indeed fragile stuff and quite a nuisance to get right.

Show 5 quoted lines
> (And BTW, Debian stable and the current Ubuntu, Edgy Eft, are still
> shipping emacs21.  So are a number of current major distro's.  So if
> you think the vast majority of users are using emacs22, you are
> either on drugs, and have a very skewed view of what are "normal"
> emacs users.)

The current Ubuntu happens to be Feisty Fawn, and it includes emacs-snapshot-gtk (among other options) with a workable emacsclient. But I certainly will not ask for including a solution that would not produce the best feasible results for all of emacs21, emacs22, and xemacs-21.x. As I said, the patch was just provided as material for discussion and does not yet work.

> There is a reason why git-mergetool currently hardcodes the use of
> "emacs", instead of just blindly using the value of $EDITOR or
> $VISUAL.
Which is not really nice to XEmacs users, by the way.
> So what you're doing here in your patch is completely busted.  If
> you insist on using emacs_candidate, we need to run emacs --version
> and parse the output, and only using the value of EMACS or VISUAL if
> the major version number of emacs is at least 22.

It is actually more straightforward to check the exit code of emacsclient --eval t >/dev/null 2>&1 which is basically what I do now. Even if one wanted to parse the output of --version, emacsclient --version would be faster.

> (It would probably be a good idea to do this once and cache the
> result, so we don't have to repeatedly for each file that git
> mergetool needs to process.)

My current version of the patch already does this. However, the startup/exit behavior is still somewhat broken though marginally usable (getting both ediff started and the resulting buffer registered as a server buffer without messing up ediff's window setup is the challenge), so I am still ironing stuff out.

Show 11 quoted lines
>> -    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
>
> Changing the default from emerge to ediff is a non-starter, sorry.
> If you really want to use ediff, you can set a config parameter to
> explicitly request it.

How would you feel about preferring ediff when EDITOR is emacsclient or gnuclient, and emerge otherwise?

Of course only once ediff will work satisfactorily with all Emacs and XEmacs variants out there.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum
Previous: Theodore TsoNext: Thomas Glanzmann
Message 32 of 34 in “What's in git.git (stable)”
  1. Junio C HamanoMay 13, 2007
  2. Junio C HamanoMay 17, 2007
  3. Junio C HamanoMay 19, 2007
  4. Junio C HamanoMay 23, 2007
  5. Junio C HamanoMay 29, 2007
  6. Junio C HamanoJun 2, 2007
  7. Junio C HamanoJun 7, 2007
  8. Junio C HamanoJun 13, 2007
  9. Johannes SchindelinJun 13, 2007
  10. Johannes SixtJun 14, 2007
  11. Junio C HamanoJun 21, 2007
  12. Junio C HamanoJun 25, 2007
  13. Junio C HamanoJul 2, 2007
  14. What's in git.gitJunio C Hamano, Jul 13, 2007
  15. Draft release notes for v1.5.3, as of -rc1Junio C Hamano, Jul 13, 2007
  16. Sven VerdoolaegeJul 13, 2007
  17. Johannes SchindelinJul 14, 2007
  18. Junio C HamanoJul 14, 2007
  19. Johannes SchindelinJul 15, 2007
  20. Brian DowningJul 13, 2007
  21. Junio C HamanoJul 13, 2007
  22. Junio C HamanoJul 28, 2007
  23. David KastrupJul 28, 2007
  24. Junio C HamanoJul 28, 2007
  25. David KastrupJul 28, 2007
  26. Theodore TsoJul 29, 2007
  27. David KastrupJul 29, 2007
  28. Theodore TsoJul 29, 2007
  29. Johannes SchindelinJul 29, 2007
  30. [Untested! proposal] git-mergetool.sh: introduce ediff optionDavid Kastrup, Jul 29, 2007
  31. Theodore TsoJul 29, 2007
  32. David KastrupJul 29, 2007
  33. Thomas GlanzmannJul 28, 2007
  34. Junio C HamanoAug 7, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.