From 273379260c26119280652729fd796541870a6fbb Mon Sep 17 00:00:00 2001 From: Andy Lin Date: Sun, 4 Feb 2024 16:18:56 -0600 Subject: [PATCH 1/2] apply-patch.sh: fix patch finding The original script finds patch files that have two hard links. But the links seem to be soft links (at least after git clone). So maybe we should use the .patch suffix to find the patch files instead. --- apply-patch.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/apply-patch.sh b/apply-patch.sh index c8e2ddd..ee9be6d 100755 --- a/apply-patch.sh +++ b/apply-patch.sh @@ -25,10 +25,15 @@ if [ ! -d $patch_dir ];then exit 1 fi +echo "Begin to apply patches from $patch_dir" cd $patch_dir -for p in `find * -links 2` +pwd +for p in `find *` do - echo - echo "process project: $p" - git -C $src/$p am --reject $patch_dir/$p/* || echo "*****[ERROR]***** apply failed: $p" + # if this is a patch file that ends with .patch + if [[ $p == *.patch ]]; then + project_dir=$(dirname $p) + echo "process project: $project_dir" + git -C $src/$project_dir apply --reject $patch_dir/$p || echo "*****[ERROR]***** apply failed: $p" + fi done From 5536686d25b7db6e425dc5acc0fe8b381f6a9cd9 Mon Sep 17 00:00:00 2001 From: Andy Lin Date: Tue, 6 Feb 2024 03:29:43 -0600 Subject: [PATCH 2/2] apply-patch.sh: deduplicate found leaf dirs --- apply-patch.sh | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/apply-patch.sh b/apply-patch.sh index ee9be6d..3a85c28 100755 --- a/apply-patch.sh +++ b/apply-patch.sh @@ -25,15 +25,11 @@ if [ ! -d $patch_dir ];then exit 1 fi -echo "Begin to apply patches from $patch_dir" cd $patch_dir -pwd -for p in `find *` +leaf_dirs=$(find . -type d -exec sh -c '(ls -p "{}" | grep / > /dev/null) || echo "{}"' \;) +for p in $leaf_dirs do - # if this is a patch file that ends with .patch - if [[ $p == *.patch ]]; then - project_dir=$(dirname $p) - echo "process project: $project_dir" - git -C $src/$project_dir apply --reject $patch_dir/$p || echo "*****[ERROR]***** apply failed: $p" - fi + echo + echo "process project: $p" + git -C $src/$p am --reject $patch_dir/$p/* || echo "*****[ERROR]***** apply failed: $p" done