Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion completers/git_completer/cmd/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func actionDiffArgs(cmd *cobra.Command) carapace.Action {
var action carapace.Action
if cmd.Flag("cached").Changed {
if len(expanded) > 0 {
action = git.ActionCachedDiffs(expanded[0])
action = git.ActionCachedRefDiffs(expanded[0])
}
} else {
action = git.ActionRefDiffs(expanded...)
Expand Down
7 changes: 7 additions & 0 deletions completers/git_completer/cmd/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,15 @@ func init() {
carapace.Gen(restoreCmd).PositionalAnyCompletion(
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
if restoreCmd.Flag("staged").Changed {
if f := restoreCmd.Flag("source"); f.Changed {
return git.ActionCachedRefDiffs(f.Value.String())
}
return git.ActionChanges(git.ChangeOpts{Staged: true}).FilterArgs()
}

if f := restoreCmd.Flag("source"); f.Changed {
return git.ActionRefDiffs(f.Value.String())
}
return git.ActionChanges(git.ChangeOpts{Unstaged: true}).FilterArgs()
}),
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/actions/tools/git/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func ActionRefDiffs(refs ...string) carapace.Action {
}

// ActionCachedDiffs completes changes between stage and given ref
func ActionCachedDiffs(ref string) carapace.Action {
func ActionCachedRefDiffs(ref string) carapace.Action {
return actionRefDiffs(true, ref)
}

Expand Down