1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-08-17 00:30:26 +03:00

Merge remote-tracking branch 'krobelus/patch-context-only-filediff'

This commit is contained in:
Maxime Coste 2024-01-22 20:23:52 +11:00
commit 1194aa861e
5 changed files with 39 additions and 1 deletions

View File

@ -18,6 +18,7 @@ my $reverse = grep /^(--reverse|-R)$/, @ARGV;
my $lineno = 0;
my $original = "";
my $diff_header = "";
my $wheat = "";
my $chaff = "";
my $state = undef;
@ -41,6 +42,10 @@ sub compute_hunk_header {
sub finish_hunk {
return unless defined $hunk_header;
if ($hunk_wheat =~ m{^[-+]}m) {
if ($diff_header) {
$wheat .= $diff_header;
$diff_header = "";
}
$wheat .= (compute_hunk_header $hunk_header, $hunk_wheat). $hunk_wheat;
}
$chaff .= (compute_hunk_header $hunk_header, $hunk_chaff) . $hunk_chaff;
@ -53,6 +58,7 @@ while (<STDIN>) {
if (m{^diff}) {
finish_hunk();
$state = "diff header";
$diff_header = "";
}
if (m{^@@}) {
finish_hunk();
@ -63,7 +69,7 @@ while (<STDIN>) {
next;
}
if ($state eq "diff header") {
$wheat .= $_;
$diff_header .= $_;
$chaff .= $_;
next;
}

View File

@ -0,0 +1 @@
%:patch tee applied.diff<ret><ret>!echo Applied:; cat applied.diff; echo; echo Updated buffer:<ret>

View File

@ -0,0 +1,11 @@
diff -ur a/file1 b/file1
--- a/file1
+++ b/file1
@@ -1 +1 @@
file1 here
diff -ur a/file2 b/file2
--- a/file2
+++ b/file2
@@ -1 +1 @@
-file2 here
+modified file2 here

View File

@ -0,0 +1,19 @@
Applied:
diff -ur a/file2 b/file2
--- a/file2
+++ b/file2
@@ -1 +1 @@
-file2 here
+modified file2 here
Updated buffer:
diff -ur a/file1 b/file1
--- a/file1
+++ b/file1
@@ -1 +1 @@
file1 here
diff -ur a/file2 b/file2
--- a/file2
+++ b/file2
@@ -1 +1 @@
modified file2 here

View File

@ -0,0 +1 @@
source "%val{runtime}/rc/tools/patch.kak"