Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work for vcsh or fake bare git technique #37

Open
DancingQuanta opened this issue Nov 23, 2017 · 10 comments · Fixed by #42
Open

Does not work for vcsh or fake bare git technique #37

DancingQuanta opened this issue Nov 23, 2017 · 10 comments · Fixed by #42

Comments

@DancingQuanta
Copy link

I am using vcsh which allows me to version control my dotfiles with git.
vcsh works by (taking a line from its manpage)

vcsh is using a technique called fake bare Git repositories, keeping $GIT_DIR in a different directory from $GIT_WORK_TREE which is pointed to $HOME.

So if I want to commit a change for a vcsh repo, I enter a vcsh environment then which have a different $GIT_DIR compared to $GIT_WORK_TREE for that repo.

committia chokes on this $GIT_DIR as shown in the following error upon committing.

Error detected while processing function committia#open[14]..<SNR>65_open_multicolumn[3]..<SNR>65_open_diff_window[1]..<SN
R>65_open_window[1]..committia#git#diff[1]..<SNR>66_search_git_dir_and_work_tree:
line   24:
E605: Exception not caught: committia: git: Failed to get git-dir from $GIT_DIR
Error detected while processing function committia#open:
line   14:
E171: Missing :endif
Error detected while processing function dein#autoload#_on_default_event[23]..<SNR>47_source_events:
line   12:
E171: Missing :endif

Can committia be adapted to support fake git repo technique please?

@rhysd
Copy link
Owner

rhysd commented Nov 30, 2017

Thank you for your report. Yeah, committia.vim does not surrpot bare repository for now. But I can investigate how to support and if it's reasonable, I'll add the support. Anyway, investigation is needed.

@DancingQuanta
Copy link
Author

Yes, this is more complex use of bare repos. Actually it is called fake bare repos and so I have no idea if a bare repo is actually involved. You may need to look at how vcsh works to understand the fake bare thing.
There are other tools that understand this for example liquidprompt for bash can sense it is in a git repo which I assume is due to executing a git command. I don't know if you wanted committia to launch calls to git to check whether it is in a git repo or not.

@rbialon
Copy link
Contributor

rbialon commented Jan 4, 2018

vcsh should set the GIT_DIR and GIT_WORK_TREE environment variables.
I use an alias for managing my home files, similar to vcsh but simpler:

alias homegit='GIT_DIR=$HOME/.dotfiles/ GIT_WORK_TREE=$HOME/ git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'

I was able to fix this issue by including

    if !empty($GIT_DIR) && !empty($GIT_WORK_TREE)
        return [$GIT_DIR, $GIT_WORK_TREE]
    endif

right after function! s:search_git_dir_and_work_tree() abort in autoload/committia/git.vim.

@DancingQuanta Can you check if this works with vcsh, too?

@DancingQuanta
Copy link
Author

DancingQuanta commented Jan 4, 2018

Oh it is embarrassing, vcsh does not set the GIT_WORK_TREE variable although it is normally VCSH_BASE=$HOME.
I will have to contact the vcsh's author about this.

EDIT

Actually when a VCSH repo is created, core.worktree is set in the repo's config. So the work tree is always set to this value when activating the VCSH repo (through exporting GIT_DIR pointing at repo's location).

@DancingQuanta
Copy link
Author

The description of #42 said that #42 does not fix #37 because vcsh did not touch GIT_WORK_TREE but it does set core.worktree attribute in the repo's config. I will do some investigating on solutions. A project, vim-fugitive/pull/575, have been working for vcsh.

@rbialon
Copy link
Contributor

rbialon commented Feb 24, 2018

Yes, that's right. If GIT_DIR is set correctly, the following will retrieve the workdir from the repo's config:

git config --local --get core.worktree

@rhysd rhysd reopened this Feb 26, 2018
@rhysd
Copy link
Owner

rhysd commented Feb 26, 2018

So, should we also check core.worktree config value here?

@rbialon
Copy link
Contributor

rbialon commented Feb 26, 2018

This depends on the type of repo:
In a bare repo,

  bare = true
  worktree = /path/to/worktree

results in fatal: core.bare and core.worktree do not make sense. (See git/git@fada767 )
So the value should only be honored if the repo isn't a bare repo.

@DancingQuanta
Copy link
Author

I asked vcsh's author about exporting GIT_WORK_TREE RichiH/vcsh#248. I like to wait for his answer.

@rhysd
Copy link
Owner

rhysd commented Feb 27, 2018

Sure. I'll wait for response.

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

Successfully merging a pull request may close this issue.

3 participants