tpope / vim-fugitive

fugitive.vim: A Git wrapper so awesome, it should be illegal
https://www.vim.org/scripts/script.php?script_id=2975
20.03k stars 1.01k forks source link

git bad signature index file corrupt #648

Closed giuse88 closed 7 years ago

giuse88 commented 9 years ago

Hi,

Often vim-fugitive corrupts my git index. This happens when I call Gstatus and then I add the same file more the one with -. Any one else has this problem?

tpope commented 9 years ago

Next time it happens take a look inside the index file and see if the contents of the :Gstatus window have overwritten it.

cj commented 9 years ago

@giuse88 @tpope not sure if this is related, but on the latest version of vim-fugative after I wq to save a commit I get this error: and then this shows up .

If I use vim to check .git/index I see: using nano I see:

tpope commented 9 years ago

Sounds like an issue with whatever this "BufSurf" plugin is.

On Thu, Jun 25, 2015 at 10:54 AM cj notifications@github.com wrote:

@giuse88 https://github.com/giuse88 @tpope https://github.com/tpope not sure if this is related, but on the latest version of vim-fugative after I wq to save a commit I get this error: https://camo.githubusercontent.com/8314ce770849b763eb943eef11b4341865c21b24/687474703a2f2f692e696d6775722e636f6d2f4f714f395078302e706e67 and then this shows up https://camo.githubusercontent.com/53b2dd07ce39147f81b780841dc0cbc2f463d527/687474703a2f2f692e696d6775722e636f6d2f6b52737a3178332e706e67 .

If I use vim to check .git/index I see: https://camo.githubusercontent.com/ecb09761265ee8b80d1803e7fc05a229660fc0fb/687474703a2f2f692e696d6775722e636f6d2f4b5254344f47742e706e67 using nano I see: https://camo.githubusercontent.com/57dabe15fb133f5fc913fb427115dcf4b3386f43/687474703a2f2f692e696d6775722e636f6d2f6d4d6d62714f692e706e67

— Reply to this email directly or view it on GitHub https://github.com/tpope/vim-fugitive/issues/648#issuecomment-115283658.

cj commented 9 years ago

this is the plugin https://github.com/ton/vim-bufsurf. It only just started happening after I updated fugitive. I guess something changed that bufsurf doesn't like.

tpope commented 9 years ago

If you can figure out the exact commit that triggered it I can further advise.

mataps commented 9 years ago

i'm having the same issue when doing Gcommit then I added a file to stage. After that, I did another Gcommit, this time with a the message and I got this error.

cj commented 8 years ago

@tpope so I'm still having this issue. I no longer have that plugin, but after I commit I'm still getting this:

tpope commented 8 years ago

Please elaborate.

cj commented 8 years ago

After I do a :Gwrite then :Gcommit type in my message and then :wq this buffer just pops up.

tpope commented 8 years ago

So the commit message buffer closes and then this opens in a split? That's odd. It looks like a failed attempt to open :Gstatus, which is what happens when you call :Gcommit with no changes.

Can you check the value of :echo b:fugitive_commit_arguments before you :wq?

cj commented 8 years ago

Yes. Strange, there definitely was a commit with changes before I did :wq'd.

here's the value: --cleanup=strip -F /home/cj/apps/acd/autolink/.git/COMMIT_EDITMSG --no-edit --no-interactive --no-signoff

tpope commented 8 years ago

While the commit message is still open, try running the following in another window:

 GIT_EDITOR=false git commit --cleanup=strip -F /home/cj/apps/acd/autolink/.git/COMMIT_EDITMSG --no-edit --no-interactive --no-signoff

Check for errors, and the exit status (echo $?).

cj commented 8 years ago

fourjay commented 8 years ago

I've run into this (pretty consistently). I've tried the troubleshooting steps without seeing much different than reported above. That said I think I might have found a workaround (and thus a pointer) My (less then full perusal) of the code shows that the commit window is normally set with bufhidden=bdelete but on commit it's set to bwipeout. It looks like some path allows that to get skipped. After a commit I can still see the hidden .git/index file with ls! If I switch to the file at that point (either directly or by invoking Gstatus) I see the garbled binary index.

To clarify a bit:

1) I use Gtatus. Everything is good 2) I commit a change with Gcommit 3) At that point I can still see the .git/index file with ls! 4) If switch to the window, it's garbled 5) If I close that window and re-invoke Gstatus, it's back to expected.

If I bwipeout the buffer directly ( :[BNUMBER]bwipeout ) then Gstatus and cousins work fine.

