Skip to content

Commit 2cc0f53

Browse files
johnkeepinggitster
authored andcommitted
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 <[email protected]> Reviewed-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent edca415 commit 2cc0f53

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

git-add--interactive.perl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444

4545
my $normal_color = $repo->get_color("", "reset");
4646

47+
my $diff_algorithm = $repo->config('diff.algorithm');
48+
4749
my $use_readkey = 0;
4850
my $use_termcap = 0;
4951
my %term_escapes;
@@ -731,6 +733,9 @@ sub run_git_apply {
731733
sub parse_diff {
732734
my ($path) = @_;
733735
my @diff_cmd = split(" ", $patch_mode_flavour{DIFF});
736+
if (defined $diff_algorithm) {
737+
push @diff_cmd, "--diff-algorithm=${diff_algorithm}";
738+
}
734739
if (defined $patch_mode_revision) {
735740
push @diff_cmd, $patch_mode_revision;
736741
}

0 commit comments

Comments
 (0)