Staging
v0.5.1
https://github.com/git/git
Revision b0883aa6c77111e88496bd0afe073caf68ab9f99 authored by Junio C Hamano on 30 January 2010, 20:08:26 UTC, committed by Junio C Hamano on 30 January 2010, 21:56:56 UTC
Even when the environment was given for the top-level process, checking
in the submodule work tree should use the index file associated with the
work tree of the submodule.  Do not export it to the environment.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent a9c7c43
Raw File
Tip revision: b0883aa6c77111e88496bd0afe073caf68ab9f99 authored by Junio C Hamano on 30 January 2010, 20:08:26 UTC
is_submodule_modified(): fix breakage with external GIT_INDEX_FILE
Tip revision: b0883aa
git-difftool.perl
#!/usr/bin/env perl
# Copyright (c) 2009, 2010 David Aguilar
#
# This is a wrapper around the GIT_EXTERNAL_DIFF-compatible
# git-difftool--helper script.
#
# This script exports GIT_EXTERNAL_DIFF and GIT_PAGER for use by git.
# GIT_DIFFTOOL_NO_PROMPT, GIT_DIFFTOOL_PROMPT, and GIT_DIFF_TOOL
# are exported for use by git-difftool--helper.
#
# Any arguments that are unknown to this script are forwarded to 'git diff'.

use strict;
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 [-t|--tool=<tool>] [-x|--extcmd=<cmd>]
                    [-y|--no-prompt]   [-g|--gui]
                    ['git diff' options]
USAGE
	exit 1;
}

sub setup_environment
{
	$ENV{PATH} = "$DIR:$ENV{PATH}";
	$ENV{GIT_PAGER} = '';
	$ENV{GIT_EXTERNAL_DIFF} = 'git-difftool--helper';
}

sub exe
{
	my $exe = shift;
	if ($^O eq 'MSWin32' || $^O eq 'msys') {
		return "$exe.exe";
	}
	return $exe;
}

sub generate_command
{
	my @command = (exe('git'), 'diff');
	my $skip_next = 0;
	my $idx = -1;
	for my $arg (@ARGV) {
		$idx++;
		if ($skip_next) {
			$skip_next = 0;
			next;
		}
		if ($arg eq '-t' || $arg eq '--tool') {
			usage() if $#ARGV <= $idx;
			$ENV{GIT_DIFF_TOOL} = $ARGV[$idx + 1];
			$skip_next = 1;
			next;
		}
		if ($arg =~ /^--tool=/) {
			$ENV{GIT_DIFF_TOOL} = substr($arg, 7);
			next;
		}
		if ($arg eq '-x' || $arg eq '--extcmd') {
			usage() if $#ARGV <= $idx;
			$ENV{GIT_DIFFTOOL_EXTCMD} = $ARGV[$idx + 1];
			$skip_next = 1;
			next;
		}
		if ($arg =~ /^--extcmd=/) {
			$ENV{GIT_DIFFTOOL_EXTCMD} = substr($arg, 9);
			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};
			next;
		}
		if ($arg eq '--prompt') {
			$ENV{GIT_DIFFTOOL_PROMPT} = 'true';
			delete $ENV{GIT_DIFFTOOL_NO_PROMPT};
			next;
		}
		if ($arg eq '-h' || $arg eq '--help') {
			usage();
		}
		push @command, $arg;
	}
	return @command
}

setup_environment();

# ActiveState Perl for Win32 does not implement POSIX semantics of
# exec* system call. It just spawns the given executable and finishes
# the starting program, exiting with code 0.
# system will at least catch the errors returned by git diff,
# allowing the caller of git difftool better handling of failures.
my $rc = system(generate_command());
exit($rc | ($rc >> 8));
back to top