OpenForm
CLICommands

apply

Last updated on

Apply a unified diff patch

Applies a unified diff patch to the working directory.

Usage

ofm apply <patch-file> [options]

Arguments

ArgumentDescription
patch-filePatch file to apply

Options

OptionDescription
--checkCheck if the patch can be applied cleanly
--reverseApply the patch in reverse
--dry-runShow what would change without modifying files

Description

The apply command reads a unified diff patch file and applies the changes to the working directory. It supports creating new files, modifying existing files, and deleting files based on the patch content.

After applying, modified artifacts are automatically validated.

Examples

Apply a patch:

ofm apply changes.patch

Check if patch applies cleanly:

ofm apply changes.patch --check

Preview changes:

ofm apply changes.patch --dry-run

Reverse a patch:

ofm apply changes.patch --reverse

Output

Successful application:

Found 2 file(s) in patch changes.patch

✓ Applied to lease-agreement.yaml
✓ Applied to checklist.yaml

Successfully applied 2 patch(es)

Modified files:
  lease-agreement.yaml
  checklist.yaml

Next steps:
  ofm status
  ofm diff
  ofm add <files>
  ofm commit -m "message"

Validating modified artifacts...
  ✓ lease-agreement.yaml is valid
  ✓ checklist.yaml is valid

Check mode:

Checking patches...
✓ lease-agreement.yaml: OK
✗ checklist.yaml: FAILED

Some patches cannot be applied (conflicts detected)

See also

  • diff - Generate diffs between files
  • validate - Validate artifacts

On this page