cohama / agit.vim Goto Github PK
View Code? Open in Web Editor NEWA powerful Git log viewer
A powerful Git log viewer
let g:agit_enable_auto_refresh = 1
を設定しておいて、他のタブから移動してきた時、一度一番上の行のdiff/statが表示されているようです。
In some (presumably rare -- I found this while browsing a repository called MetroGit) cases where more than two branches are merged in a commit, -
and .
appear in the git graph. Currently they are not properly highlighted:
A script for reproduction (please execute in an empty directory if you do):
#!/bin/bash
# execute in an empty directory
git init
touch "i"
git add .
git commit -m "initial"
git checkout -b a
echo "a" > a
git add .
git commit -m "a"
git checkout master; git checkout -b b
echo "b" > b
git add .
git commit -m "b"
git checkout master; git checkout -b c
echo "c" > c
git add .
git commit -m "c"
git checkout master
git merge master a b c -m "merge"
Adding \-
and \.
to the syn match agitTree
seems to solve the problem, but not quite sure if this breaks anything.
To reproduce
OS X 10.9.5
vim 7.4.52
シンタックスagitDiffAdd/agitDiffRemoveは、agitDiffにcontainedされているため、diffが長いと適用されません。
確認方法
mkdir foobar
cd foobar/
git init
seq 10000 > README
git add README
vim
:Agit
:wincmd l
:wincmd j
G
※ diffが長いことはよくあることです
I know that the default mappings are defined locally, so how can I remap them?
Example, I want to use D
for <Plug>(agit-diff)
and nnoremap D <Plug>(agit-diff)
is of course not the way to do it.
I can use autocommands (FileType agit,agit_diff
.....), but is there not a better way?
e.g.
let g:agit_no_default_mappings = 1
augroup Agit
autocmd!
autocmd Filetype agit,agit_stat,agit_diff nmap <buffer> D <Plug>(agit-diff)
autocmd Filetype agit,agit_stat,agit_diff nmap <buffer> q <Plug>(agit-exit)
autocmd Filetype agit,agit_stat,agit_diff nmap <buffer> R <Plug>(agit-reload)
augroup END
Thanks in advance.
各バッファの生成時にnonumber, norelativenumber, nowrapなどが指定されていますが、catfileバッファについてはこの辺の設定は変更せず、.vimrcなどで指定したままになっていて欲しいです。
477d49a の変更にてvimproc#get_command_name
からcdを呼び出していますが、一部のLinuxディストリビューションでは $PATH/cd
が存在しない為、エラーが出ます。
[vimproc] vimproc#get_command_name: File "cd" is not found.
Error detected while processing function agit#launch[29]..agit#bufwin#agit_tabnew[6]..316[2]..318[1]..319[8]..304[10]..agit#aligner#align:
line 1:
E684: list index out of range: 0
E116: Invalid arguments for function len
E15: Invalid expression: len(a:table[0]) " sampling head's column number
確認したところMacOSやRHEL(確認したものはCent7, Fedora29)系には/usr/bin/cd
がありそうでしたが、Ubuntu18.04とArch Linuxには存在しませんでした(shellのビルトインコマンドを使っているようです)。
ワークアラウンドとして動くディストロと同様の下記のようなものを$PATH/cdとして保存しchmod +x
することで動きます。
#!/usr/bin/sh
builtin cd "$@"
windows環境での修正PR(#77)を適用してもこの問題は解決しません。
filetypeをセットするのは、マッピングを設定したあとにしなくてはいけません。なぜかというと、
autocmd FileType agit nunmap <buffer> <C-k>
のような設定をできるようにするべきだからです。
Hello!
When file paths in the stats buffer are more than around 70 characters long, they become abbreviated like this: .../subdirectory/file
Using :AgitDiff
on such a line causes the error File not tracked
.
One way to create a repository to test this:
mkdir longnames
cd longnames/
git init
mkdir -p 000000000/111111111/222222222/333333333/444444444/555555555/666666666/777777777
echo "test"> 000000000/111111111/222222222/333333333/444444444/555555555/666666666/777777777/file
echo "test"> 000000000/111111111/222222222/333333333/444444444/555555555/666666666/file
echo "test"> 000000000/111111111/222222222/333333333/444444444/555555555/file
echo "test"> 000000000/file
git add -A
git commit -m "xyz"
echo "test 2">> 000000000/111111111/222222222/333333333/444444444/555555555/666666666/777777777/file
echo "test 2">> 000000000/111111111/222222222/333333333/444444444/555555555/666666666/file
echo "test 2">> 000000000/111111111/222222222/333333333/444444444/555555555/file
echo "test 2">> 000000000/file
git add -A
git commit -m "zzz"
超レアケースなのはわかっているのですが、、、 AgitFile での diff 表示時に、内部で発行されているのは現状 cat-file かと思います。
が、cat-file だとutf8以外のファイルを扱う際、--textconv を扱えないので文字化けが発生します。(set encoding や LANG を変更すればもちろん解決する話ですが。。。)
そこで、 --textconv を処理できる show-file --textconv [rev]:file に変更できるようなオプションを追加 or catfile 実行する際のコマンドラインを設定できるようなオプションを追加頂きたいです。
git 2.11 から短縮ハッシュ長が可変になったため、ハッシュ長を7で決め打ちしている箇所が問題になります。
(https://github.com/cohama/agit.vim/blob/fdcd655/autoload/agit.vim#L222 など)
例えば vim 本体のリポジトリの場合、8.0.0123 の時点で git log --oneline
してみると短縮ハッシュ長は9文字でした。
そのため、:Agit
のログ表示でハッシュ部分が conceal されない上、j
でカーソルを下に動かすと一気に最下段まで移動してしまいます。
/autoload/agit/git.vim の s:git.log()
内で、以下のようなコードでHEADの行を取得しようとしていますが、まちがっているように見えます。(これだとhead_hash内のいずれかの文字がひとつでもあればmatchするのでほとんどの場合0が返る)
let head_hash = agit#git#exec('rev-parse --short HEAD', self.git_dir)
let head_index = s:find_index(aligned_log, 'match(v:val, "[' . head_hash . ']") >= 0')
意図した動作とするためには、head_hashにString.chompをかけた上で、[]をエスケープする必要があると思います。
ただ、個人的にはLocal Changesの行は常に一番上に表示されている方が使いやすい気がします。
(too many logs)にカーソルがあるとき、一番上のコミットのagit_diffが表示されているようです。一番下に表示されているコミットのdiffを表示するか、何も表示しないほうがいいと思います。
We cannot use agit.vim on Ubuntu because s:get_git_dir()
throws an error.
The command git --no-pager rev-parse --prefix / --git-dir
warns that:
fatal: bad flag '--git-dir' used after filename
--prefix
/
--git-dir
Agit uses b:git_dir
when available for fugitive compatibility, but it's not the only plugin that uses b:git_dir
. motemen/git-vim also uses (defines) b:git_dir
, and what's tragic, its implementation has apparently a bug.
This is more of a issue of git-vim than agit, but this kind of thing will prevent from non-fugitive-related b:git_dir
from affecting:
autoload/agit.vim
@@ -127,7 +127,7 @@ endfunction
function! s:get_git_dir()
" if fugitive exists
- if exists('b:git_dir')
+ if s:fugitive_enabled && exists('b:git_dir')
return b:git_dir
endif
let cdcmd = haslocaldir() ? 'lcd ' : 'cd '
(I'm not sure if there's any side effects in this.)
all of these does not work:
:Agit --dir=a b
:Agit --dir="a b"
:Agit --dir='a b'
:Agit --dir=a\ b
:Agit --dir=a\\ b
git clone時に--separate-git-dir=...オプションを使用して作業ツリーを分離したリポジトリをagit.vimで見た際、
未コミット差分が "fatal: This operation must be run in a work tree" とエラーになります。
agit.vimの他にvim-fugitiveが入っていると現象が発生し、
agit.vim単独では発生しません。
表題の件で、
:help agit
には
:AgitDiff [{revisions}]
<snip>
When launched from |agit-stat| buffer, AgitDiff trys to pick target file
from cursor position. (see ##|<cfile>|)
とありますが、agit-stat でどこにカーソルが有っても、:Agit 呼び出し元のファイルとの差分になります
ステータス・ラインやタブ・バーの表示は、カーソル位置のファイル名になっているのですが???
私は何か勘違いしているでしょうか?
#998 の状況なので、vim-fugitive は未インストールです
$ vim --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Nov 24 2016 22:32:42)
適用済パッチ: 1-1829
追加拡張パッチ: 8.0.0056
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.10
Release: 16.10
Codename: yakkety
agit.vim
タイトル通りです。
:Agit
などを実行した際に、カレントディレクトリのパスにスペースが含まれている場合、
git: '(スペースの後のパスの文字列)' is not a git command. See 'git --help'.
と表示され、正常に開始されません。
パスにスペースが含まれていない場合は正常に動作しました。
OS: Win8.1 x64
What I'm trying to achieve is, having two separate git histories for the same work tree, one with properly named commits and another for auto-committing work-in-progress every now and then. I achieved this behavior with --git-dir, but now I want to be able to run :Agit for each of the trees.
This is what I do (this should only work when fugitive is on):
nnoremap <F11> :let b:git_dir = substitute(b:git_dir, ".git$", ".wip", "")<CR>:Agit<CR>
The git.git_dir property does get initialized properly, but all three default views have the message
fatal: The empty string is not a valid path
which probably means some calls to git don't respect the git_dir parameter. There are such calls in the code but I couldn't find the relevant ones. I'll be working on understanding the codebase, just reporting here to ask for help. This issue might be related to #48 or #19
%h means abbreviated commit hash and not displayed in left window.
source file agit.vim/autoload/agit/git.vim
let gitlog = agit#git#exec('log --all --graph --decorate=full --no-color --date=relative --format=format:"%d %s' . s:sep . '|>%ad<|' . s:sep . '{>%an<}' . s:sep . '[%h]"', self.git_dir)
I wish that commit hash could be displayed.
AgitFileで次のエラーが出ます。 ( agit#launch
のtry catchをコメントアウトしています )
Error detected while processing function agit#launch..agit#bufwin#agit_tabnew..132..141..127..agit#aligner#align:
line 1:
E684: list index out of range: 0
E116: Invalid arguments for function len(a:table[0]) " sampling head's column number
E15: Invalid expression: len(a:table[0]) " sampling head's column number
line 4:
E121: Undefined variable: column_number
E116: Invalid arguments for function range(column_number)
E15: Invalid expression: range(column_number)
line 14:
E684: list index out of range: 0
E15: Invalid expression: s:sum(maxs) - maxs[0]
line 16:
E121: Undefined variable: width_without_commit_msg
E15: Invalid expression: a:max_col == 0 ? maxs[0] : a:max_col - width_without_commit_msg - seps_width
再現方法
思わずvimfilerの画面でAgitFileしてしまって見つけました。
gitで管理されていないファイルなのですぐに落とすのがいいのか、それともフォールバックで普通にAgitを開くかですかね。
@cohama in this issue
~/SpaceVim/SpaceVim
, and this is a root of a git repotabnew ~/.SpaceVim.d/init
to open the custom file this is a link to ~/Dotfiles/SpaceVim.d/init.vim
. and ~/Dotfiles
also is a root of git repo.maybe This plugin should handle the local path instead.
To produce:
git clone https://github.com/cohama/agit.vim
cd ./agit.vim/plugin
vim
:Agit
Error
= Local uncommitted changes, not checked in to index
+ Local changes checked in to index but not committed
fatal: Not a git repository: '/Users/itchyny/agit.vim//Users/itchyny/agit.vim/.git'
We expect the agit tab will be closed with the q
key.
However, when we focus on the agit_stat/agit_diff buffers, pressing the q
key does not close the agit tab.
Problem: When the Agit is the only tab, I cannot exit Agit.
It's preferable to open a new tab and delete the Agit tab.
I use agit.vim in Windows.
And it sometimes says "Not a git repository" unexpectedly.
In get_git_dir()
, agit calls git by vimproc#system()
instead of system()
if vimproc is available, and refers v:shell_error
to get result.
But vimproc#system()
does not set v:shell_error
.
I guess it should be vimproc#get_last_status()
when vimproc is available.
今の実装では、リポジトリの場所はバッファに開かれているファイルのパスから検索されますが、
AgitFileで明示的にファイルを指定して起動した場合はそのパスから検索する必要があるのではないでしょうか。
gitに渡すオプションとして、--git-dirと--work-treeの代わりに-Cを代わりに使った方がいいのではないかと思うのですが、いかがでしょうか?
例えば、作業ツリーのパスが$ROOTだとして、agitのリポジトリで autoload/agit.vim の履歴を表示しようとした場合、git 1.9.4 では以下のような動作になるようです
# カレントディレクトリがリポジトリルートなら何の問題もない
cd $ROOT
git --git-dir=$ROOT/.git --work-tree=$ROOT log -- autoload/agit.vim # OK
# カレントディレクトリがサブディレクトリの場合、相対パスでファイルを
# 指定する必要がある
cd $ROOT/autoload
git --git-dir=$ROOT/.git --work-tree=$ROOT log -- autoload/agit.vim # NG
git --git-dir=$ROOT/.git --work-tree=$ROOT log -- agit.vim # OK
# カレントディレクトリがリポジトリ外の場合、相対パスではダメで、
# リポジトリルートからのパスを指定する必要がある
cd $ROOT/..
git --git-dir=$ROOT/.git --work-tree=$ROOT log -- agit.vim/autoload/agit.vim # NG
git --git-dir=$ROOT/.git --work-tree=$ROOT log -- autoload/agit.vim # OK
そのため、カレントディレクトリの場所によって渡すパスを変えるか、常に絶対パスで指定する必要が(多分)あります。
これに対して、-Cでの指定であれば、カレントディレクトリの位置にかかわらず同じパスで処理できます。
cd $ROOT
git -C $ROOT log -- autoload/agit.vim # OK
cd $ROOT/autoload
git -C $ROOT log -- autoload/agit.vim # OK
cd $ROOT/..
git -C $ROOT log -- autoload/agit.vim # OK
1056d84の変更によって、staged/unstagedに対するAgitDiffが動かなくなりました。
fugitiveが入っていると、index上のファイルを表示するのにfugitiveを使いますが、
fugitive://リポジトリのフルパス///0/リポジトリ内でのファイルの相対パス
となるはずのパスが
fugitive://リポジトリのフルパス///0/ファイルのフルパス
となっています。
もしかするとWindows特有の問題かもしれません。
I want agit to use current git directory is getcwd()
not a current file's directory.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.