On Thu, Jan 24, 2013 at 11:54:25PM -0800, David Aguilar wrote:
> On Thu, Jan 24, 2013 at 11:21 PM, Junio C Hamano <gits...@pobox.com> wrote:
> > Is there a way for me to programatically tell what merge.tool and
> > diff.tool could be enabled for a particular source checkout of Git
> > regardless of what platform am I on (that is, even though I won't
> > touch Windows, I want to see 'tortoise' appear in the output of such
> > a procedure)?  We could generate a small text file from the Makefile
> > in Documentation and include it when building the manual pages if
> > such a procedure is available.
> 
> That's a good idea.
> Here's one way... (typed into gmail, so probably broken)
>
> LF='
> '
> mergetools=
> difftools=
> scriptlets="$(git --exec-path)"/mergetools
> 
> for script in "$scriptlets"/*
> do
>     tool="$(basename "$script")"
>     if test "$tool" = "defaults"
>     then
>         continue
>     fi
>     . "$scriptlets"/defaults
>     can_diff && difftools="$difftools$tool$LF"
>     can_merge && mergetools="$mergetools$tool$LF"
> done

I don't think this will work since the names of the valid tools are not
necessarily the same as the names of the scriptlets - this is the exact
issue that prompted my patches to git-difftool yesterday.

The best option I can see given what's currently available is something
like this:

-- >8 --

sed -n -e '/^list_merge_tool_candidates/,/^}/ {
        /tools=/ {
                s/.*tools=//
                s/"//g
                s/\$tools//
                s/ /\n/g
                p
        }
}' git-mergetool--lib.sh |sort |uniq |while read -r tool
do
        test -z "$tool" && continue
        ( . git-mergetool--lib && setup_tool $tool
                # Use can_diff and can_merge here.
        )
done

-- 8< --


John
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to