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

Re: [PATCH] git-mergetool: Make default smarter by considering user's desktop environment and editor

From
Junio C Hamano <junkio@cox.net>
Date
Jun 6, 2007, 08:08 UTC
Message-ID
<7vabvd7bfg.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<466637E2.5040303@freedesktop.org>
Josh Triplett <josh@freedesktop.org> writes:
Show 5 quoted lines
> Make git-mergetool prefer meld under GNOME, and kdiff3 under KDE.  When
> considering emerge and vimdiff, check $VISUAL and $EDITOR to see which the
> user might prefer.
>
> Signed-off-by: Josh Triplett <josh@freedesktop.org>
The basic idea is sound.  However...
 (1) I wonder if we can get rid of the horribly long if .. elif
     chain by using shell function and then iterate a list of them;
 (2) echo "${VISUAL-$EDITOR}" | grep '^emacs'???
     Some people may have explicit path (/home/me/bin/emacs),
     and/or runs a variant of emacs called 'xemacs'.  Same for
     vim.
Something like...
        test_xstuff () {
                test -n "$DISPLAY" && type "$1" >/dev/null 2>&1
        test_kdiff3 () {
                test_xstuff kdiff3
        }
        test_tkdiff () {
                test_xstuff tkdiff
        }
        test_estuff() {
                type "$1" >/dev/null 2>&1 &&
                case "${VISUAL-$EDITOR}" in *"$1"*) : ;; *) false ;; esac
        }
        test_emerge () {
                test_estuff emacs
        }
        test_vimdiff () {
                test_estuff vim
        }
        choose_merge_tool () {
                for t in "$@"
                do
                        if test_$t
                        then
                                echo "$t"
                                break
                        fi
                done
        }
        if test -z "$merge_tool"
        then
                merge_tool_candidates='kdiff3 tkdiff xxdiff meld opendiff ...'
                if test -n "$GNOME_DESCTOP_SESSION_ID"
                then
                        merge_tool_candidates="meld $merge_tool_candidates"
                elif test -n "$KDE_FULL_SESSION"
                then
                        merge_tool_candidates="kdiff3 $merge_tool_candidates"
                elif
                        ...
                fi
                merge_tool=$(choose_merge_tool $merge_tool_candidates)
        fi
Previous: Josh TriplettNext: David Kastrup
Message 2 of 6 in “git-mergetool: Make default smarter by considering user's desktop environment and editor”
  1. git-mergetool: Make default smarter by considering user's desktop environment and editorJosh Triplett, Jun 6, 2007
  2. Junio C HamanoJun 6, 2007
  3. David KastrupJun 6, 2007
  4. Junio C HamanoJun 6, 2007
  5. David KastrupJun 6, 2007
  6. Theodore TsoJun 6, 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.