Code

git-difftool: Add '--gui' for selecting a GUI tool
[git.git] / git-difftool.perl
index ba5e60a45e2c4a8b54e6a58e656b3978dcb45633..8c836e4c76528e52b010dd37e904f132d5386000 100755 (executable)
@@ -15,13 +15,16 @@ use warnings;
 use Cwd qw(abs_path);
 use File::Basename qw(dirname);
 
+require Git;
+
 my $DIR = abs_path(dirname($0));
 
 
 sub usage
 {
        print << 'USAGE';
-usage: git difftool [--tool=<tool>] [-y|--no-prompt] ["git diff" options]
+usage: git difftool [-g|--gui] [-t|--tool=<tool>] [-y|--no-prompt]
+                    ["git diff" options]
 USAGE
        exit 1;
 }
@@ -63,6 +66,14 @@ sub generate_command
                        $ENV{GIT_DIFF_TOOL} = substr($arg, 7);
                        next;
                }
+               if ($arg eq '-g' || $arg eq '--gui') {
+                       my $tool = Git::command_oneline('config',
+                                                       'diff.guitool');
+                       if (length($tool)) {
+                               $ENV{GIT_DIFF_TOOL} = $tool;
+                       }
+                       next;
+               }
                if ($arg eq '-y' || $arg eq '--no-prompt') {
                        $ENV{GIT_DIFFTOOL_NO_PROMPT} = 'true';
                        delete $ENV{GIT_DIFFTOOL_PROMPT};