mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-09 12:03:47 -05:00
Compare commits
188 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2564c37d0a | ||
|
|
c316b924e8 | ||
|
|
7a190ead85 | ||
|
|
e48cf2dadd | ||
|
|
6d497b0e63 | ||
|
|
dcf32d2b3d | ||
|
|
0fd64f8fbf | ||
|
|
2845e6dc4f | ||
|
|
7fae98f263 | ||
|
|
a9100fafb8 | ||
|
|
9fec8aadc5 | ||
|
|
66697b99d6 | ||
|
|
fb55319973 | ||
|
|
02fe20ece4 | ||
|
|
6cd8ff77f0 | ||
|
|
af76267c6a | ||
|
|
144b73946e | ||
|
|
d4fb2a2f5c | ||
|
|
4bf30ce907 | ||
|
|
0fe0964385 | ||
|
|
8b4a1017b6 | ||
|
|
66e0fe5d3e | ||
|
|
61b09ca6b7 | ||
|
|
b3651aa744 | ||
|
|
fd83fcaf90 | ||
|
|
1e3786734b | ||
|
|
4d3835f637 | ||
|
|
44e5df8433 | ||
|
|
a202238b5d | ||
|
|
bb2797d313 | ||
|
|
67e9756c35 | ||
|
|
ae2005adbb | ||
|
|
ed36717a68 | ||
|
|
b1ab990314 | ||
|
|
2b5effe2f1 | ||
|
|
662b501eee | ||
|
|
7bdf33d375 | ||
|
|
e9dc363745 | ||
|
|
9979b2ab7c | ||
|
|
8589246545 | ||
|
|
7b0aa58090 | ||
|
|
45c21fc384 | ||
|
|
8dc13a6a72 | ||
|
|
0614acc770 | ||
|
|
1a7b07cf22 | ||
|
|
4a3c6b4a56 | ||
|
|
e3c9588e07 | ||
|
|
40facfde5e | ||
|
|
236bd21b45 | ||
|
|
e9ce313912 | ||
|
|
74b10425eb | ||
|
|
1a041936da | ||
|
|
a358191cfb | ||
|
|
597289e64d | ||
|
|
7ea21ca9ac | ||
|
|
2ca0765dc4 | ||
|
|
347d309efb | ||
|
|
6138aebbbb | ||
|
|
dd262b7e21 | ||
|
|
f91c34069e | ||
|
|
40e2dcba05 | ||
|
|
a3e9518186 | ||
|
|
8c63314381 | ||
|
|
12e0151750 | ||
|
|
887d86e920 | ||
|
|
73ed8e8a71 | ||
|
|
4bf7f2fd69 | ||
|
|
08d471056e | ||
|
|
969a3d857f | ||
|
|
06b3da7204 | ||
|
|
db3b837e6e | ||
|
|
b780bce39b | ||
|
|
a615172b14 | ||
|
|
caee67c748 | ||
|
|
1fea1e5821 | ||
|
|
80e410c81a | ||
|
|
84fcfae7f0 | ||
|
|
4d684256ba | ||
|
|
0e948d514c | ||
|
|
4eee908ad5 | ||
|
|
c1d2fc1a19 | ||
|
|
c85980cd93 | ||
|
|
81deb6333a | ||
|
|
85f340590d | ||
|
|
fc8f9eda9d | ||
|
|
c82abd0558 | ||
|
|
d859e05f00 | ||
|
|
3feda7f440 | ||
|
|
c9c406a118 | ||
|
|
a877908acd | ||
|
|
6c89a3675b | ||
|
|
bf796562b6 | ||
|
|
023ab8e4a6 | ||
|
|
da95d96ece | ||
|
|
8a0a448f56 | ||
|
|
004da420e5 | ||
|
|
8b4194047c | ||
|
|
716edd4bc0 | ||
|
|
70c0f132f5 | ||
|
|
a8392e0ebb | ||
|
|
64fbfc7a8d | ||
|
|
f232e4c6a3 | ||
|
|
db7fd110a8 | ||
|
|
248764f2c3 | ||
|
|
f8fb5eafab | ||
|
|
4f82d241cc | ||
|
|
f761ea700c | ||
|
|
035cdf44e8 | ||
|
|
deaf4aa139 | ||
|
|
da066426fd | ||
|
|
4643363b08 | ||
|
|
c5d4ce7479 | ||
|
|
6eadff1107 | ||
|
|
c68fb3c83a | ||
|
|
6c09ce3ab4 | ||
|
|
cec05fac01 | ||
|
|
4b0475f9d8 | ||
|
|
8edc9cd006 | ||
|
|
382c0a5405 | ||
|
|
c472b8f2c1 | ||
|
|
30c2490b6e | ||
|
|
5a9b7a593b | ||
|
|
4ce8646410 | ||
|
|
321f63ff19 | ||
|
|
7f299fbbe3 | ||
|
|
6d0df81732 | ||
|
|
5cea916e9c | ||
|
|
c3c39d904b | ||
|
|
6bab1a0c39 | ||
|
|
49c2a4acb5 | ||
|
|
73c39195ae | ||
|
|
f818a947ae | ||
|
|
fbaa831e57 | ||
|
|
07d30de8be | ||
|
|
c693da9cb0 | ||
|
|
1e7e707696 | ||
|
|
d818ac93af | ||
|
|
2fcf95467f | ||
|
|
286476d58f | ||
|
|
b78a8ab860 | ||
|
|
e6e3f3f225 | ||
|
|
240127f5a5 | ||
|
|
bfc1745f3b | ||
|
|
93f29cf831 | ||
|
|
5879304769 | ||
|
|
196e448375 | ||
|
|
e0b770a9bd | ||
|
|
c938737960 | ||
|
|
978ca4a5ce | ||
|
|
a8626a4ca4 | ||
|
|
4a5781bc1b | ||
|
|
71acb7da35 | ||
|
|
1e41a88ec9 | ||
|
|
9e7b67e9b0 | ||
|
|
445a8160d2 | ||
|
|
cb49f8b4be | ||
|
|
6aa3f09eb7 | ||
|
|
197ca58a95 | ||
|
|
7165817b69 | ||
|
|
be68a8ec8a | ||
|
|
b8046d1c5e | ||
|
|
b7e57637ba | ||
|
|
35f94eef48 | ||
|
|
c118dabb89 | ||
|
|
8c076e3f68 | ||
|
|
0aa3389f5c | ||
|
|
fb2289982b | ||
|
|
56e4947843 | ||
|
|
99f0431135 | ||
|
|
29411e2801 | ||
|
|
c0b6faeae7 | ||
|
|
792154e45d | ||
|
|
0717396aa2 | ||
|
|
9b9a81b170 | ||
|
|
598ad040b3 | ||
|
|
805c0bbdd9 | ||
|
|
1971f8fd62 | ||
|
|
5ba918ea7b | ||
|
|
27475a5d08 | ||
|
|
e3b1af604c | ||
|
|
c9d6c83470 | ||
|
|
8df073165a | ||
|
|
9bc425e943 | ||
|
|
65346f0926 | ||
|
|
5a7469d899 | ||
|
|
6f07b18012 | ||
|
|
302f30c924 | ||
|
|
7316baffdd |
@@ -11,8 +11,9 @@ Vim's diff handling capabilities to stage a subset of the file's
|
|||||||
changes.
|
changes.
|
||||||
|
|
||||||
Bring up the output of `git status` with `:Gstatus`. Press `-` to
|
Bring up the output of `git status` with `:Gstatus`. Press `-` to
|
||||||
`add`/`reset` a file's changes, or `p` to `add`/`reset` `--patch`. And guess
|
`add`/`reset` a file's changes, or `p` to `add`/`reset` `--patch`. Use
|
||||||
what `:Gcommit` does!
|
`:Gcommit %` to commit the current file, editing the commit message inside
|
||||||
|
the currently running Vim.
|
||||||
|
|
||||||
`:Gblame` brings up an interactive vertical split with `git blame`
|
`:Gblame` brings up an interactive vertical split with `git blame`
|
||||||
output. Press enter on a line to edit the commit where the line
|
output. Press enter on a line to edit the commit where the line
|
||||||
@@ -36,10 +37,9 @@ making it like `git add` when called from a work tree file and like
|
|||||||
`git checkout` when called from the index or a blob in history.
|
`git checkout` when called from the index or a blob in history.
|
||||||
|
|
||||||
Use `:Gbrowse` to open the current file on the web front-end of your favorite
|
Use `:Gbrowse` to open the current file on the web front-end of your favorite
|
||||||
hosting provider, with optional line range (try it in visual mode!). Built-in
|
hosting provider, with optional line range (try it in visual mode!). Plugins
|
||||||
support is provided for `git instaweb`, and plugins are available for popular
|
are available for popular providers such as [GitHub][rhubarb.vim],
|
||||||
providers such as [GitHub][rhubarb.vim], [GitLab][fugitive-gitlab.vim], and
|
[GitLab][fugitive-gitlab.vim], and [Bitbucket][fubitive.vim].
|
||||||
[Bitbucket][fubitive.vim].
|
|
||||||
|
|
||||||
[rhubarb.vim]: https://github.com/tpope/vim-rhubarb
|
[rhubarb.vim]: https://github.com/tpope/vim-rhubarb
|
||||||
[fugitive-gitlab.vim]: https://github.com/shumphrey/fugitive-gitlab.vim
|
[fugitive-gitlab.vim]: https://github.com/shumphrey/fugitive-gitlab.vim
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
134
doc/fugitive.txt
134
doc/fugitive.txt
@@ -63,6 +63,7 @@ that are part of Git repositories).
|
|||||||
U |:Git| checkout HEAD (staged files)
|
U |:Git| checkout HEAD (staged files)
|
||||||
U |:Git| clean (untracked files)
|
U |:Git| clean (untracked files)
|
||||||
U |:Git| rm (unmerged files)
|
U |:Git| rm (unmerged files)
|
||||||
|
. enter |:| command line with file prepopulated
|
||||||
|
|
||||||
*fugitive-:Gcommit*
|
*fugitive-:Gcommit*
|
||||||
:Gcommit [args] A wrapper around git-commit. If there is nothing
|
:Gcommit [args] A wrapper around git-commit. If there is nothing
|
||||||
@@ -89,7 +90,7 @@ that are part of Git repositories).
|
|||||||
|
|
||||||
*fugitive-:Grebase*
|
*fugitive-:Grebase*
|
||||||
:Grebase [args] Like |:Gmerge|, but for git-rebase. Interactive
|
:Grebase [args] Like |:Gmerge|, but for git-rebase. Interactive
|
||||||
rebase not suppported.
|
rebase not supported.
|
||||||
|
|
||||||
*fugitive-:Gpush*
|
*fugitive-:Gpush*
|
||||||
:Gpush [args] Invoke git-push, load the results into the |quickfix|
|
:Gpush [args] Invoke git-push, load the results into the |quickfix|
|
||||||
@@ -124,19 +125,19 @@ that are part of Git repositories).
|
|||||||
|quickfix| list.
|
|quickfix| list.
|
||||||
|
|
||||||
*fugitive-:Gedit* *fugitive-:Ge*
|
*fugitive-:Gedit* *fugitive-:Ge*
|
||||||
:Gedit [revision] |:edit| a |fugitive-revision|.
|
:Gedit [object] |:edit| a |fugitive-object|.
|
||||||
|
|
||||||
*fugitive-:Gsplit*
|
*fugitive-:Gsplit*
|
||||||
:Gsplit [revision] |:split| a |fugitive-revision|.
|
:Gsplit [object] |:split| a |fugitive-object|.
|
||||||
|
|
||||||
*fugitive-:Gvsplit*
|
*fugitive-:Gvsplit*
|
||||||
:Gvsplit [revision] |:vsplit| a |fugitive-revision|.
|
:Gvsplit [object] |:vsplit| a |fugitive-object|.
|
||||||
|
|
||||||
*fugitive-:Gtabedit*
|
*fugitive-:Gtabedit*
|
||||||
:Gtabedit [revision] |:tabedit| a |fugitive-revision|.
|
:Gtabedit [object] |:tabedit| a |fugitive-object|.
|
||||||
|
|
||||||
*fugitive-:Gpedit*
|
*fugitive-:Gpedit*
|
||||||
:Gpedit [revision] |:pedit| a |fugitive-revision|.
|
:Gpedit [object] |:pedit| a |fugitive-object|.
|
||||||
|
|
||||||
:Gsplit! [args] *fugitive-:Gsplit!* *fugitive-:Gvsplit!*
|
:Gsplit! [args] *fugitive-:Gsplit!* *fugitive-:Gvsplit!*
|
||||||
:Gvsplit! [args] *fugitive-:Gtabedit!* *fugitive-:Gpedit!*
|
:Gvsplit! [args] *fugitive-:Gtabedit!* *fugitive-:Gpedit!*
|
||||||
@@ -144,13 +145,12 @@ that are part of Git repositories).
|
|||||||
:Gpedit! [args] split, tab, or preview window.
|
:Gpedit! [args] split, tab, or preview window.
|
||||||
|
|
||||||
*fugitive-:Gread*
|
*fugitive-:Gread*
|
||||||
:Gread [revision] Empty the buffer and |:read| a |fugitive-revision|.
|
:Gread [object] Empty the buffer and |:read| a |fugitive-object|.
|
||||||
When the argument is omitted, this is similar to
|
When the argument is omitted, this is similar to
|
||||||
git-checkout on a work tree file or git-add on a stage
|
git-checkout on a work tree file or git-add on a stage
|
||||||
file, but without writing anything to disk.
|
file, but without writing anything to disk.
|
||||||
|
|
||||||
:{range}Gread [revision]
|
:{range}Gread [object] |:read| in a |fugitive-object| after {range}.
|
||||||
|:read| in a |fugitive-revision| after {range}.
|
|
||||||
|
|
||||||
*fugitive-:Gread!*
|
*fugitive-:Gread!*
|
||||||
:Gread! [args] Empty the buffer and |:read| the output of a Git
|
:Gread! [args] Empty the buffer and |:read| the output of a Git
|
||||||
@@ -179,31 +179,28 @@ that are part of Git repositories).
|
|||||||
succeeded.
|
succeeded.
|
||||||
|
|
||||||
*fugitive-:Gdiff*
|
*fugitive-:Gdiff*
|
||||||
:Gdiff [revision] Perform a |vimdiff| against the current file in the
|
:Gdiff [object] Perform a |vimdiff| against the given file, or if a
|
||||||
given revision. With no argument, the version in the
|
commit is given, the current file in that commit.
|
||||||
index is used (which means a three-way diff during a
|
With no argument, the version in the index is used
|
||||||
merge conflict, making it a git-mergetool
|
(which means a three-way diff during a merge conflict,
|
||||||
alternative). The newer of the two files is placed
|
making it a git-mergetool alternative). The newer of
|
||||||
to the right or bottom, depending on 'diffopt' and
|
the two files is placed to the right or bottom,
|
||||||
the width of the window relative to 'textwidth'. Use
|
depending on 'diffopt', and the width of the window
|
||||||
|do| and |dp| and write to the index file to simulate
|
relative to 'textwidth'. Use |do| and |dp| and write
|
||||||
"git add --patch". For the three-way diff, there is
|
to the index file to simulate "git add --patch". For
|
||||||
also d2o and d3o pulling the hunk to the middle from
|
the three-way diff, there is also d2o and d3o pulling
|
||||||
the left or the right window, respectively.
|
the hunk to the middle from the left or the right
|
||||||
|
window, respectively.
|
||||||
|
|
||||||
*fugitive-:Gsdiff*
|
*fugitive-:Gsdiff*
|
||||||
:Gsdiff [revision] Like |:Gdiff|, but always split horizontally.
|
:Gsdiff [object] Like |:Gdiff|, but always split horizontally.
|
||||||
|
|
||||||
*fugitive-:Gvdiff*
|
*fugitive-:Gvdiff*
|
||||||
:Gvdiff [revision] Like |:Gdiff|, but always split vertically.
|
:Gvdiff [object] Like |:Gdiff|, but always split vertically.
|
||||||
|
|
||||||
*fugitive-:Gmove*
|
*fugitive-:Gmove*
|
||||||
:Gmove {destination} Wrapper around git-mv that renames the buffer
|
:Gmove {destination} Wrapper around git-mv that renames the buffer
|
||||||
afterward. The destination is relative to the current
|
afterward. Add a ! to pass -f.
|
||||||
directory except when started with a /, in which case
|
|
||||||
it is relative to the work tree. (This is a holdover
|
|
||||||
from before |:Grename| and will be removed.) Add a !
|
|
||||||
to pass -f.
|
|
||||||
|
|
||||||
*fugitive-:Grename*
|
*fugitive-:Grename*
|
||||||
:Grename {destination} Like |:Gmove| but operates relative to the parent
|
:Grename {destination} Like |:Gmove| but operates relative to the parent
|
||||||
@@ -234,12 +231,11 @@ that are part of Git repositories).
|
|||||||
<CR> q, then open commit
|
<CR> q, then open commit
|
||||||
o open commit in horizontal split
|
o open commit in horizontal split
|
||||||
O open commit in new tab
|
O open commit in new tab
|
||||||
|
p open commit in preview window
|
||||||
- reblame at commit
|
- reblame at commit
|
||||||
~ reblame at [count]th first grandparent
|
~ reblame at [count]th first grandparent
|
||||||
P reblame at [count]th parent (like HEAD^[count])
|
P reblame at [count]th parent (like HEAD^[count])
|
||||||
|
|
||||||
:[range]Gblame [flags] Run git-blame on the given range.
|
|
||||||
|
|
||||||
*fugitive-:Gbrowse*
|
*fugitive-:Gbrowse*
|
||||||
:Gbrowse Open the current file, blob, tree, commit, or tag
|
:Gbrowse Open the current file, blob, tree, commit, or tag
|
||||||
in your browser at the upstream hosting provider.
|
in your browser at the upstream hosting provider.
|
||||||
@@ -251,24 +247,17 @@ that are part of Git repositories).
|
|||||||
supported by installing rhubarb.vim, available at
|
supported by installing rhubarb.vim, available at
|
||||||
<https://github.com/tpope/vim-rhubarb>.
|
<https://github.com/tpope/vim-rhubarb>.
|
||||||
|
|
||||||
The hosting provider is determined by looking at the
|
:Gbrowse {object} Like :Gbrowse, but for a given |fugitive-object|.
|
||||||
remote for the current or specified branch and falls
|
|
||||||
back to "origin". In the special case of a "."
|
|
||||||
remote, a local instance of git-instaweb will be
|
|
||||||
started and used.
|
|
||||||
|
|
||||||
:Gbrowse {revision} Like :Gbrowse, but for a given |fugitive-revision|. A
|
|
||||||
useful value here is -, which ties the URL to the
|
|
||||||
latest commit rather than a volatile branch.
|
|
||||||
|
|
||||||
:Gbrowse [...]@{remote} Force using the given remote rather than the remote
|
:Gbrowse [...]@{remote} Force using the given remote rather than the remote
|
||||||
for the current branch. The remote is used to
|
for the current branch. The remote is used to
|
||||||
determine which GitHub repository to link to.
|
determine which upstream repository to link to.
|
||||||
|
|
||||||
:{range}Gbrowse [args] Appends an anchor to the URL that emphasizes the
|
:{range}Gbrowse [args] Appends an anchor to the URL that emphasizes the
|
||||||
selected lines. You almost certainly want to give a
|
selected lines. This also forces the URL to include a
|
||||||
"-" argument in this case to force the URL to include
|
commit rather than a branch name so it remains valid
|
||||||
an exact revision.
|
if the file changes. You can give a range of "0" to
|
||||||
|
force this behavior without including an anchor.
|
||||||
|
|
||||||
:[range]Gbrowse! [args] Like :Gbrowse, but put the URL on the clipboard rather
|
:[range]Gbrowse! [args] Like :Gbrowse, but put the URL on the clipboard rather
|
||||||
than opening it.
|
than opening it.
|
||||||
@@ -279,26 +268,29 @@ These maps are available everywhere.
|
|||||||
|
|
||||||
*fugitive-c_CTRL-R_CTRL-G*
|
*fugitive-c_CTRL-R_CTRL-G*
|
||||||
<C-R><C-G> On the command line, recall the path to the current
|
<C-R><C-G> On the command line, recall the path to the current
|
||||||
object (that is, a representation of the object
|
|fugitive-object| (that is, a representation of the
|
||||||
recognized by |:Gedit|).
|
object recognized by |:Gedit|).
|
||||||
|
|
||||||
*fugitive-y_CTRL-G*
|
*fugitive-y_CTRL-G*
|
||||||
["x]y<C-G> Yank the commit SHA and path to the current object.
|
["x]y<C-G> Yank the commit SHA and path to the current
|
||||||
|
|fugitive-object|.
|
||||||
|
|
||||||
These maps are available in Git objects.
|
These maps are available in committed Git objects.
|
||||||
|
|
||||||
*fugitive-<CR>*
|
*fugitive-<CR>*
|
||||||
<CR> Jump to the revision under the cursor.
|
<CR> Jump to the |fugitive-object| under the cursor.
|
||||||
|
|
||||||
*fugitive-o*
|
*fugitive-o*
|
||||||
o Jump to the revision under the cursor in a new split.
|
o Jump to the |fugitive-object| under the cursor in a
|
||||||
|
new split.
|
||||||
|
|
||||||
*fugitive-S*
|
*fugitive-S*
|
||||||
S Jump to the revision under the cursor in a new
|
S Jump to the |fugitive-object| under the cursor in a
|
||||||
vertical split.
|
new vertical split.
|
||||||
|
|
||||||
*fugitive-O*
|
*fugitive-O*
|
||||||
O Jump to the revision under the cursor in a new tab.
|
O Jump to the |fugitive-object| under the cursor in a
|
||||||
|
new tab.
|
||||||
|
|
||||||
*fugitive--*
|
*fugitive--*
|
||||||
- Go to the tree containing the current tree or blob.
|
- Go to the tree containing the current tree or blob.
|
||||||
@@ -313,40 +305,38 @@ P Go to the current file in the [count]th parent.
|
|||||||
*fugitive-C*
|
*fugitive-C*
|
||||||
C Go to the commit containing the current file.
|
C Go to the commit containing the current file.
|
||||||
|
|
||||||
*fugitive-.*
|
|
||||||
. Start a |:| command line with the current revision
|
|
||||||
prepopulated at the end of the line.
|
|
||||||
|
|
||||||
*fugitive-a*
|
*fugitive-a*
|
||||||
a Show the current tag, commit, or tree in an alternate
|
a Show the current tag, commit, or tree in an alternate
|
||||||
format.
|
format.
|
||||||
|
|
||||||
SPECIFYING REVISIONS *fugitive-revision*
|
SPECIFYING OBJECTS *fugitive-object* *fugitive-revision*
|
||||||
|
|
||||||
Fugitive revisions are similar to Git revisions as defined in the "SPECIFYING
|
Fugitive objects are either work tree files or Git revisions as defined in the
|
||||||
REVISIONS" section in the git-rev-parse man page. For commands that accept an
|
"SPECIFYING REVISIONS" section in the git-rev-parse man page, with expansions
|
||||||
optional revision, the default is the file in the index for work tree files
|
inspired by |cmdline-special| layered on top. For commands that accept an
|
||||||
and the work tree file for everything else. Example revisions follow.
|
optional object, the default is the file in the index for work tree files and
|
||||||
|
the work tree file for everything else. Example objects follow.
|
||||||
|
|
||||||
Revision Meaning ~
|
Object Meaning ~
|
||||||
HEAD .git/HEAD
|
HEAD .git/HEAD
|
||||||
refs/heads/x .git/refs/heads/x
|
refs/heads/x .git/refs/heads/x (in "common dir" if present)
|
||||||
@ The commit referenced by @ aka HEAD
|
@ The commit referenced by @ aka HEAD
|
||||||
master^ The parent of the commit referenced by master
|
master^ The parent of the commit referenced by master
|
||||||
master: The tree referenced by master
|
master: The tree referenced by master
|
||||||
/master The file named master in the work tree
|
./master The file named master in the working directory
|
||||||
Makefile The file named Makefile in the work tree
|
Makefile The file named Makefile in the work tree
|
||||||
@^:Makefile The file named Makefile in the parent of HEAD
|
@^:Makefile The file named Makefile in the parent of HEAD
|
||||||
:Makefile The file named Makefile in the index (writable)
|
:Makefile The file named Makefile in the index (writable)
|
||||||
- The current file in HEAD
|
@~2:% The current file in the grandparent of HEAD
|
||||||
^ The current file in the previous commit
|
:% The current file in the index
|
||||||
~3 The current file 3 commits ago
|
:1:% The current file's common ancestor during a conflict
|
||||||
: .git/index (Same as |:Gstatus|)
|
:2:# The alternate file in the target branch during a conflict
|
||||||
:0 The current file in the index
|
:3:#5 The file from buffer #5 in the merged branch during a conflict
|
||||||
:1 The current file's common ancestor during a conflict
|
! The commit owning the current file
|
||||||
:2 The current file in the target branch during a conflict
|
!:Makefile The file named Makefile in the commit owning the current file
|
||||||
:3 The current file in the merged branch during a conflict
|
!3^2 The second parent of the commit owning buffer #3
|
||||||
:/foo The most recent commit with "foo" in the message
|
.git/config The repo config file
|
||||||
|
: Same as |:Gstatus|
|
||||||
|
|
||||||
STATUSLINE *fugitive-statusline*
|
STATUSLINE *fugitive-statusline*
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
" fugitive.vim - A Git wrapper so awesome, it should be illegal
|
" fugitive.vim - A Git wrapper so awesome, it should be illegal
|
||||||
" Maintainer: Tim Pope <http://tpo.pe/>
|
" Maintainer: Tim Pope <http://tpo.pe/>
|
||||||
" Version: 2.4
|
" Version: 2.5
|
||||||
" GetLatestVimScripts: 2975 1 :AutoInstall: fugitive.vim
|
" GetLatestVimScripts: 2975 1 :AutoInstall: fugitive.vim
|
||||||
|
|
||||||
if exists('g:loaded_fugitive')
|
if exists('g:loaded_fugitive')
|
||||||
@@ -8,14 +8,93 @@ if exists('g:loaded_fugitive')
|
|||||||
endif
|
endif
|
||||||
let g:loaded_fugitive = 1
|
let g:loaded_fugitive = 1
|
||||||
|
|
||||||
function! s:shellslash(path) abort
|
function! FugitiveGitDir(...) abort
|
||||||
if &shell =~? 'cmd' || exists('+shellslash') && !&shellslash
|
if !a:0 || a:1 ==# -1
|
||||||
return tr(a:path, '\', '/')
|
return get(b:, 'git_dir', '')
|
||||||
|
elseif type(a:1) == type(0)
|
||||||
|
return getbufvar(a:1, 'git_dir')
|
||||||
|
elseif type(a:1) == type('')
|
||||||
|
return substitute(s:Slash(a:1), '/$', '', '')
|
||||||
else
|
else
|
||||||
return a:path
|
return ''
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! FugitiveCommonDir(...) abort
|
||||||
|
let dir = FugitiveGitDir(a:0 ? a:1 : -1)
|
||||||
|
if empty(dir)
|
||||||
|
return ''
|
||||||
|
endif
|
||||||
|
return fugitive#CommonDir(dir)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! FugitiveWorkTree(...) abort
|
||||||
|
return FugitiveTreeForGitDir(FugitiveGitDir(a:0 ? a:1 : -1))
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! FugitiveReal(...) abort
|
||||||
|
let file = a:0 ? a:1 : @%
|
||||||
|
if file =~# '^\a\a\+:' || a:0 > 1
|
||||||
|
return call('fugitive#Real', [file] + a:000[1:-1])
|
||||||
|
elseif file =~# '^/\|^\a:\|^$'
|
||||||
|
return file
|
||||||
|
else
|
||||||
|
return fnamemodify(file, ':p' . (file =~# '[\/]$' ? '' : ':s?[\/]$??'))
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! FugitiveFind(...) abort
|
||||||
|
return fugitive#Find(a:0 ? a:1 : bufnr(''), FugitiveGitDir(a:0 > 1 ? a:2 : -1))
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! FugitivePath(...) abort
|
||||||
|
if a:0 > 1
|
||||||
|
return fugitive#Path(a:1, a:2, FugitiveGitDir(a:0 > 2 ? a:3 : -1))
|
||||||
|
else
|
||||||
|
return FugitiveReal(a:0 ? a:1 : @%)
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! FugitiveParse(...) abort
|
||||||
|
let path = s:Slash(a:0 ? a:1 : @%)
|
||||||
|
if path !~# '^fugitive:'
|
||||||
|
return ['', '']
|
||||||
|
endif
|
||||||
|
let vals = matchlist(path, '\c^fugitive:\%(//\)\=\(.\{-\}\)\%(//\|::\)\(\x\{40\}\|[0-3]\)\(/.*\)\=$')
|
||||||
|
if len(vals)
|
||||||
|
return [(vals[2] =~# '^.$' ? ':' : '') . vals[2] . substitute(vals[3], '^/', ':', ''), vals[1]]
|
||||||
|
endif
|
||||||
|
let v:errmsg = 'fugitive: invalid Fugitive URL ' . path
|
||||||
|
throw v:errmsg
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! FugitivePrepare(...) abort
|
||||||
|
return call('fugitive#Prepare', a:000)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! FugitiveConfig(key, ...) abort
|
||||||
|
return fugitive#Config(a:key, FugitiveGitDir(a:0 ? a:1 : -1))
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! FugitiveRemoteUrl(...) abort
|
||||||
|
return fugitive#RemoteUrl(a:0 ? a:1 : '', FugitiveGitDir(a:0 > 1 ? a:2 : -1))
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! FugitiveHead(...) abort
|
||||||
|
let dir = FugitiveGitDir(a:0 > 1 ? a:2 : -1)
|
||||||
|
if empty(dir)
|
||||||
|
return ''
|
||||||
|
endif
|
||||||
|
return fugitive#Head(a:0 ? a:1 : 0, dir)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! FugitiveStatusline(...) abort
|
||||||
|
if !exists('b:git_dir')
|
||||||
|
return ''
|
||||||
|
endif
|
||||||
|
return fugitive#Statusline()
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! FugitiveIsGitDir(path) abort
|
function! FugitiveIsGitDir(path) abort
|
||||||
let path = substitute(a:path, '[\/]$', '', '') . '/'
|
let path = substitute(a:path, '[\/]$', '', '') . '/'
|
||||||
return getfsize(path.'HEAD') > 10 && (
|
return getfsize(path.'HEAD') > 10 && (
|
||||||
@@ -25,10 +104,12 @@ endfunction
|
|||||||
|
|
||||||
let s:worktree_for_dir = {}
|
let s:worktree_for_dir = {}
|
||||||
let s:dir_for_worktree = {}
|
let s:dir_for_worktree = {}
|
||||||
function! FugitiveTreeForGitDir(git_dir) abort
|
function! FugitiveTreeForGitDir(path) abort
|
||||||
let dir = substitute(s:shellslash(a:git_dir), '/$', '', '')
|
let dir = a:path
|
||||||
if dir =~# '/\.git$'
|
if dir =~# '/\.git$'
|
||||||
return len(dir) ==# 5 ? '/' : dir[0:-6]
|
return len(dir) ==# 5 ? '/' : dir[0:-6]
|
||||||
|
elseif dir ==# ''
|
||||||
|
return ''
|
||||||
endif
|
endif
|
||||||
if !has_key(s:worktree_for_dir, dir)
|
if !has_key(s:worktree_for_dir, dir)
|
||||||
let s:worktree_for_dir[dir] = ''
|
let s:worktree_for_dir[dir] = ''
|
||||||
@@ -58,7 +139,7 @@ function! FugitiveTreeForGitDir(git_dir) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! FugitiveExtractGitDir(path) abort
|
function! FugitiveExtractGitDir(path) abort
|
||||||
let path = s:shellslash(a:path)
|
let path = s:Slash(a:path)
|
||||||
if path =~# '^fugitive:'
|
if path =~# '^fugitive:'
|
||||||
return matchstr(path, '\C^fugitive:\%(//\)\=\zs.\{-\}\ze\%(//\|::\|$\)')
|
return matchstr(path, '\C^fugitive:\%(//\)\=\zs.\{-\}\ze\%(//\|::\|$\)')
|
||||||
elseif isdirectory(path)
|
elseif isdirectory(path)
|
||||||
@@ -66,6 +147,10 @@ function! FugitiveExtractGitDir(path) abort
|
|||||||
else
|
else
|
||||||
let path = fnamemodify(path, ':p:h:s?/$??')
|
let path = fnamemodify(path, ':p:h:s?/$??')
|
||||||
endif
|
endif
|
||||||
|
let pre = substitute(matchstr(path, '^\a\a\+\ze:'), '^.', '\u&', '')
|
||||||
|
if len(pre) && exists('*' . pre . 'Real')
|
||||||
|
let path = s:Slash({pre}Real(path))
|
||||||
|
endif
|
||||||
let root = resolve(path)
|
let root = resolve(path)
|
||||||
if root !=# path
|
if root !=# path
|
||||||
silent! exe haslocaldir() ? 'lcd .' : 'cd .'
|
silent! exe haslocaldir() ? 'lcd .' : 'cd .'
|
||||||
@@ -82,7 +167,7 @@ function! FugitiveExtractGitDir(path) abort
|
|||||||
return simplify(fnamemodify($GIT_DIR, ':p:s?[\/]$??'))
|
return simplify(fnamemodify($GIT_DIR, ':p:s?[\/]$??'))
|
||||||
endif
|
endif
|
||||||
if FugitiveIsGitDir($GIT_DIR)
|
if FugitiveIsGitDir($GIT_DIR)
|
||||||
call FugitiveTreeForGitDir(simplify(fnamemodify($GIT_DIR, ':p:s?[\/]$??')))
|
call FugitiveWorkTree(simplify(fnamemodify($GIT_DIR, ':p:s?[\/]$??')))
|
||||||
if has_key(s:dir_for_worktree, root)
|
if has_key(s:dir_for_worktree, root)
|
||||||
return s:dir_for_worktree[root]
|
return s:dir_for_worktree[root]
|
||||||
endif
|
endif
|
||||||
@@ -110,7 +195,7 @@ function! FugitiveExtractGitDir(path) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! FugitiveDetect(path) abort
|
function! FugitiveDetect(path) abort
|
||||||
if exists('b:git_dir') && (b:git_dir ==# '' || b:git_dir =~# '/$')
|
if exists('b:git_dir') && b:git_dir =~# '^$\|/$\|^fugitive:'
|
||||||
unlet b:git_dir
|
unlet b:git_dir
|
||||||
endif
|
endif
|
||||||
if !exists('b:git_dir')
|
if !exists('b:git_dir')
|
||||||
@@ -124,66 +209,75 @@ function! FugitiveDetect(path) abort
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! FugitiveStatusline(...) abort
|
function! s:Slash(path) abort
|
||||||
if !exists('b:git_dir')
|
if exists('+shellslash')
|
||||||
return ''
|
return tr(a:path, '\', '/')
|
||||||
endif
|
|
||||||
return fugitive#Statusline()
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! FugitiveHead(...) abort
|
|
||||||
if !exists('b:git_dir')
|
|
||||||
return ''
|
|
||||||
endif
|
|
||||||
return fugitive#repo().head(a:0 ? a:1 : 0)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! FugitivePath(...) abort
|
|
||||||
let file = fnamemodify(a:0 ? a:1 : @%, ':p')
|
|
||||||
if file =~? '^fugitive:'
|
|
||||||
return fugitive#Path(file)
|
|
||||||
else
|
else
|
||||||
return file
|
return a:path
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! FugitiveReal(...) abort
|
function! s:ProjectionistDetect() abort
|
||||||
return call('FugitivePath', a:000)
|
let file = s:Slash(get(g:, 'projectionist_file', ''))
|
||||||
|
let dir = FugitiveExtractGitDir(file)
|
||||||
|
let base = matchstr(file, '^fugitive://.\{-\}//\x\+')
|
||||||
|
if empty(base)
|
||||||
|
let base = FugitiveTreeForGitDir(dir)
|
||||||
|
endif
|
||||||
|
if len(base)
|
||||||
|
if exists('+shellslash') && !&shellslash
|
||||||
|
let base = tr(base, '/', '\')
|
||||||
|
endif
|
||||||
|
call projectionist#append(base, FugitiveCommonDir(dir) . '/info/projections.json')
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
augroup fugitive
|
augroup fugitive
|
||||||
autocmd!
|
autocmd!
|
||||||
|
|
||||||
autocmd BufNewFile,BufReadPost * call FugitiveDetect(expand('%:p'))
|
autocmd BufNewFile,BufReadPost * call FugitiveDetect(expand('<amatch>:p'))
|
||||||
autocmd FileType netrw call FugitiveDetect(fnamemodify(get(b:, 'netrw_curdir', @%), ':p'))
|
autocmd FileType netrw call FugitiveDetect(fnamemodify(get(b:, 'netrw_curdir', expand('<amatch>')), ':p'))
|
||||||
autocmd User NERDTreeInit,NERDTreeNewRoot
|
autocmd User NERDTreeInit,NERDTreeNewRoot
|
||||||
\ if exists('b:NERDTree.root.path.str') |
|
\ if exists('b:NERDTree.root.path.str') |
|
||||||
\ call FugitiveDetect(b:NERDTree.root.path.str()) |
|
\ call FugitiveDetect(b:NERDTree.root.path.str()) |
|
||||||
\ endif
|
\ endif
|
||||||
autocmd VimEnter * if expand('<amatch>')==''|call FugitiveDetect(getcwd())|endif
|
autocmd VimEnter * if empty(expand('<amatch>'))|call FugitiveDetect(getcwd())|endif
|
||||||
autocmd CmdWinEnter * call FugitiveDetect(expand('#:p'))
|
autocmd CmdWinEnter * call FugitiveDetect(expand('#:p'))
|
||||||
|
|
||||||
autocmd FileType git
|
autocmd FileType git
|
||||||
\ if exists('b:git_dir') |
|
\ if exists('b:git_dir') |
|
||||||
\ call fugitive#MapJumps() |
|
\ call fugitive#MapJumps() |
|
||||||
\ endif
|
|
||||||
autocmd FileType git,gitcommit,gitrebase
|
|
||||||
\ if exists('b:git_dir') |
|
|
||||||
\ call fugitive#MapCfile() |
|
\ call fugitive#MapCfile() |
|
||||||
\ endif
|
\ endif
|
||||||
|
autocmd FileType gitcommit
|
||||||
|
\ if exists('b:git_dir') |
|
||||||
|
\ call fugitive#MapCfile('fugitive#StatusCfile()') |
|
||||||
|
\ endif
|
||||||
|
autocmd FileType gitrebase
|
||||||
|
\ let &l:include = '^\%(pick\|squash\|edit\|reword\|fixup\|drop\|[pserfd]\)\>' |
|
||||||
|
\ if exists('b:git_dir') |
|
||||||
|
\ let &l:includeexpr = 'v:fname =~# ''^\x\{4,40\}$'' ? FugitiveFind(v:fname) : ' .
|
||||||
|
\ (len(&l:includeexpr) ? &l:includeexpr : 'v:fname') |
|
||||||
|
\ endif |
|
||||||
|
\ let b:undo_ftplugin = get(b:, 'undo_ftplugin', 'exe') . '|setl inex= inc='
|
||||||
|
|
||||||
autocmd BufReadCmd index{,.lock}
|
autocmd BufReadCmd index{,.lock}
|
||||||
\ if FugitiveIsGitDir(expand('<amatch>:p:h')) |
|
\ if FugitiveIsGitDir(expand('<amatch>:p:h')) |
|
||||||
|
\ let b:git_dir = s:Slash(expand('<amatch>:p:h')) |
|
||||||
\ exe fugitive#BufReadStatus() |
|
\ exe fugitive#BufReadStatus() |
|
||||||
\ elseif filereadable(expand('<amatch>')) |
|
\ elseif filereadable(expand('<amatch>')) |
|
||||||
\ read <amatch> |
|
\ read <amatch> |
|
||||||
\ 1delete |
|
\ 1delete_ |
|
||||||
\ endif
|
\ endif
|
||||||
autocmd FileReadCmd fugitive://**//[0-3]/** exe fugitive#FileRead()
|
autocmd BufReadCmd fugitive://*//* exe fugitive#BufReadCmd()
|
||||||
autocmd BufReadCmd fugitive://**//[0-3]/** exe fugitive#BufReadIndex()
|
autocmd BufWriteCmd fugitive://*//[0-3]/* exe fugitive#BufWriteCmd()
|
||||||
autocmd BufWriteCmd fugitive://**//[0-3]/** exe fugitive#BufWriteIndex()
|
autocmd FileReadCmd fugitive://*//* exe fugitive#FileReadCmd()
|
||||||
autocmd BufReadCmd fugitive://**//[0-9a-f][0-9a-f]* exe fugitive#BufReadObject()
|
autocmd FileWriteCmd fugitive://*//[0-3]/* exe fugitive#FileWriteCmd()
|
||||||
autocmd FileReadCmd fugitive://**//[0-9a-f][0-9a-f]* exe fugitive#FileRead()
|
if exists('##SourceCmd')
|
||||||
|
autocmd SourceCmd fugitive://*//* nested exe fugitive#SourceCmd()
|
||||||
|
endif
|
||||||
|
|
||||||
autocmd User Flags call Hoist('buffer', function('FugitiveStatusline'))
|
autocmd User Flags call Hoist('buffer', function('FugitiveStatusline'))
|
||||||
|
|
||||||
|
autocmd User ProjectionistDetect call s:ProjectionistDetect()
|
||||||
augroup END
|
augroup END
|
||||||
|
|||||||
Reference in New Issue
Block a user