The workaround (and possible clue) is that I typically use ZZ as a wq shortcut. In after/gitcommit.vim I've now set a function + mapping that calls bwipeout and the problem goes away (aka I remap ZZ)

Hoping this is useful :-)

yevhen-m commented 8 years ago

@cj I have the same issue with garbled text after GCommit command. Have you managed to fix it somehow?

unChartedZone commented 7 years ago

Is anyone here who is having this issue, using vim-airline by any chance?

yevhen-m commented 7 years ago

@unChartedZone I use vim-airline.

unChartedZone commented 7 years ago

@yevhen-m I noticed that the issue with fugitive goes away when I uninstall vim-airline, so perhaps that plugin could be the cause of the issue but I'm not entirely sure.

pedrofranceschi commented 7 years ago

I'm having the same issue… Any fix available?

ben-ballot commented 7 years ago

Hello, I can confirm that this is related to airline. I hit this after switching to Xenial (the exact same setup was working fine on 15.10).

Here is my .vimrc file

set nocompatible              " required
filetype off                  " required
syntax on

" Change leader
let mapleader="\<Space>"

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')

" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'

" Add all your plugins here (note older versions of Vundle used Bundle instead
" of Plugin)*

" Auto-Complete
Bundle 'Valloric/YouCompleteMe'

" Folding
Plugin 'tmhedberg/SimpylFold' "Folding

" Python autodindent
Plugin 'vim-scripts/indentpython.vim' " Indent python

" Syntax
Plugin 'scrooloose/syntastic' "Syntax checker

"
Plugin 'nvie/vim-flake8' " PEP8

" Colors
Plugin 'jnurmine/Zenburn' " Zenburn theme (console)
Plugin 'altercation/vim-colors-solarized' "Solarized theme (GUI)

Plugin 'scrooloose/nerdtree' "Hierarchy tree

Plugin 'kien/ctrlp.vim' " Search files

Plugin 'vim-airline/vim-airline' "Status bar
Plugin 'vim-airline/vim-airline-themes'

Plugin 'tpope/vim-fugitive' " Show git branch in status bar

Plugin 'xolox/vim-misc' " Needed by vim-session
Plugin 'xolox/vim-session' " Make use of mksession easier

Plugin 'saltstack/salt-vim' " For saltstack files

Plugin 'fatih/vim-go' " Go Plugin

Plugin 'pearofducks/ansible-vim' " Ansible plugin

Bundle 'Rykka/riv.vim'

" All of your Plugins must be added before the following line
call vundle#end()            " required
filetype plugin indent on    " required
set encoding=utf-8

" Set filetype based on name
autocmd BufRead,BufNewFile *Dockerfile* setlocal filetype=dockerfile
autocmd BufRead,BufNewFile *dockerfile* setlocal filetype=dockerfile
autocmd BufRead,BufNewFile *.spec.in setlocal filetype=spec
autocmd BufRead,BufNewFile *.functions setlocal filetype=sh
autocmd BufRead,BufNewFile *.sls setlocal filetype=sls
autocmd BufRead,BufNewFile *.jinja setlocal filetype=jinja

"" General section
set nowrap        " don't wrap lines
set tabstop=4     " a tab is four spaces
set backspace=indent,eol,start
                    " allow backspacing over everything in insert mode
set autoindent    " always set autoindenting on
set copyindent    " copy the previous indentation on autoindenting
set shiftwidth=4  " number of spaces to use for autoindenting
set shiftround    " use multiple of shiftwidth when indenting with '<' and '>'
set showmatch     " set show matching parenthesis
set ignorecase    " ignore case when searching
set smartcase     " ignore case if search pattern is all lowercase,
                    "    case-sensitive otherwise
set smarttab      " insert tabs on the start of a line according to
                    "    shiftwidth, not tabstop
set hlsearch      " highlight search terms
set incsearch     " show search matches as you type

set history=1000         " remember more commands and search history
set undolevels=1000      " use many muchos levels of undo
set wildignore=*.swp,*.bak,*.pyc,*.class
set visualbell           " don't beep
set noerrorbells         " don't beep

" FX button mapping
set pastetoggle=<F2> " Toggle PASTE mode

" Remove trailing whitespaces
:nnoremap <silent> <F5> :let _s=@/ <Bar> :%s/\s\+$//e <Bar> :let @/=_s <Bar> :nohl <Bar> :unlet _s <CR>

set hidden " Allow leaving a buffer with unsaved changes

set mouse=a " Use mouse in all mode

set guioptions-=T  "remove toolbar

" Completion in menu bar
set wildmode=longest,list,full
set wildmenu

"" Remap
" <leader>sv sources .vimrc
nnoremap <leader>sv :source $MYVIMRC<CR>:runtime! plugin/settings/*<CR>:redraw<CR>:echo $MYVIMRC 'reloaded'<CR>

" Buffer navigation
nnoremap <silent> <leader><Left> <esc>:bp<CR>
nnoremap <silent> <leader><Right> <esc>:bn<CR>

" Split navigations
nnoremap <silent> <C-Right> <c-w>l
nnoremap <silent> <C-Left> <c-w>h
nnoremap <silent> <C-Up> <c-w>k
nnoremap <silent> <C-Down> <c-w>j

" Copy to system clipboard Visual selection
" vnoremap <silent> <C-c> y/<C-R>"*<CR><esc>

"" Folding
" Enable folding
set foldmethod=indent
set foldlevel=99

" See the docstring when folding
let g:SimpylFold_docstring_preview=1

" Autocompletion stuff
let g:ycm_autoclose_preview_window_after_completion=1
map <leader>g  :YcmCompleter GoToDefinitionElseDeclaration<CR>

" Colors set
if has('gui_running')
  set background=dark
  colorscheme solarized
  set guifont=DejaVu\ Sans\ Mono\ for\ Powerline\ 9
else
  "colors theme configuration (console)
  if &term == "linux" || &term == "screen.linux"
    set t_Co=8
    colorscheme zenburn
  else
    set t_Co=256
    colorscheme zenburn
  endif
endif

"" NerdTree
let NERDTreeIgnore=['\.pyc$', '\~$'] "ignore files in NERDTree
map <C-n> :NERDTreeToggle<CR>
" Close vim if only NerdTree is open
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif

" Always enable status bar
set laststatus=2

" Use powerline font symbols
let g:airline_powerline_fonts = 1
if !exists('g:airline_symbols')
  let g:airline_symbols = {}
endif
let g:airline_symbols.space = "\ua0"

" Enable the list of buffers
let g:airline#extensions#tabline#enabled = 1

" Session
let g:session_autosave = "prompt"
let g:session_autosaveperiodic = 60
let g:session_persist_colors = 0
let g:session_persist_font = 0

As long as I keep the vim-airline plugin, if I edit a file, :Gwrite, :Gcommit, I end up with a window with the .git/index content like this DIRC������CX/— yada yada

The title of the window being "/.git/index" [Preview] I can just close it but it's rather annoying

As long as I remove vim-airline plugin, this does not happen anymore

Using previous version of vim-airline has lead nowhere so far, but still checking

ben-ballot commented 7 years ago

Found it. This regression was introduced by https://github.com/vim-airline/vim-airline/commit/3899f848a751b2f8e6d45fa1fe3f723491999f6f If you put your vim-airline to 02ecb8631d4c4252e11fff2ed9fc8d48d91577a1, it works fine I'll put that to vim-airline repository also

zoni commented 7 years ago

According to vim-airline maintainers, this is an issue in fugitive rather than vim-airline. https://github.com/vim-airline/vim-airline/issues/1332#issuecomment-263123809 has a detailed explanation of what is happening here.

tpope commented 7 years ago

If I understand correctly, that ought to do it.

zoni commented 7 years ago

Looks like we're not quite there yet. Running with https://github.com/tpope/vim-fugitive/commit/c5c1bd66d897501848312a97b408ca5255251a9a, issuing :Gcommit now errors with:

Error detected while processing function <SNR>45_Commit:
line   25:
E46: Cannot change read-only variable "shell_error"
Press ENTER or type command to continue
tpope commented 7 years ago

Crap, try now.

On Sat, Feb 25, 2017 at 4:50 PM Nick Groenen notifications@github.com wrote:

Looks like we're not quite there yet. Running with c5c1bd6 https://github.com/tpope/vim-fugitive/commit/c5c1bd66d897501848312a97b408ca5255251a9a, issuing :Gcommit now errors with:

Error detected while processing function 45_Commit: line 25: E46: Cannot change read-only variable "shell_error" Press ENTER or type command to continue

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/tpope/vim-fugitive/issues/648#issuecomment-282515016, or mute the thread https://github.com/notifications/unsubscribe-auth/AAABeha0yjV3rqs_10otcqyvwZmBRAceks5rgKIWgaJpZM4EpCvQ .

zoni commented 7 years ago

Success! :smile: I can confirm that fixed it (that is both the regression from c5c1bd66d897501848312a97b408ca5255251a9a as well as the original issue itself).

Thanks!