git-add--interactive: remove hunk coalescing
Current git-apply has no trouble at all applying chunks that have overlapping context, as produced by the splitting feature. So we can drop the manual coalescing. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Thomas Rast committed
Jul 2, 2008 at 23:59 UTC
0beee4c6dec15292415e3d56075c16a76a22af54
1 file changed
-89
git-add--interactive.perl
-89
@@ -682,93 +682,6 @@ sub split_hunk {
682
return @split;
683
}
684
685
-sub find_last_o_ctx {
686
- my ($it) = @_;
687
- my $text = $it->{TEXT};
688
- my ($o_ofs, $o_cnt) = parse_hunk_header($text->[0]);
689
- my $i = @{$text};
690
- my $last_o_ctx = $o_ofs + $o_cnt;
691
- while (0 < --$i) {
692
- my $line = $text->[$i];
693
- if ($line =~ /^ /) {
694
- $last_o_ctx--;
695
- next;
696
- }
697
- last;
698
- }
699
- return $last_o_ctx;
700
-}
701
-
702
-sub merge_hunk {
703
- my ($prev, $this) = @_;
704
- my ($o0_ofs, $o0_cnt, $n0_ofs, $n0_cnt) =
705
- parse_hunk_header($prev->{TEXT}[0]);
706
- my ($o1_ofs, $o1_cnt, $n1_ofs, $n1_cnt) =
707
- parse_hunk_header($this->{TEXT}[0]);
708
-
709
- my (@line, $i, $ofs, $o_cnt, $n_cnt);
710
- $ofs = $o0_ofs;
711
- $o_cnt = $n_cnt = 0;
712
- for ($i = 1; $i < @{$prev->{TEXT}}; $i++) {
713
- my $line = $prev->{TEXT}[$i];
714
- if ($line =~ /^\+/) {
715
- $n_cnt++;
716
- push @line, $line;
717
- next;
718
- }
719
-
720
- last if ($o1_ofs <= $ofs);
721
-
722
- $o_cnt++;
723
- $ofs++;
724
- if ($line =~ /^ /) {
725
- $n_cnt++;
726
- }
727
- push @line, $line;
728
- }
729
-
730
- for ($i = 1; $i < @{$this->{TEXT}}; $i++) {
731
- my $line = $this->{TEXT}[$i];
732
- if ($line =~ /^\+/) {
733
- $n_cnt++;
734
- push @line, $line;
735
- next;
736
- }
737
- $ofs++;
738
- $o_cnt++;
739
- if ($line =~ /^ /) {
740
- $n_cnt++;
741
- }
742
- push @line, $line;
743
- }
744
- my $head = ("@@ -$o0_ofs" .
745
- (($o_cnt != 1) ? ",$o_cnt" : '') .
746
- " +$n0_ofs" .
747
- (($n_cnt != 1) ? ",$n_cnt" : '') .
748
- " @@\n");
749
- @{$prev->{TEXT}} = ($head, @line);
750
-}
751
-
752
-sub coalesce_overlapping_hunks {
753
- my (@in) = @_;
754
- my @out = ();
755
-
756
- my ($last_o_ctx);
757
-
758
- for (grep { $_->{USE} } @in) {
759
- my $text = $_->{TEXT};
760
- my ($o_ofs) = parse_hunk_header($text->[0]);
761
- if (defined $last_o_ctx &&
762
- $o_ofs <= $last_o_ctx) {
763
- merge_hunk($out[-1], $_);
764
- }
765
- else {
766
- push @out, $_;
767
- }
768
- $last_o_ctx = find_last_o_ctx($out[-1]);
769
- }
770
- return @out;
771
-}
685
686
sub help_patch_cmd {
687
print colored $help_color, <<\EOF ;
@@ -962,8 +875,6 @@ sub patch_update_file {
875
}
876
}
877
965
- @hunk = coalesce_overlapping_hunks(@hunk);
966
-
878
my $n_lofs = 0;
879
my @result = ();
880
if ($mode->{USE}) {