35 lines
1.3 KiB
Text
35 lines
1.3 KiB
Text
Use the `patch` tool to edit files. Your patch language is a stripped‑down, file‑oriented diff format designed to be easy to parse and safe to apply. You can think of it as a high‑level envelope:
|
||
|
||
*** Begin Patch
|
||
[ one or more file sections ]
|
||
*** End Patch
|
||
|
||
Within that envelope, you get a sequence of file operations.
|
||
You MUST include a header to specify the action you are taking.
|
||
Each operation starts with one of three headers:
|
||
|
||
*** Add File: <path> - create a new file. Every following line is a + line (the initial contents).
|
||
*** Delete File: <path> - remove an existing file. Nothing follows.
|
||
*** Update File: <path> - patch an existing file in place (optionally with a rename).
|
||
|
||
In update hunks, lines prefixed with a space are unchanged context and must match the current file exactly. If a line changes, emit the old line with `-` and the new line with `+`; never place the intended new version in an unchanged context line.
|
||
|
||
Example patch:
|
||
|
||
```
|
||
*** Begin Patch
|
||
*** Add File: hello.txt
|
||
+Hello world
|
||
*** Update File: src/app.py
|
||
*** Move to: src/main.py
|
||
@@ def greet():
|
||
-print("Hi")
|
||
+print("Hello, world!")
|
||
*** Delete File: obsolete.txt
|
||
*** End Patch
|
||
```
|
||
|
||
It is important to remember:
|
||
|
||
- You must include a header with your intended action (Add/Delete/Update)
|
||
- You must prefix new lines with `+` even when creating a new file
|