aboutsummaryrefslogtreecommitdiffstats
path: root/lib/pama/revctrl/git.go
diff options
context:
space:
mode:
Diffstat (limited to 'lib/pama/revctrl/git.go')
-rw-r--r--lib/pama/revctrl/git.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/pama/revctrl/git.go b/lib/pama/revctrl/git.go
index f4b78dd5..7be9de58 100644
--- a/lib/pama/revctrl/git.go
+++ b/lib/pama/revctrl/git.go
@@ -98,6 +98,22 @@ func (g git) Clean() bool {
return len(s) == 0 && exitcode == 0 && err == nil
}
+func (g git) CreateWorktree(target, commit string) error {
+ _, exitcode, err := g.do("worktree", "add", target, commit)
+ if exitcode > 0 {
+ return fmt.Errorf("failed to create worktree in %s: %w", target, err)
+ }
+ return err
+}
+
+func (g git) DeleteWorktree(target string) error {
+ _, exitcode, err := g.do("worktree", "remove", target)
+ if exitcode > 0 {
+ return fmt.Errorf("failed to delete worktree in %s: %w", target, err)
+ }
+ return err
+}
+
func (g git) ApplyCmd() string {
// TODO: should we return a *exec.Cmd instead of a string?
return fmt.Sprintf("git -C %s am -3 --empty drop", g.path)