diff --git a/pkg/actions/tools/git/commit.go b/pkg/actions/tools/git/commit.go index 5e5c6f6625..c6c7cff597 100644 --- a/pkg/actions/tools/git/commit.go +++ b/pkg/actions/tools/git/commit.go @@ -21,7 +21,12 @@ func ActionHeadCommits(limit int) carapace.Action { vals := make([]string, 0) for index, line := range lines[:len(lines)-1] { - vals = append(vals, "HEAD~"+fmt.Sprintf("%0"+strconv.Itoa(len(strconv.Itoa(limit-1)))+"d", index), strings.TrimSpace(line[10:])) + switch index { + case 0: + vals = append(vals, "HEAD~", strings.TrimSpace(line[10:])) + default: + vals = append(vals, "HEAD~"+fmt.Sprintf("%0"+strconv.Itoa(len(strconv.Itoa(limit-1)))+"d", index), strings.TrimSpace(line[10:])) + } } return carapace.ActionValuesDescribed(vals...).Style(styles.Git.HeadCommit) }) diff --git a/pkg/actions/tools/git/ref.go b/pkg/actions/tools/git/ref.go index 7b0016c4bf..7b7e0acaef 100644 --- a/pkg/actions/tools/git/ref.go +++ b/pkg/actions/tools/git/ref.go @@ -54,7 +54,7 @@ func ActionRefs(refOption RefOption) carapace.Action { } if refOption.HeadCommits { - batch = append(batch, carapace.ActionValues("HEAD~").NoSpace('~')) + batch = append(batch, ActionHeadCommits(1).NoSpace('~')) } if refOption.Tags {