2 Commits

Author SHA1 Message Date
Tim Pope
62c50ff296 Handle .git in file system root
References https://github.com/tpope/vim-fugitive/issues/908
2017-05-07 15:29:01 -04:00
Tim Pope
c2877d0d5c Show commit message in :Gblame statusline
References #405.
2017-05-02 20:52:19 -04:00
7 changed files with 3155 additions and 4200 deletions

2
.gitattributes vendored
View File

@@ -1,2 +0,0 @@
.git* export-ignore
*.markdown export-ignore

View File

@@ -8,14 +8,8 @@ platform issues, and interactions with other plugins. I end up bisecting a
lot more than other projects, and thus I'm especially meticulous here about lot more than other projects, and thus I'm especially meticulous here about
maintaining a clean, readable, history. Squash and force push any requested maintaining a clean, readable, history. Squash and force push any requested
changes to a pull request. And if your [commit message changes to a pull request. And if your [commit message
sucks](https://commit.style), I'm not going to accept it. Period. sucks](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html),
I'm not going to accept it. Period.
If your contribution involves adding a configuration option, you are going to
need a very compelling justification for it. Options add a maintenance
burden, support burden, and documentation bloat, and oftentimes can be
achieved much more simply with a custom map or autocommand. If your option
controls an underlying Git command, ask yourself why Git itself does not offer
such configuration.
Beyond that, don't be shy about asking before patching. What takes you hours Beyond that, don't be shy about asking before patching. What takes you hours
might take me minutes simply because I have both domain knowledge and a might take me minutes simply because I have both domain knowledge and a

View File

@@ -11,9 +11,8 @@ 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`. Use `add`/`reset` a file's changes, or `p` to `add`/`reset` `--patch`. And guess
`:Gcommit %` to commit the current file, editing the commit message inside what `:Gcommit` does!
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
@@ -21,7 +20,7 @@ changed, or `o` to open it in a split. When you're done, use `:Gedit`
in the historic buffer to go back to the work tree version. in the historic buffer to go back to the work tree version.
`:Gmove` does a `git mv` on a file and simultaneously renames the `:Gmove` does a `git mv` on a file and simultaneously renames the
buffer. `:Gdelete` does a `git rm` on a file and simultaneously deletes buffer. `:Gremove` does a `git rm` on a file and simultaneously deletes
the buffer. the buffer.
Use `:Ggrep` to search the work tree (or any arbitrary commit) with Use `:Ggrep` to search the work tree (or any arbitrary commit) with
@@ -37,15 +36,16 @@ 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!). Plugins hosting provider, with optional line range (try it in visual mode!). Built-in
are available for popular providers such as [GitHub][rhubarb.vim], support is provided for `git instaweb`, and plugins are available for popular
[GitLab][fugitive-gitlab.vim], and [Bitbucket][fubitive.vim]. providers such as [GitHub][rhubarb.vim], [GitLab][fugitive-gitlab.vim], and
[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
[fubitive.vim]: https://github.com/tommcdo/vim-fubitive [fubitive.vim]: https://github.com/tommcdo/vim-fubitive
Add `%{FugitiveStatusline()}` to `'statusline'` to get an indicator Add `%{fugitive#statusline()}` to `'statusline'` to get an indicator
with the current branch in (surprise!) your statusline. with the current branch in (surprise!) your statusline.
Last but not least, there's `:Git` for running any arbitrary command, Last but not least, there's `:Git` for running any arbitrary command,
@@ -66,7 +66,7 @@ If you don't have a preferred installation method, one option is to install
and paste: and paste:
cd ~/.vim/bundle cd ~/.vim/bundle
git clone https://github.com/tpope/vim-fugitive.git git clone git://github.com/tpope/vim-fugitive.git
vim -u NONE -c "helptags vim-fugitive/doc" -c q vim -u NONE -c "helptags vim-fugitive/doc" -c q
If your Vim version is below 7.2, I recommend also installing If your Vim version is below 7.2, I recommend also installing
@@ -75,11 +75,24 @@ other Git niceties.
## FAQ ## FAQ
> Why don't any of the commands exist? > I installed the plugin and started Vim. Why don't any of the commands
> exist?
Fugitive cares about the current file, not the current working directory. Fugitive cares about the current file, not the current working
Edit a file from the repository. To avoid the blank window problem, favor directory. Edit a file from the repository.
commands like `:split` and `:tabedit` over commands like `:new` and `:tabnew`.
> I opened a new tab. Why don't any of the commands exist?
Fugitive cares about the current file, not the current working
directory. Edit a file from the repository.
> Why is `:Gbrowse` not using the right browser?
`:Gbrowse` delegates to `git web--browse`, which is less than perfect
when it comes to finding the right browser. You can tell it the correct
browser to use with `git config --global web.browser ...`. On OS X, for
example, you might want to set this to `open`. See `git web--browse --help`
for details.
> Here's a patch that automatically opens the quickfix window after > Here's a patch that automatically opens the quickfix window after
> `:Ggrep`. > `:Ggrep`.

File diff suppressed because it is too large Load Diff

View File

@@ -40,12 +40,10 @@ that are part of Git repositories).
<CR> |:Gedit| <CR> |:Gedit|
- |:Git| add - |:Git| add
- |:Git| reset (staged files) - |:Git| reset (staged files)
a Show alternative format cA |:Gcommit| --amend --reuse-message=HEAD
ca |:Gcommit| --amend ca |:Gcommit| --amend
cc |:Gcommit| cc |:Gcommit|
ce |:Gcommit| --amend --no-edit cva |:Gcommit| --amend --verbose
cw |:Gcommit| --amend --only
cva |:Gcommit| --verbose --amend
cvc |:Gcommit| --verbose cvc |:Gcommit| --verbose
D |:Gdiff| D |:Gdiff|
ds |:Gsdiff| ds |:Gsdiff|
@@ -54,8 +52,8 @@ that are part of Git repositories).
dv |:Gvdiff| dv |:Gvdiff|
O |:Gtabedit| O |:Gtabedit|
o |:Gsplit| o |:Gsplit|
P |:Git| add --patch p |:Git| add --patch
P |:Git| reset --patch (staged files) p |:Git| reset --patch (staged files)
q close status q close status
r reload status r reload status
S |:Gvsplit| S |:Gvsplit|
@@ -63,7 +61,6 @@ 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
@@ -79,21 +76,17 @@ that are part of Git repositories).
*fugitive-:Gmerge* *fugitive-:Gmerge*
:Gmerge [args] Calls git-merge and loads errors and conflicted files :Gmerge [args] Calls git-merge and loads errors and conflicted files
into the |quickfix| list. Opens a |:Gcommit| style into the quickfix list. Opens a |:Gcommit| style
split window for the commit message if the merge split window for the commit message if the merge
succeeds. If called during a merge conflict, the succeeds. If called during a merge conflict, the
conflicted files from the current index are loaded conflicted files from the current index are loaded
into the |quickfix| list. into the quickfix list.
*fugitive-:Gpull* *fugitive-:Gpull*
:Gpull [args] Like |:Gmerge|, but for git-pull. :Gpull [args] Like |:Gmerge|, but for git-pull.
*fugitive-:Grebase*
:Grebase [args] Like |:Gmerge|, but for git-rebase. Interactive
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
list, and invoke |:cwindow| to reveal any errors. list, and invoke |:cwindow| to reveal any errors.
|:Dispatch| is used if available for asynchronous |:Dispatch| is used if available for asynchronous
invocation. invocation.
@@ -109,35 +102,35 @@ that are part of Git repositories).
*fugitive-:Glog* *fugitive-:Glog*
:Glog [args] Load all previous revisions of the current file into :Glog [args] Load all previous revisions of the current file into
the |quickfix| list. Additional git-log arguments can the quickfix list. Additional git-log arguments can
be given (for example, --reverse). If "--" appears as be given (for example, --reverse). If "--" appears as
an argument, no file specific filtering is done, and an argument, no file specific filtering is done, and
previous commits rather than previous file revisions previous commits rather than previous file revisions
are loaded. are loaded.
:{range}Glog [args] Use git-log -L to load previous revisions of the given :{range}Glog [args] Use git-log -L to load previous revisions of the given
range of the current file into the |quickfix| list. range of the current file into the quickfix list. The
The cursor is positioned on the first line of the cursor is positioned on the first line of the first
first diff hunk for each commit. diff hunk for each commit.
*fugitive-:Gllog* *fugitive-:Gllog*
:Gllog [args] Like |:Glog|, but use the location list instead of the :Gllog [args] Like |:Glog|, but use the location list instead of the
|quickfix| list. quickfix list.
*fugitive-:Gedit* *fugitive-:Ge* *fugitive-:Gedit* *fugitive-:Ge*
:Gedit [object] |:edit| a |fugitive-object|. :Gedit [revision] |:edit| a |fugitive-revision|.
*fugitive-:Gsplit* *fugitive-:Gsplit*
:Gsplit [object] |:split| a |fugitive-object|. :Gsplit [revision] |:split| a |fugitive-revision|.
*fugitive-:Gvsplit* *fugitive-:Gvsplit*
:Gvsplit [object] |:vsplit| a |fugitive-object|. :Gvsplit [revision] |:vsplit| a |fugitive-revision|.
*fugitive-:Gtabedit* *fugitive-:Gtabedit*
:Gtabedit [object] |:tabedit| a |fugitive-object|. :Gtabedit [revision] |:tabedit| a |fugitive-revision|.
*fugitive-:Gpedit* *fugitive-:Gpedit*
:Gpedit [object] |:pedit| a |fugitive-object|. :Gpedit [revision] |:pedit| a |fugitive-revision|.
:Gsplit! [args] *fugitive-:Gsplit!* *fugitive-:Gvsplit!* :Gsplit! [args] *fugitive-:Gsplit!* *fugitive-:Gvsplit!*
:Gvsplit! [args] *fugitive-:Gtabedit!* *fugitive-:Gpedit!* :Gvsplit! [args] *fugitive-:Gtabedit!* *fugitive-:Gpedit!*
@@ -145,12 +138,13 @@ 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 [object] Empty the buffer and |:read| a |fugitive-object|. :Gread [revision] Empty the buffer and |:read| a |fugitive-revision|.
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 [object] |:read| in a |fugitive-object| after {range}. :{range}Gread [revision]
|: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,42 +173,36 @@ that are part of Git repositories).
succeeded. succeeded.
*fugitive-:Gdiff* *fugitive-:Gdiff*
:Gdiff [object] Perform a |vimdiff| against the given file, or if a :Gdiff [revision] Perform a |vimdiff| against the current file in the
commit is given, the current file in that commit. given revision. With no argument, the version in the
With no argument, the version in the index is used index is used (which means a three-way diff during a
(which means a three-way diff during a merge conflict, merge conflict, making it a git-mergetool
making it a git-mergetool alternative). The newer of alternative). The newer of the two files is placed
the two files is placed to the right or bottom, to the right or bottom, depending on 'diffopt' and
depending on 'diffopt', and the width of the window the width of the window relative to 'textwidth'. Use
relative to 'textwidth'. Use |do| and |dp| and write |do| and |dp| and write to the index file to simulate
to the index file to simulate "git add --patch". For "git add --patch". For the three-way diff, there is
the three-way diff, there is also d2o and d3o pulling also d2o and d3o pulling the hunk to the middle from
the hunk to the middle from the left or the right the left or the right window, respectively.
window, respectively.
*fugitive-:Gsdiff* *fugitive-:Gsdiff*
:Gsdiff [object] Like |:Gdiff|, but always split horizontally. :Gsdiff [revision] Like |:Gdiff|, but always split horizontally.
*fugitive-:Gvdiff* *fugitive-:Gvdiff*
:Gvdiff [object] Like |:Gdiff|, but always split vertically. :Gvdiff [revision] 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. Add a ! to pass -f. afterward. The destination is relative to the current
directory except when started with a /, in which case
it is relative to the work tree. Add a ! to pass -f.
*fugitive-:Grename* *fugitive-:Gremove*
:Grename {destination} Like |:Gmove| but operates relative to the parent :Gremove Wrapper around git-rm that deletes the buffer
directory of the current file.
*fugitive-:Gdelete*
:Gdelete Wrapper around git-rm that deletes the buffer
afterward. When invoked in an index file, --cached is afterward. When invoked in an index file, --cached is
passed. Add a ! to pass -f and forcefully discard the passed. Add a ! to pass -f and forcefully discard the
buffer. buffer.
*fugitive-:Gremove*
:Gremove Like :Gdelete, but keep the (now empty) buffer around.
*fugitive-:Gblame* *fugitive-:Gblame*
:Gblame [flags] Run git-blame on the file and open the results in a :Gblame [flags] Run git-blame on the file and open the results in a
scroll bound vertical split. You can give any of scroll bound vertical split. You can give any of
@@ -231,11 +219,12 @@ 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.
@@ -247,17 +236,24 @@ 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>.
:Gbrowse {object} Like :Gbrowse, but for a given |fugitive-object|. The hosting provider is determined by looking at the
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 upstream repository to link to. determine which GitHub 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. This also forces the URL to include a selected lines. You almost certainly want to give a
commit rather than a branch name so it remains valid "-" argument in this case to force the URL to include
if the file changes. You can give a range of "0" to an exact revision.
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.
@@ -268,29 +264,26 @@ 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
|fugitive-object| (that is, a representation of the object (that is, a representation of the object
object recognized by |:Gedit|). recognized by |:Gedit|).
*fugitive-y_CTRL-G* *fugitive-y_CTRL-G*
["x]y<C-G> Yank the commit SHA and path to the current ["x]y<C-G> Yank the commit SHA and path to the current object.
|fugitive-object|.
These maps are available in committed Git objects. These maps are available in Git objects.
*fugitive-<CR>* *fugitive-<CR>*
<CR> Jump to the |fugitive-object| under the cursor. <CR> Jump to the revision under the cursor.
*fugitive-o* *fugitive-o*
o Jump to the |fugitive-object| under the cursor in a o Jump to the revision under the cursor in a new split.
new split.
*fugitive-S* *fugitive-S*
S Jump to the |fugitive-object| under the cursor in a S Jump to the revision under the cursor in a new
new vertical split. vertical split.
*fugitive-O* *fugitive-O*
O Jump to the |fugitive-object| under the cursor in a O Jump to the revision under the cursor in a new tab.
new tab.
*fugitive--* *fugitive--*
- Go to the tree containing the current tree or blob. - Go to the tree containing the current tree or blob.
@@ -305,51 +298,53 @@ 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 OBJECTS *fugitive-object* *fugitive-revision* SPECIFYING REVISIONS *fugitive-revision*
Fugitive objects are either work tree files or Git revisions as defined in the Fugitive revisions are similar to Git revisions as defined in the "SPECIFYING
"SPECIFYING REVISIONS" section in the git-rev-parse man page, with expansions REVISIONS" section in the git-rev-parse man page. For commands that accept an
inspired by |cmdline-special| layered on top. For commands that accept an optional revision, the default is the file in the index for work tree files
optional object, the default is the file in the index for work tree files and and the work tree file for everything else. Example revisions follow.
the work tree file for everything else. Example objects follow.
Object Meaning ~ Revision Meaning ~
HEAD .git/HEAD HEAD .git/HEAD
refs/heads/x .git/refs/heads/x (in "common dir" if present) master .git/refs/heads/master
@ The commit referenced by @ aka HEAD HEAD^{} The commit referenced by HEAD
master^ The parent of the commit referenced by master HEAD^ The parent of the commit referenced by HEAD
master: The tree referenced by master HEAD: The tree referenced by HEAD
./master The file named master in the working directory /HEAD The file named HEAD in the work tree
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 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)
@~2:% The current file in the grandparent of HEAD - The current file in HEAD
:% The current file in the index ^ The current file in the previous commit
:1:% The current file's common ancestor during a conflict ~3 The current file 3 commits ago
:2:# The alternate file in the target branch during a conflict : .git/index (Same as |:Gstatus|)
:3:#5 The file from buffer #5 in the merged branch during a conflict :0 The current file in the index
! The commit owning the current file :1 The current file's common ancestor during a conflict
!:Makefile The file named Makefile in the commit owning the current file :2 The current file in the target branch during a conflict
!3^2 The second parent of the commit owning buffer #3 :3 The current file in the merged branch during a conflict
.git/config The repo config file :/foo The most recent commit with "foo" in the message
: Same as |:Gstatus|
STATUSLINE *fugitive-statusline* STATUSLINE *fugitive-statusline*
*FugitiveStatusline()* *fugitive#statusline()* *fugitive#statusline()*
Add %{FugitiveStatusline()} to your statusline to get an indicator including Add %{fugitive#statusline()} to your statusline to get an indicator including
the current branch and the currently edited file's commit. If you don't have the current branch and the currently edited file's commit. If you don't have
a statusline, this one matches the default when 'ruler' is set: a statusline, this one matches the default when 'ruler' is set:
> >
set statusline=%<%f\ %h%m%r%{FugitiveStatusline()}%=%-14.(%l,%c%V%)\ %P set statusline=%<%f\ %h%m%r%{fugitive#statusline()}%=%-14.(%l,%c%V%)\ %P
< <
*FugitiveHead(...)* *fugitive#head(...)* *fugitive#head(...)*
Use FugitiveHead() to return the name of the current branch. If the current Use fugitive#head() to return the name of the current branch. If the current
HEAD is detached, FugitiveHead() will return the empty string, unless the HEAD is detached, fugitive#head() will return the empty string, unless the
optional argument is given, in which case the hash of the current commit will optional argument is given, in which case the hash of the current commit will
be truncated to the given number of characters. be truncated to the given number of characters.

View File

@@ -1 +0,0 @@
autocmd BufReadPost *.fugitiveblame setfiletype fugitiveblame

File diff suppressed because it is too large Load Diff