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

Re: [PATCH] difftool: print list of valid tools with '--tool-help'

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 15, 2012, 23:18 UTC
Message-ID
<7v8vj1ihcn.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1331850311-4620-1-git-send-email-tim.henigan@gmail.com>
Tim Henigan <tim.henigan@gmail.com> writes:
Show 11 quoted lines
> @@ -100,6 +101,15 @@ sub generate_command
>  		if ($arg eq '-h') {
>  			usage();
>  		}
> +		if ($arg eq '--tool-help') {
> +			my $gitpath = Git::exec_path();
> +			print "'git difftool --tool=<tool>' may be set to one of the following:\n";
> +			for (glob "$gitpath/mergetools/*") {
> +				next if /defaults$/;
> +				print "\t" . basename($_) . "\n";
> +			}

As this topic to show list of tools dynamically has plenty of time to be in the mainline (it will be post 1.7.10), I would suggest a follow-up series to this patch to do things like the following (just thinking aloud):

 - define a new entry point to these mergetools/ scriptlets, let's call
   it "cando".  An entry for mergetools/kompare might look like this:
        cando () {
                type kompare >/dev/null && test -n "$DISPLAY"
        }
   that would yield true only when kompare is available and $DISPLAY is
   set.
 - instead of dumping everything in $gitpath/mergetools/*, check if each
   tool says it can be used in the user's environment.
        for (glob "$gitpath/mergetools/*") {
                next unless can_run($_);
                print ...
        }
        ...
   and "can_run" may look like this:
        sub can_run {
                my ($script) = @_;
             my $cmd = ". '$script' && cando";
             system('sh', '-c', $cmd) == 0;
        }
 - perhaps show the result in columnar layout.
Previous: David AguilarNext: Tim Henigan
Message 4 of 7 in “difftool: print list of valid tools with '--tool-help'”
  1. difftool: print list of valid tools with '--tool-help'Tim Henigan, Mar 15, 2012
  2. Junio C HamanoMar 15, 2012
  3. David AguilarMar 17, 2012
  4. Junio C HamanoMar 15, 2012
  5. Tim HeniganMar 23, 2012
  6. Junio C HamanoMar 23, 2012
  7. 9/9 difftool: print list of valid tools with '--tool-help'Tim Henigan, Mar 26, 2012

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.