Skip to content

Cannot git autocomplete single file from newly-added subdirectory #5229

Closed

Description

@mqudsi
mkdir foo; cd foo;
git init .
mkdir bar
touch bar/baz
git add bar<TAB> # or git add bar/<TAB>

The git completion is not aware of the contents of the new subdirectory bar, and does not offer bar/baz as a completion no matter what.

Activity

  1. faho commented on Oct 4, 2018

    @faho
    Member

    This offers "bar/" for me, which is a result of using git status -unormal instead of "-uall". We might want to rethink that.

  2. faho commented on Oct 4, 2018

    @faho
    Member

    Note that "uall" can be quite slow, so we might want to couple this with limiting to the current directory (via commandline -ct)

  3. added this to the fish-3.0 milestone on Oct 4, 2018
  4. mqudsi commented on Oct 4, 2018

    @mqudsi
    ContributorAuthor

    Thanks for digging into it. Normally fish does not dig into a directory (nor offer recursive completions) unless that directory has been typed out at the command prompt, so I imagine we can special-case the completion code to use -uall when commandline -ct | string match -qe / is true, then restrict the search to commandline -ct | string replace -r '/.*' '/'?

    Edit: Never mind. That's exactly what you just said. 🤦‍♀️

  5. faho commented on Oct 4, 2018

    @faho
    Member

    I imagine we can special-case the completion code to use -uall when commandline -ct | string match -qe / is true, then restrict the search to commandline -ct | string replace -r '/.*' '/'?

    No need to even do something that complex - it turns out that commandline arguments are always checked, so git status -unormal (commandline -ct)* would work. There's some ramifications to that, and I'm not sure if we want to do the glob or let git do it.

  6. mqudsi commented on Oct 14, 2018

    @mqudsi
    ContributorAuthor

    I'm not sure if we want to do the glob or let git do it.

    With my recent experience in mind: whichever one is faster 😄

  7. mqudsi commented on Oct 23, 2018

    @mqudsi
    ContributorAuthor

    @faho I don't know if you'd prefer a separate issue for these, but

    • git checkout COMMITISH <TAB> should complete files that were in the repo at that time
    • git show <TAB> should offer local and remote branches, not just commitishes
    • git show COMMITISH:<TAB> should complete files that were in the repo at that time
    • git bisect has a well defined format (that also stupidly breaks with all git conventions) and takes a sub-sub-command instead of an argument. It should be straightforward, though.
  8. faho commented on Oct 24, 2018

    @faho
    Member

    git show should offer local and remote branches, not just commitishes

    It does.

    The rest just haven't been added. Any idea how to complete "files at the time"?

    (This is why I said that doing git completions could be a full time job)

  9. faho commented on Oct 24, 2018

    @faho
    Member

    git bisect has a well defined format (that also stupidly breaks with all git conventions) and takes a sub-sub-command instead of an argument.

    Not really - stash also does sub-subcommand.

  10. mqudsi commented on Oct 27, 2018

    @mqudsi
    ContributorAuthor

    It does.

    You're right. In a repo like fish, it's just impossible to see them in the autocompleter because of the ordering of results.

    Can you please universally add a rule for --? git checkout -- should complete files (theoretically from HEAD, but it's OK if just locally) but instead it exhibits #5237

  11. faho commented on Oct 28, 2018

    @faho
    Member

    git checkout -- should complete files (theoretically from HEAD, but it's OK if just locally)

    Well.. no? I mean if you do git checkout -- README.md, and README.md exists and is known to git, that won't error out, but unless README.md is deleted or modified that command should be useless.

    Which is why checkout already has:

    complete -k -f -c git -n '__fish_git_using_command checkout' -a '(__fish_git_files modified deleted)'

    If we can reliably determine which files are useful we should only offer those, because the other files are just noise.

    Or am I missing something?

    (This probably triggers 5237 because of the "--")

  12. mqudsi commented on Oct 28, 2018

    @mqudsi
    ContributorAuthor

    Hmm, I can't remember now but it was in the middle of a partial rebase and I needed to checkout the file to restore some changes or something. I will post back if/when I can repro.

  13. added a commit that references this issue on Nov 24, 2018
    3130fa2
  14. locked as resolved and limited conversation to collaborators on Apr 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions