Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
add -i: add function to format hunk header
author
Phillip Wood
<phillip.wood@dunelm.org.uk>
Mon, 19 Feb 2018 11:29:02 +0000
(11:29 +0000)
committer
Junio C Hamano
<gitster@pobox.com>
Tue, 20 Feb 2018 16:48:04 +0000
(08:48 -0800)
This code is duplicated in a couple of places so make it into a
function as we're going to add some more callers shortly.
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-add--interactive.perl
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
8279ed0
)
diff --git
a/git-add--interactive.perl
b/git-add--interactive.perl
index 28b325d75481b74e8f7b16485e1fc18ad854161c..64f869c3b7fe89ea698b78645554b94c665dcd6f 100755
(executable)
--- a/
git-add--interactive.perl
+++ b/
git-add--interactive.perl
@@
-751,6
+751,15
@@
sub parse_hunk_header {
return ($o_ofs, $o_cnt, $n_ofs, $n_cnt);
}
return ($o_ofs, $o_cnt, $n_ofs, $n_cnt);
}
+sub format_hunk_header {
+ my ($o_ofs, $o_cnt, $n_ofs, $n_cnt) = @_;
+ return ("@@ -$o_ofs" .
+ (($o_cnt != 1) ? ",$o_cnt" : '') .
+ " +$n_ofs" .
+ (($n_cnt != 1) ? ",$n_cnt" : '') .
+ " @@\n");
+}
+
sub split_hunk {
my ($text, $display) = @_;
my @split = ();
sub split_hunk {
my ($text, $display) = @_;
my @split = ();
@@
-838,11
+847,7
@@
sub split_hunk {
my $o_cnt = $hunk->{OCNT};
my $n_cnt = $hunk->{NCNT};
my $o_cnt = $hunk->{OCNT};
my $n_cnt = $hunk->{NCNT};
- my $head = ("@@ -$o_ofs" .
- (($o_cnt != 1) ? ",$o_cnt" : '') .
- " +$n_ofs" .
- (($n_cnt != 1) ? ",$n_cnt" : '') .
- " @@\n");
+ my $head = format_hunk_header($o_ofs, $o_cnt, $n_ofs, $n_cnt);
my $display_head = $head;
unshift @{$hunk->{TEXT}}, $head;
if ($diff_use_color) {
my $display_head = $head;
unshift @{$hunk->{TEXT}}, $head;
if ($diff_use_color) {
@@
-912,11
+917,7
@@
sub merge_hunk {
}
push @line, $line;
}
}
push @line, $line;
}
- my $head = ("@@ -$o0_ofs" .
- (($o_cnt != 1) ? ",$o_cnt" : '') .
- " +$n0_ofs" .
- (($n_cnt != 1) ? ",$n_cnt" : '') .
- " @@\n");
+ my $head = format_hunk_header($o0_ofs, $o_cnt, $n0_ofs, $n_cnt);
@{$prev->{TEXT}} = ($head, @line);
}
@{$prev->{TEXT}} = ($head, @line);
}