Add instructions for creating patches.
Bug: http://b/339424309
Test: treehugger
Change-Id: I74380c4d622476f1c4bc0c4e3acc33801ad69303
diff --git a/README.md b/README.md
index ec7b66e..e9c96f5 100644
--- a/README.md
+++ b/README.md
@@ -85,6 +85,24 @@
./crate_tool try-updates | tee crate-updates
```
+## How to add a patch file
+
+You should avoid creating patches, if possible. Every patch file is an ongoing
+operational burden that makes it more difficult to keep our crates up-to-date.
+
+If a patch is absolutely necessary, you should, if possible, send a pull
+request to the upstream crate, so we can eliminate the Android patch in the
+future, when upgrading.
+
+To create a patch for crate "foo", edit the files directly. Then do:
+
+```
+git diff --relative=crates/foo -- crates/foo/<file1> crates/foo/<file2> > patches/<name>.patch`
+```
+
+If you stage or commit the change and the patch, you should see no new changes
+when you run "regenerate".
+
## I want to know how the sausage is made
The source code for `crate_tool` is [here](https://android.googlesource.com/platform/development/+/refs/heads/main/tools/external_crates/).
@@ -113,4 +131,4 @@
* `cargo remove <crate_name>`
* `cargo add <crate_name>@=<version>`
-* `./crate_tool regenerate <crate name>`
\ No newline at end of file
+* `./crate_tool regenerate <crate name>`