Skip to content

git: "could not find parent directory containing any of: .git" with --bare repos #2754

Open
@steschwa

Description

@steschwa

Current Behavior

I am using yadm to manage my dotfiles. What it basically does is run git init --bare /Users/foo/.local/share/yadm/repo.git and provide a cli tool yadm that has few own commands. Other commands (e.g. yadm add or yadm status) are directly passed through to git (https://github.com/yadm-dev/yadm/blob/bbb58e6625de5d934fd49b4b81c1981e137e3057/yadm#L151).

As carapace does not provide a builtin completer for yadm i tried creating my own spec:

# yaml-language-server: $schema=https://carapace.sh/schemas/command.json
name: yadm
run: "[git, --git-dir, /Users/foo/.local/share/yadm/repo.git]"

This works fine for basic stuff. yadm stat<tab> becomes yadm status, nice!

The problem is that yadm add <tab> prints could not find parent directory containing any of: ".git". However when i am inside a git-repo (e.g. my work repo which has nothing to do with my dotfiles) yadm add <tab> seems to work fine and correctly shows unstaged files in my dotfiles.
Calling the completer directy (atleast that's what i assume it does) with carapace git nushell "git" "--git-dir" "/Users/foo/.local/share/yadm/repo.git" "add" "" yields the same error.

Version

$ carapace --version
carapace-bin 1.3.0

OS

  • Darwin
  • Linux
  • Termux
  • Windows

Shell

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

Anything else?

I did some digging myself and here is the stacktrace i suspect:

  1. https://github.com/carapace-sh/carapace/blob/aac64bc4267f98146c4a73ecc74bc44fb20c72e7/pkg/traverse/traverse.go#L35
  2. if root, err := rootDir(c); err != nil {
  3. git.ActionChanges(git.ChangeOpts{Unstaged: true}).FilterArgs(),

Polar

Fund with Polar

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdarwinfundFundable with polar.shnushell

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions