Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git: diff - fix refrange #2117

Merged
merged 1 commit into from
Jan 5, 2024
Merged
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
8 changes: 4 additions & 4 deletions completers/git_completer/cmd/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func init() {

filtered := make([]string, 0)
for index, arg := range c.Args {
if index == 0 && strings.Contains(arg, "...") { // assume refrange - TODO what about '{ref}..{ref}'
if index == 0 && strings.Contains(arg, "..") { // assume refrange - TODO what about '{ref}...{ref}'
filtered = append(filtered, arg)
break
}
Expand All @@ -54,7 +54,7 @@ func init() {
batch = append(batch, git.ActionRefRanges(git.RefOption{}.Default()))
default:
switch {
case strings.Contains(c.Args[0], "..."): // skip if we already have a refrange
case strings.Contains(c.Args[0], ".."): // skip if we already have a refrange
case diffCmd.Flag("cached").Changed: // skip as '-cached' accepts only on ref
default:
batch = append(batch, git.ActionRefs(git.RefOption{}.Default()))
Expand All @@ -63,8 +63,8 @@ func init() {
}

if len(filtered) > 0 {
// TODO support/suppress '{ref}..{ref}'??
filtered = append(strings.SplitN(filtered[0], "...", 2), filtered[1:]...) // split refrange if any
// TODO support/suppress '{ref}...{ref}'??
filtered = append(strings.SplitN(filtered[0], "..", 2), filtered[1:]...) // split refrange if any
}

switch len(filtered) {
Expand Down