Closed ffesseler closed 7 years ago
I'm always using HEAD of committia.vim but I've not seen this problem. Could you provide how to reproduce? And I need to know your environment (version of git
and Vim, OS)
I'm using git version 2.10.1 (Apple Git-78)
I'll try to find how to reproduce it. Right now, it happens on a private git repo.
git status
command looks failed.
diff --git a/autoload/committia/git.vim b/autoload/committia/git.vim
index 0f92c53..19dce13 100644
--- a/autoload/committia/git.vim
+++ b/autoload/committia/git.vim
@@ -62,7 +62,9 @@ function! s:search_git_dir_and_work_tree() abort
endfunction
function! s:execute_git(cmd, git_dir, work_tree) abort
- return s:system(printf('%s --git-dir="%s" --work-tree="%s" %s', g:committia#git#cmd, a:git_dir, a:work_tree, a:cmd))
+ let tmp = printf('%s --git-dir="%s" --work-tree="%s" %s', g:committia#git#cmd, a:git_dir, a:work_tree, a:cmd)
+ echom tmp
+ return s:system(tmp)
endfunction
function! s:ensure_index_file(git_dir) abort
With this diff, you can see actual command which was executed with :message
. Could you try this and try the same command in command line? Does it fail also?
EDIT: Sorry, diff was wrong (fixed).
If your repository is public, I think I can also try the situation.
ping @anekos: if you notice something, please help me to fix this.
Command executed :
git --git-dir="/Users/ffesseler/bla/.git" --work-tree="/Users/ffesseler/bla^@" diff -u --cached --no-color --no-ext-diff
It works fine when using it in the command line. Here is the output :
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
modified: server/client-html/src/main/resources/client-html-src/src/app/components/editors/noteEditor/noteEditor.js
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
@ noteEditor.js:1 @
//
import { NoteToolSet } from 'domain/model';
import { toHexa } from 'utils/color';
import { NotePaddings, NoteExtraTextPadding, NoteFont, TextCommonStyle } from 'domain/constants';
/Users/ffesseler/bla^@
Ah, it looks that NL remains in work tree directory path... I'll take a look.
Wait, this is the command that actually fails :
git --git-dir="/Users/ffesseler/bla/.git" --work-tree="/Users/ffesseler/bla^@" -c color.status=false status -b
fatal: This operation must be run in a work tree
Thanks.
I still can't understand what happens...
Could you try below diff? Is something output? If so, please let me see what was output.
diff --git a/autoload/committia/git.vim b/autoload/committia/git.vim
index 0f92c53..c482c57 100644
--- a/autoload/committia/git.vim
+++ b/autoload/committia/git.vim
@@ -43,6 +43,7 @@ function! s:search_git_dir_and_work_tree() abort
let work_tree = fnamemodify(readfile(git_dir . '/gitdir')[0], ':h')
else
let work_tree = s:extract_first_line(s:system(printf('%s --git-dir="%s" rev-parse --show-toplevel', g:committia#git#cmd, git_dir)))
+ echom work_tree
endif
return [git_dir, work_tree]
endif
Here is the output
/Users/ffesseler/bla^@
/Users/ffesseler/bla^@
The ^@
represents newline. So, actual command is:
git --git-dir="/Users/ffesseler/bla/.git" --work-tree="/Users/ffesseler/bla
" -c color.status=false status -b
I think it also fails in command line (if you try, please enter new line after ctrl+v in terminal)
@ffesseler Thank you. So I guess
s:extract_first_line(s:system(printf('%s --git-dir="%s" rev-parse --show-toplevel', g:committia#git#cmd, git_dir)))
returns the wrong work tree path.
Indeed:
git --git-dir="/Users/ffesseler/bla/.git" --work-tree="/Users/ffesseler/bla" -c color.status=false status -b
works in command line
git --git-dir="/Users/ffesseler/bla/.git" --work-tree="/Users/ffesseler/bla^@" -c color.status=false status -b
does not.
Could you tell me the output of
:echo &magic
set nomagic
may change how to interpret regex in match()
in s:extract_first_line()
.
@ffesseler Thank you for clarifying it. The newline ^@
looks root cause of this bug.
:echo &magic outputs 1
Thanks. So nomagic
is not related to this problem.
I submitted a commit 08b671a . Your system is macOS. So it may not be related to this problem, but could you try the latest?
And if you can, please tell me the output of below command:
If you don't use vimproc.vim:
:echom string(system("git --git-dir='/Users/ffesseler/bla/.git' rev-parse --show-toplevel"))
If you use vimproc.vim:
:echom string(vimproc#system("git --git-dir='/Users/ffesseler/bla/.git' rev-parse --show-toplevel"))
Same issue with the last version.
:echom string(system("git --git-dir='/Users/ffesseler/bla/.git' rev-parse --show-toplevel"))
outputs : '/Users/ffesseler/bla^@'
Thank you.
Hmm... so the problem is why s:extract_first_line
does not extract first line.
Does 3be483f fix this problem?
Yes ! Works fine now :)
I found that [^\n]\+
should have been ^[^\n]\+
, but 3be483f also works. Thank you for your cooperation. It was very helpful 👍
Thanks to you for fixing this very quickly and for providing me some tips to help debugging !
commitia worked fine until I updated the plugin yesterday. When I type "git commit", I get an error :
This seems related to the changes introduced with #31 .