Skip to content

Commit 6a6b923

Browse files
committed
support muting of staging
1 parent 3420b9e commit 6a6b923

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

git/git.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ func Worktree(ctx context.Context, repo *Repository) *Tree {
111111
}
112112

113113
func Add(ctx context.Context, wt *Tree, path ns.NS) {
114+
if IsStagingMuted(ctx) {
115+
return
116+
}
114117
if _, err := wt.Add(path.GitPath()); err != nil {
115118
must.Panic(ctx, err)
116119
}

git/mute.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package git
2+
3+
import "context"
4+
5+
type muteStagingCtxKey struct{}
6+
7+
func MuteStaging(ctx context.Context) context.Context {
8+
return context.WithValue(ctx, muteStagingCtxKey{}, true)
9+
}
10+
11+
func UnmuteStaging(ctx context.Context) context.Context {
12+
return context.WithValue(ctx, muteStagingCtxKey{}, false)
13+
}
14+
15+
func IsStagingMuted(ctx context.Context) bool {
16+
v, ok := ctx.Value(muteStagingCtxKey{}).(bool)
17+
return ok && v
18+
}

0 commit comments

Comments
 (0)