1 Commits

Author SHA1 Message Date
Tim Pope
ff32149a59 Attempt to allow :Gbrowse on HTTP GitHub FI 2012-11-18 21:35:45 -05:00
5 changed files with 652 additions and 1374 deletions

2
.gitattributes vendored
View File

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

View File

@@ -1,24 +0,0 @@
Before reporting a bug, you should try stripping down your Vim configuration
and removing other plugins. The sad truth about VimScript is that it is
fraught with incompatibilities waiting to happen. I'm happy to work around
them where I can, but it's up to you to isolate the conflict.
Fugitive is particularly prone to regressions due to Git version issues,
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
maintaining a clean, readable, history. Squash and force push any requested
changes to a pull request. And if your [commit message
sucks](https://commit.style), 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
might take me minutes simply because I have both domain knowledge and a
perverse knowledge of VimScript so vast that many would consider it a symptom
of mental illness. On the flip side, some ideas I'll reject no matter how
good the implementation is. "Send a patch" is an edge case answer in my book.

View File

@@ -1,4 +1,5 @@
# fugitive.vim fugitive.vim
============
I'm not going to lie to you; fugitive.vim may very well be the best I'm not going to lie to you; fugitive.vim may very well be the best
Git wrapper of all time. Check out these features: Git wrapper of all time. Check out these features:
@@ -11,16 +12,16 @@ 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` that
what `:Gcommit` does! mofo. And guess what `:Gcommit` does!
`: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 reblame the file as it stood in that
changed, or `o` to open it in a split. When you're done, use `:Gedit` commit, or `o` to open that commit in a split. When you're done, use
in the historic buffer to go back to the work tree version. `:Gedit` 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
@@ -35,15 +36,9 @@ and you never get any warnings about the file changing outside Vim.
making it like `git add` when called from a work tree file and like 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 GitHub, with optional line
hosting provider, with optional line range (try it in visual mode!). Built-in range (try it in visual mode!). If your current repository isn't on
support is provided for `git instaweb`, and plugins are available for popular GitHub, `git instaweb` will be spun up instead.
providers such as [GitHub][rhubarb.vim], [GitLab][fugitive-gitlab.vim], and
[Bitbucket][fubitive.vim].
[rhubarb.vim]: https://github.com/tpope/vim-rhubarb
[fugitive-gitlab.vim]: https://github.com/shumphrey/fugitive-gitlab.vim
[fubitive.vim]: https://github.com/tommcdo/vim-fubitive
Add `%{fugitive#statusline()}` 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.
@@ -51,7 +46,8 @@ 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,
and `Git!` to open the output of a command in a temp file. and `Git!` to open the output of a command in a temp file.
## Screencasts Screencasts
-----------
* [A complement to command line git](http://vimcasts.org/e/31) * [A complement to command line git](http://vimcasts.org/e/31)
* [Working with the git index](http://vimcasts.org/e/32) * [Working with the git index](http://vimcasts.org/e/32)
@@ -59,27 +55,44 @@ and `Git!` to open the output of a command in a temp file.
* [Browsing the git object database](http://vimcasts.org/e/34) * [Browsing the git object database](http://vimcasts.org/e/34)
* [Exploring the history of a git repository](http://vimcasts.org/e/35) * [Exploring the history of a git repository](http://vimcasts.org/e/35)
## Installation Installation
------------
If you don't have a preferred installation method, one option is to install If you don't have a preferred installation method, I recommend
[pathogen.vim](https://github.com/tpope/vim-pathogen), and then copy installing [pathogen.vim](https://github.com/tpope/vim-pathogen), and
and paste: then simply copy 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
Once help tags have been generated, you can view the manual with
`:help fugitive`.
If your Vim version is below 7.2, I recommend also installing If your Vim version is below 7.2, I recommend also installing
[vim-git](https://github.com/tpope/vim-git) for syntax highlighting and [vim-git](https://github.com/tpope/vim-git) for syntax highlighting and
other Git niceties. 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`.
@@ -96,7 +109,32 @@ to open after any grep invocation:
autocmd QuickFixCmdPost *grep* cwindow autocmd QuickFixCmdPost *grep* cwindow
## Self-Promotion Contributing
------------
Before reporting a bug, you should try stripping down your Vim
configuration and removing other plugins. The sad nature of VimScript
is that it is fraught with incompatibilities waiting to happen. I'm
happy to work around them where I can, but it's up to you to isolate
the conflict.
If your [commit message sucks](http://stopwritingramblingcommitmessages.com/),
I'm not going to accept your pull request. I've explained very politely
dozens of times that
[my general guidelines](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
are absolute rules on my own repositories, so I may lack the energy to
explain it to you yet another time. And please, if I ask you to change
something, `git commit --amend`.
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 perverse knowledge of VimScript so vast that many would consider
it a symptom of mental illness. On the flip side, some ideas I'll
reject no matter how good the implementation is. "Send a patch" is an
edge case answer in my book.
Self-Promotion
--------------
Like fugitive.vim? Follow the repository on Like fugitive.vim? Follow the repository on
[GitHub](https://github.com/tpope/vim-fugitive) and vote for it on [GitHub](https://github.com/tpope/vim-fugitive) and vote for it on
@@ -105,7 +143,8 @@ you're feeling especially charitable, follow [tpope](http://tpo.pe/) on
[Twitter](http://twitter.com/tpope) and [Twitter](http://twitter.com/tpope) and
[GitHub](https://github.com/tpope). [GitHub](https://github.com/tpope).
## License License
-------
Copyright (c) Tim Pope. Distributed under the same terms as Vim itself. Copyright (c) Tim Pope. Distributed under the same terms as Vim itself.
See `:help license`. See `:help license`.

View File

@@ -34,18 +34,15 @@ that are part of Git repositories).
window. The following maps, which work on the cursor window. The following maps, which work on the cursor
line file where sensible, are provided: line file where sensible, are provided:
g? show this help
<C-N> next file <C-N> next file
<C-P> previous file <C-P> previous file
<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|
@@ -57,67 +54,38 @@ that are part of Git repositories).
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|
U |:Git| checkout
U |:Git| checkout HEAD (staged files)
U |:Git| clean (untracked files)
U |:Git| rm (unmerged files)
*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
to commit, |:Gstatus| is called instead. Unless the to commit, |:Gstatus| is called instead. Unless the
arguments given would skip the invocation of an editor arguments given would skip the invocation of an editor
(e.g., -m), a split window will be used to obtain a (e.g., -m), a split window will be used to obtain a
commit message, or a new tab if -v is given. Write commit message. Write and close that window (:wq or
and close that window (:wq or |:Gwrite|) to finish the |:Gwrite|) to finish the commit. Unlike when running
commit. Unlike when running the actual git-commit the actual git-commit command, it is possible (but
command, it is possible (but unadvisable) to alter the unadvisable) to muck with the index with commands like
index with commands like git-add and git-reset while a git-add and git-reset while a commit message is
commit message is pending. pending.
*fugitive-:Gmerge*
:Gmerge [args] Calls git-merge and loads errors and conflicted files
into the |quickfix| list. Opens a |:Gcommit| style
split window for the commit message if the merge
succeeds. If called during a merge conflict, the
conflicted files from the current index are loaded
into the |quickfix| list.
*fugitive-:Gpull*
:Gpull [args] Like |:Gmerge|, but for git-pull.
*fugitive-:Gpush*
:Gpush [args] Invoke git-push, load the results into the |quickfix|
list, and invoke |:cwindow| to reveal any errors.
|:Dispatch| is used if available for asynchronous
invocation.
*fugitive-:Gfetch*
:Gfetch [args] Like |:Gpush|, but for git-fetch.
*fugitive-:Ggrep* *fugitive-:Ggrep*
:Ggrep[!] [args] |:grep|[!] with git-grep as 'grepprg'. :Ggrep [args] |:grep| with git-grep as 'grepprg'.
*fugitive-:Glgrep* *fugitive-:Glgrep*
:Glgrep[!] [args] |:lgrep|[!] with git-grep as 'grepprg'. :Glgrep [args] |:lgrep| with git-grep as 'grepprg'.
*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 of the current file into the |quickfix| list.
The cursor is positioned on the first line of the
first 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 [revision] |:edit| a |fugitive-revision|. :Gedit [revision] |:edit| a |fugitive-revision|.
@@ -154,7 +122,7 @@ that are part of Git repositories).
:{range}Gread! [args] |:read| the output of a Git command after {range}. :{range}Gread! [args] |:read| the output of a Git command after {range}.
*fugitive-:Gw* *fugitive-:Gwrite* *fugitive-:Gwrite*
:Gwrite Write to the current file's path and stage the results. :Gwrite Write to the current file's path and stage the results.
When run in a work tree file, it is effectively git When run in a work tree file, it is effectively git
add. Elsewhere, it is effectively git-checkout. A add. Elsewhere, it is effectively git-checkout. A
@@ -180,54 +148,41 @@ that are part of Git repositories).
index is used (which means a three-way diff during a index is used (which means a three-way diff during a
merge conflict, making it a git-mergetool merge conflict, making it a git-mergetool
alternative). The newer of the two files is placed alternative). The newer of the two files is placed
to the right or bottom, depending on 'diffopt' and to the right. Use |do| and |dp| and write to the
the width of the window relative to 'textwidth'. Use index file to simulate "git add --patch".
|do| and |dp| and write to the index file to simulate
"git add --patch". For the three-way diff, there is
also d2o and d3o pulling 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 [revision] Like |:Gdiff|, but split horizontally.
*fugitive-:Gvdiff* *fugitive-:Gvdiff*
:Gvdiff [revision] Like |:Gdiff|, but always split vertically. :Gvdiff [revision] Identical to |:Gdiff|. For symmetry with |:Gsdiff|.
*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. The destination is relative to the current
directory except when started with a /, in which case directory except when started with a /, in which case
it is relative to the work tree. (This is a holdover it is relative to the work tree. Add a ! to pass -f.
from before |:Grename| and will be removed.) 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. Press enter on a line to
ltfnsewMC as flags and they will be passed along to reblame the file as it was in that commit. You can
git-blame. The following maps, which work on the give any of ltfnsewMC as flags and they will be passed
cursor line commit where sensible, are provided: along to git-blame. The following maps, which work on
the cursor line commit where sensible, are provided:
g? show this help
A resize to end of author column A resize to end of author column
C resize to end of commit column C resize to end of commit column
D resize to end of date/time column D resize to end of date/time column
q close blame and return to blamed window q close blame and return to blamed window
gq q, then |:Gedit| to return to work tree version gq q, then |:Gedit| to return to work tree version
<CR> q, then open commit i 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
- reblame at commit - reblame at commit
@@ -237,38 +192,32 @@ that are part of Git repositories).
:[range]Gblame [flags] Run git-blame on the given range. :[range]Gblame [flags] Run git-blame on the given range.
*fugitive-:Gbrowse* *fugitive-:Gbrowse*
:Gbrowse Open the current file, blob, tree, commit, or tag :[range]Gbrowse If the remote for the current branch is on GitHub,
in your browser at the upstream hosting provider. open the current file, blob, tree, commit, or tag
If a range is given, it is appropriately appended to (with git-web--browse) on GitHub. Otherwise, open the
the URL as an anchor. current file, blob, tree, commit, or tag in
git-instaweb (if you have issues, verify you can run
"git instaweb" from a terminal). If a range is given,
it is appropriately appended to the URL as an anchor.
Upstream providers can be added by installing an To use with GitHub FI, point g:fugitive_github_domains
appropriate Vim plugin. For example, GitHub can be at a list of domains:
supported by installing rhubarb.vim, available at >
<https://github.com/tpope/vim-rhubarb>. let g:fugitive_github_domains = ['git.example.com']
~
:[range]Gbrowse! Like :Gbrowse, but put the URL on the clipboard rather
than opening it.
The hosting provider is determined by looking at the :[range]Gbrowse {revision}
remote for the current or specified branch and falls Like :Gbrowse, but for a given |fugitive-revision|. A
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 useful value here is -, which ties the URL to the
latest commit rather than a volatile branch. latest commit rather than a volatile branch.
:Gbrowse [...]@{remote} Force using the given remote rather than the remote :[range]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 GitHub repository to link to.
:{range}Gbrowse [args] Appends an anchor to the URL that emphasizes the
selected lines. You almost certainly want to give a
"-" argument in this case to force the URL to include
an exact revision.
:[range]Gbrowse! [args] Like :Gbrowse, but put the URL on the clipboard rather
than opening it.
MAPPINGS *fugitive-mappings* MAPPINGS *fugitive-mappings*
These maps are available everywhere. These maps are available everywhere.
@@ -309,10 +258,6 @@ 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.

File diff suppressed because it is too large Load Diff