Skip to content

Git checkout action does not show file completions #3310

@anjos

Description

@anjos

Current Behavior

When using git checkout TAB completion via carapace, (modified) files are not shown as options one can select from. That would be a nice to have.

Furthermore, if I type the first letter of the file to be reset (via checkout), then carapace will also not auto-complete it. It does not match the behaviour of the fish completer, for instance.

Expected Behavior

I'd expect the completer offers (modified) file completion on git checkout.

If not explicitly, then it should also not get in the way and allow me to complete the full filename after typing the first few characters. Currently, this does not work.

Steps To Reproduce

$ git status
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   AGENTS.md

no changes added to commit (use "git add" and/or "git commit -a")
$ git checkout <TAB>
HEAD  (project: improve agent init file)  origin/main  (project: improve agent init file)
main  (project: improve agent init file)  ORIG_HEAD                       ([tasks] Debug)

Note this will not auto-complete either:

$ git checkout AG<TAB>
# nothing happens!

I guess I'm using the completer from the core carapace:

$ carapace --list git
{
  "git": [
    {
      "name": "git",
      "description": "the stupid content tracker",
      "group": "common",
      "package": "github.com/carapace-sh/carapace-bin/completers/common/git_completer/cmd",
      "url": "https://git-scm.com/"
    },
    {
      "name": "git",
      "description": "the stupid content tracker",
      "group": "bridge",
      "variant": "fish"
    }
  ]
}

If I switch to the fish bridge, via carapace --choice git/fish@bridge, then it shows me a different behaviour:

$ carapace --choice git/fish@bridge
$ git checkout <TAB>
0c9d591                              (project: ignore theme while doing qa)
2bc0d3b                                         (pixi: reduce startup deps)
4d386a2                         (git: ensure cleaness before using subrepo)
7d3897d                                  (project: improve agent init file)
08b7102                  (lib/gitlab: only assign macos runners if need be)
8f6b5f4                                          (git: update ignore rules)
9c7b024                    (project: use subrepo instead of git submodules)
31be65d                                       (overleaf: add setup support)
35ee896                          (project: require bash>=4 for git subrepo)
37a2613                   (project: add overleaf support with a .latexmkrc)
39f84e4                                    (tests: do not expect submodule)
70a4381                         (project/.scripts: fix template resolution)
091cded                                         (pixi: avoid double-update)
92d0750                                    (overleaf: improve sync scripts)
93ae5be               (readme: reduce number of required packages to start)
96a92a8                           (overleaf: complete workflow integration)
246ba3b       (Implement gitlab project initialisation support (closes carapace-sh/carapace#1))
442e180                          (agents: add support for AI-coding agents)
467fdff                                        (tests: enable update check)
469cb4f                                                 (project: fix deps)
671af3b  (copier: use [[ instead of {{ to better cope with latex templates)
743d948     (pixi: update environment; add git-subrepo on linux-64 for now)
963f01f                  (project/pixi: setup correct theme update command)
1681cf8                                                   (Move repository)
2528b71                                 (lib/pixi: use current environment)
…and 31 more rows

However, if at this point I start typing the filename, a new TAB will work as expected.

To be complete, this should show:

  1. Modified files
  2. Branches
  3. Specific commits
  4. Tags(?)

Version

carapace-bin 1.6.3

OS

  • Darwin
  • Linux
  • Termux
  • Windows

Shell

  • Bash
  • Cmd
  • Elvish
  • Fish
  • Nushell
  • Oil
  • Powershell
  • Xonsh
  • Zsh

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdarwinfishfundFundable with polar.sh

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions