Background:
[2021-07-14 23:00:25]» diff -v
diff (GNU diffutils) 3.6
[2021-07-14 23:04:05]» patch -v
GNU patch 2.7.6
[2021-07-14 23:04:20]» pwd
/home/chb/code/work/bar/baz/master
I'm in a directory that's many levels above a file I'm patching. I'm usign the -u flag to diff in the hope that patch will read the file paths in the unified output and patch the file accordingly. Both files are text files, so I'm also using the -a flag.
Problem:
I've tried many combinations of flags and none seem to actually get patch to work:
[2021-07-14 23:06:48]❮ diff -au bck/foundation/modules/iam/main.tf ../bck_cluster/bck/foundation/modules/iam/main.tf > au.patch
[2021-07-14 23:13:40]» cat au.patch
--- bck/foundation/modules/iam/main.tf 2021-07-14 16:50:49.131517079 -0400
+++ ../bck_cluster/bck/foundation/modules/iam/main.tf 2021-07-14 16:39:47.122605198 -0400
@@ -38,7 +38,7 @@
resource "google_project_iam_member" "bck_cloudsql_admin" {
project = var.project_id
- role = "roles/cloudsql.editor"
+ role = "roles/cloudsql.admin"
member = "serviceAccount:${google_service_account.project_service_account.email}"
}
[2021-07-14 23:15:35]» patch --verbose < au.patch
Hmm... I can't seem to find a patch in there anywhere.
patch: **** Only garbage was found in the patch input.
[2021-07-14 23:16:30]» pwd
/home/chb/code/work/bar/baz/master
Though I know it's not necessary to adjust the paths present at the top of the file, I'm ready to try anything:
[2021-07-14 23:16:19]» patch --verbose -p0 < au.patch
Hmm... I can't seem to find a patch in there anywhere.
patch: **** Only garbage was found in the patch input.
[2021-07-14 23:16:26]» patch --verbose -p1 < au.patch
Hmm... I can't seem to find a patch in there anywhere.
patch: **** Only garbage was found in the patch input.
Maybe this situation requires a context diff and not a unified diff?
[2021-07-14 23:21:17]» diff -ac bck/foundation/modules/iam/main.tf ../bck_cluster/bck/foundation/modules/iam/main.tf > ca.patch
[2021-07-14 23:22:42]» patch --verbose < ca.patch
Hmm... I can't seem to find a patch in there anywhere.
patch: **** Only garbage was found in the patch input.
After reading "NOTES FOR PATCH SENDERS" in the man page, I tried changing directories and then running diff and patch in the common parent directory of both paths. Same error.
What am I doing wrong?