Skip to content

Commit

Permalink
Merge pull request #2117 from rsteube/git-diff-refrange
Browse files Browse the repository at this point in the history
git: diff - fix refrange
  • Loading branch information
rsteube authored Jan 5, 2024
2 parents 074d27f + 5c8fecd commit a2d81ec
Showing 1 changed file with 4 additions and 4 deletions.
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

0 comments on commit a2d81ec

Please sign in to comment.