Skip to content
This repository has been archived by the owner on May 8, 2024. It is now read-only.

Gina add % fails when pwd is not git root #188

Open
lambdalisue opened this issue Dec 25, 2018 · 4 comments
Open

Gina add % fails when pwd is not git root #188

lambdalisue opened this issue Dec 25, 2018 · 4 comments

Comments

@lambdalisue
Copy link
Owner

  1. cd gina.vim && vim
  2. :cd autoload
  3. :e test
  4. :w
  5. :Gina add %
  6. :Gina status
@lambdalisue
Copy link
Owner Author

lambdalisue commented Dec 25, 2018

The :Gina add % executes a command as

git -C {repository} ... add test

And the -C seems the reason while

       -C <path>
           Run as if git was started in <path> instead of the current working directory. When multiple -C options are given, each subsequent
           non-absolute -C <path> is interpreted relative to the preceding -C <path>.

           This option affects options that expect path name like --git-dir and --work-tree in that their interpretations of the path names would
           be made relative to the working directory caused by the -C option. For example the following invocations are equivalent:

               git --git-dir=a.git --work-tree=b -C c status
               git --git-dir=c/a.git --work-tree=c/b status

So a given test is searched from a root directory of the git repository rather than the autoload directory so fail.

Workaround

Use %:p instead

:Gina add %:p

@ujihisa
Copy link
Contributor

ujihisa commented Dec 26, 2018

thanks! @lambdalisue++

ujihisa added a commit to ujihisa/config that referenced this issue Dec 26, 2018
@lambdalisue lambdalisue pinned this issue Jan 30, 2019
@lambdalisue lambdalisue changed the title Gina add fails without any errors when the current directory is not the git root (Vim) Gina add % fails when pwd is not git root Jan 30, 2019
@doronbehar
Copy link
Contributor

Maybe the solution to this would consist of having a dedicated gina command handler for :Gina add in autoload/gina/command/add.vim?

@lambdalisue
Copy link
Owner Author

It's actually quite complicated. Assume gina.vim repository is in /Users/alisue/gina.vim and autoload/gina.vim is modified then

  1. Gina state shows M autoload/gina.vim when cwd is /Users/alisue/gina.vim/autoload/
  2. Gina state also shows M autoload/gina.vim when cwd is /Users/alisue/gina.vim/ rather than M . gina.vim when git -C is used
  3. << or >> in gina-status buffer internally use Gina add command

Thus I cannot simply use fnamemodify({path}, ':p') or whatever to make an absolute path or a relative path from the repository root.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants