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

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

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 28, 2012, 18:58 UTC
Message-ID
<7vvclov9hi.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1332959684-2231-1-git-send-email-tim.henigan@gmail.com>
Tim Henigan <tim.henigan@gmail.com> writes:
> Changes in v8:
>   - Replaced 'glob' with 'File::Find'. Glob will fail if file paths include
>     spaces.  Using File::Find overcomes that limitation.

OK, but doesn't File::Find recurse into its subdirectories? If you create a 'foo' directory there and drop a 'bar' script in it, is the rest of the code prepared to give you "git difftool -t foo/bar"?

Show 5 quoted lines
>   - Added 'TOOL_MODE=DIFF' prior to calling 'git-mergetool--lib.sh'. This
>     insures that the shell script executes as designed.
>   - difftool now calls 'can_diff' from 'git-mergetool--lib.sh' to insure that
>     only tools that are capable of diffing are shown as valid options. For
>     example, 'tortoisemerge' cannot be used as a diff viewer.

Good that you caught these brown-paper-bag bugs ;-) It feels a bit awkward that nobody pointed these out, even though the series has been queued in 'pu' since its early iterations.

Show 18 quoted lines
> diff --git a/git-difftool.perl b/git-difftool.perl
> index 0fa131c..15fd572 100755
> --- a/git-difftool.perl
> +++ b/git-difftool.perl
> @@ -38,6 +39,40 @@ USAGE
>  	exit($exitcode);
>  }
>  
> +sub print_tool_help
> +{
> +	my ($cmd, @found, @notfound, @tools);
> +	my $gitpath = Git::exec_path();
> +
> +	find(sub { push(@tools, $_) unless (-d $_) }, "$gitpath/mergetools");
> +
> +	for (@tools) {
> +		my $tool = $_;
> +		next if ($tool eq "defaults");

Now you use File::Find::find(), you probably should do this kind of trivial filtering inside the callback, no?

Previous: Tim HeniganNext: Tim Henigan
Message 2 of 5 in “difftool: print list of valid tools with '--tool-help'”
  1. 9/9 difftool: print list of valid tools with '--tool-help'Tim Henigan, Mar 28, 2012
  2. Junio C HamanoMar 28, 2012
  3. Tim HeniganMar 28, 2012
  4. Junio C HamanoMar 28, 2012
  5. Tim HeniganMar 28, 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.