summaryrefslogtreecommitdiff
path: root/git-add--interactive.perl
diff options
context:
space:
mode:
authorJohn Keeping <john@keeping.me.uk>2013-06-12 18:44:10 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-06-12 20:41:19 (GMT)
commit2cc0f53b53e7d5456ec45713a201142754d69249 (patch)
tree94418ab8fab56d71df612e36144bfb54a472033f /git-add--interactive.perl
parentedca4152560522a431a51fc0a06147fc680b5b18 (diff)
downloadgit-2cc0f53b53e7d5456ec45713a201142754d69249.zip
git-2cc0f53b53e7d5456ec45713a201142754d69249.tar.gz
git-2cc0f53b53e7d5456ec45713a201142754d69249.tar.bz2
add--interactive: respect diff.algorithm
When staging hunks interactively it is sometimes useful to use an alternative diff algorithm which splits the changes into hunks in a more logical manner. This is not possible because the plumbing commands called by add--interactive ignore the "diff.algorithm" configuration option (as they should). Since add--interactive is a porcelain command it should respect this configuration variable. To do this, make it read diff.algorithm and pass its value to the underlying diff-index and diff-files invocations. At this point, do not add options to "git add", "git reset" or "git checkout" (all of which can call git-add--interactive). If a user wants to override the value on the command line they can use: git -c diff.algorithm=$ALGO ... Signed-off-by: John Keeping <john@keeping.me.uk> Reviewed-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-add--interactive.perl')
-rwxr-xr-xgit-add--interactive.perl5
1 files changed, 5 insertions, 0 deletions
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index d2c4ce6..5310959 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -44,6 +44,8 @@ my ($diff_new_color) =
my $normal_color = $repo->get_color("", "reset");
+my $diff_algorithm = $repo->config('diff.algorithm');
+
my $use_readkey = 0;
my $use_termcap = 0;
my %term_escapes;
@@ -731,6 +733,9 @@ sub run_git_apply {
sub parse_diff {
my ($path) = @_;
my @diff_cmd = split(" ", $patch_mode_flavour{DIFF});
+ if (defined $diff_algorithm) {
+ push @diff_cmd, "--diff-algorithm=${diff_algorithm}";
+ }
if (defined $patch_mode_revision) {
push @diff_cmd, $patch_mode_revision;
}