shithub: git9

Download patch

ref: abbb4f0afe86353d767254afce3ba691ee9f12db
parent: 215c3439912b03036266910eacd74e2f46f99bd8
author: Ori Bernstein <ori@eigenstate.org>
date: Thu Dec 3 00:10:48 EST 2020

git/import: avoid adding nonexistent files

When importing patches with hunk offsets, some extra lines
are printed when files are patched. Since we use the output
to know which files to add or remove, this can lead to an
attempt to add nonexistent files.

Filter down to just the output about patching, so we don't
print spurious messages.

--- a/import
+++ b/import
@@ -69,7 +69,7 @@
 	rc -c '
 		echo applying $msg | sed 1q
 		date=`{seconds $date}
-		if(! files=`$nl{ape/patch -Ep1 < $diffpath | sed ''s/^patching file `(.*)''''/\1/''})
+		if(! files=`$nl{ape/patch -Ep1 < $diffpath | grep '^patching file' | sed ''s/^patching file `(.*)''''/\1/''})
 			die ''patch failed''
 		for(f in $files){
 			if(test -e $f)