285 Commits

Author SHA1 Message Date
Paulo Patto
258b49b4f6 Merge 949d085861 into b068eaf1e6 2025-02-03 12:42:17 -05:00
Tim Pope
b068eaf1e6 Drop */# maps in visual mode
Resolves: https://github.com/tpope/vim-fugitive/issues/2374
2025-02-02 23:33:54 -05:00
Paulo Patto
949d085861 Merge branch 'tpope:master' into doc-readme-for-lazy 2025-01-23 22:07:50 -03:00
Tim Pope
d74a7cff4c Add cW map as commit --fixup=reword:
References: https://github.com/tpope/vim-fugitive/pull/2369
2025-01-20 01:35:07 -05:00
Tim Pope
f4e8453ce7 Replace cA map with cn
Following Magit's lead.

References: https://github.com/tpope/vim-fugitive/pull/2369
2025-01-20 01:35:07 -05:00
Tim Pope
de42a732ee Fix help tag for g?
References: https://github.com/tpope/vim-fugitive/issues/2320
2025-01-20 01:21:42 -05:00
Tim Pope
174230d6a7 Make :GRename ./ and ../ respect parent dir of current file
References: https://github.com/tpope/vim-eunuch/issues/114
2024-12-29 02:29:26 -05:00
embedded
fcb4db52e7 Use netrw#Open if available (#2361) 2024-12-15 18:44:08 -05:00
Kevin Hwang
320b18fba2 Fix tab Gdiffsplit opening empty buffer 2024-11-19 12:16:44 -05:00
Tim Pope
d4877e54ce Use keepalt for diff maps
Resolves: https://github.com/tpope/vim-fugitive/issues/2336
2024-09-06 21:00:15 -04:00
Julio B
1d18c696c4 Disable modelines for status buffers
Regression introduced in 8c8cdf4405.
Resolves: https://github.com/tpope/vim-fugitive/issues/2333
2024-09-02 14:43:35 -04:00
Tim Pope
0444df68cd Use nvim vim.ui.open as a fallback
Resolves: https://github.com/tpope/vim-fugitive/pull/2322
2024-07-18 19:59:03 -04:00
Tim Pope
8c8cdf4405 Use callback based workflow for status buffer 2024-07-05 12:04:03 -04:00
David Briscoe
5661dea7be Format the full body instead of separating title
Fix #2315: Gedit strips newlines when commit lacks a blank line

%B is the "raw body (unwrapped subject and body)". Since we're
displaying both, we can use that to avoid any changes to the message
content. %B was added to git in 1.7.2 (2010) in commit
1367b12ad623e28546ba40c435015d94e7fbb248, and fugitive requires 1.8.5 so
it's safe to use.
2024-07-05 11:59:21 -04:00
Tim Pope
d0c1a43753 Clarify dq behavior
Resolves: https://github.com/tpope/vim-fugitive/issues/2196
2024-06-25 22:34:34 -04:00
Tim Pope
64d6cafb9d Rearrange :Git documentation
Resolves: https://github.com/tpope/vim-fugitive/issues/2314
2024-06-12 12:59:20 -04:00
Tim Pope
4f59455d23 Use rev-parse to get abbrev length for status buffer 2024-05-19 10:52:16 -04:00
Tim Pope
7493b78e6b Fix :Git difftool without -y
Resolves: https://github.com/tpope/vim-fugitive/issues/2307
2024-05-19 10:52:16 -04:00
Tim Pope
09ffa8fc08 Fix :Git difftool -y
Resolves: https://github.com/tpope/vim-fugitive/issues/2306
2024-05-19 00:37:06 -04:00
Tim Pope
5a9bd42dd8 Make push map available on P
I think matching the Magit interface is probably a better use of P than
wrapping --patch.  As a baby step in that direction, allow P to invoke
the same experimental behavior as "s" or "-".
2024-05-17 16:10:36 -04:00
Tim Pope
a0b0c1ddc1 Normalize path before quoting it 2024-05-17 14:01:06 -04:00
Tim Pope
10fb874d7e Filter out bold/underline typesetting in man output
Resolves: https://github.com/tpope/vim-fugitive/issues/2300
2024-05-17 13:16:03 -04:00
Tim Pope
110e7ca00c Ignore missing ssh include files 2024-05-15 12:46:29 -04:00
Tim Pope
19ca61c78c Support ~ in ssh config include
Resolves: https://github.com/tpope/vim-rhubarb/issues/79
2024-05-15 12:44:27 -04:00
lakshayg
5b0347b523 Fix syntax error in autoload/fugitive.vim
The error was introduced in ed9e21fb9b
2024-05-15 02:12:36 -04:00
Tim Pope
ed9e21fb9b Support :Git difftool --check
Resolves: https://github.com/tpope/vim-fugitive/issues/2303
2024-05-14 23:46:05 -04:00
Tim Pope
ce882460cf Support Git flags inside of aliases
Resolves: https://github.com/tpope/vim-fugitive/issues/2298
2024-05-01 18:17:05 -04:00
Yida Zhang
dac8e5c2d8 Fix TempReadPost returning 0 2024-04-08 01:40:26 -04:00
Paulo Patto
8eff3529b9 Update README with Lazy config
Add minimal config to install via Lazy.vim
2024-04-06 22:26:22 -03:00
Tim Pope
c0b03f1cac Restore winfixbuf consideration in status blur
The revert in a83135b55b was a bit too
aggressive.  We can support winfixbuf being set on the status buffer
without setting it ourselves.
2024-03-31 16:12:45 -04:00
Tim Pope
a83135b55b Revert "Set winfixbuf on status windows"
This reverts commit 8d4e8d4538.  Once the
dust has settled I'll reconsider.

References: https://github.com/tpope/vim-fugitive/issues/2272
References: https://github.com/tpope/vim-fugitive/discussions/2275
References: https://github.com/tpope/vim-fugitive/issues/2276
References: https://github.com/tpope/vim-fugitive/issues/2278
References: https://github.com/tpope/vim-fugitive/issues/2282
References: https://github.com/tpope/vim-fugitive/issues/2286
2024-03-28 16:43:46 -04:00
Tim Pope
2377e16e66 Fix misfire of User FugitivePager
Resolves: https://github.com/tpope/vim-fugitive/issues/2283
2024-03-26 14:15:09 -04:00
Yifan Hu
193ba9b393 Fix typo for advice.statusHints 2024-03-21 10:17:05 -07:00
Tim Pope
8d4e8d4538 Set winfixbuf on status windows
Resolves: https://github.com/tpope/vim-fugitive/issues/2272
2024-03-16 12:42:25 -04:00
Tim Pope
549e283d15 Set winfixbuf on blame windows
References: https://github.com/tpope/vim-fugitive/issues/2272
2024-03-16 12:37:29 -04:00
Tim Pope
fe4ba848ba Avoid reuse of winfixbuf windows
References: https://github.com/tpope/vim-fugitive/issues/2272
2024-03-16 12:35:36 -04:00
Tim Pope
41beedabc7 For push map, never push to fetch remote
There are legitimate reasons to push to the fetch remote, but making it
possible from the push map makes it too easy to do by default.
2024-03-03 19:57:59 -05:00
Tim Pope
ded6eb9da3 Use fewer buffer variables for status buffer 2024-03-02 14:35:07 -05:00
Tim Pope
eedb203ba7 Introduce stat.push and stat.merge 2024-03-02 14:19:32 -05:00
Tim Pope
840ce4a9d9 Move push_remote and fetch_remote into stat 2024-03-02 13:53:14 -05:00
Tim Pope
16ffd9623e Move pull_type into stat 2024-03-02 13:50:23 -05:00
Tim Pope
85eef8003e Don't assume default value for branch.*.merge
Commands like git-merge and git-pull seem not to make this assumption,
so neither should we.
2024-03-02 13:50:21 -05:00
Tim Pope
2e88f14a58 Avoid settabvar()
Still seeing ml_get errors on older Vim.  I give up.

Resolves: https://github.com/tpope/vim-fugitive/pull/2262
2024-02-24 14:01:27 -05:00
Tim Pope
69687f28d4 Move props into stat 2024-02-18 01:09:49 -05:00
Tim Pope
4bc9d98993 Replace status buffer contents atomically 2024-02-18 01:08:14 -05:00
Tim Pope
011cf4fcb9 Give status exec result variable a clearer name 2024-02-11 21:57:03 -05:00
Tim Pope
801b0417a5 Fix shortened :call command 2024-02-11 21:57:03 -05:00
Tim Pope
9f92ff14d9 Update tabpagenr('#') version constraint to fix ml_get error
References: https://github.com/tpope/vim-fugitive/pull/2262
2024-02-11 20:53:40 -05:00
Tim Pope
2a388ef5ba Allow for numeric tab argument in <mods>
Support was added in Vim 9.0.0786.
2024-02-11 20:06:40 -05:00
Tim Pope
ddedd5bd20 Add corresponding nvim check for tabpagenr('#') 2024-02-11 16:13:25 -05:00
Tim Pope
8376227c9d Avoid tabpagenr('#') on Vim versions without it
References: https://github.com/tpope/vim-fugitive/pull/2262
2024-02-11 12:32:23 -05:00
Tim Pope
e3cdf27e19 Remove error handler from status BufReadCmd
The only error that should be possible here now is the version check, so
do that explicitly instead.
2024-02-10 19:46:54 -05:00
Tim Pope
3d9cace1ff Reorder status BufReadCmd
Put all the stuff that actually updates the buffer together, so we can
soft reload without triggering autocommands or doing redundant work.

The reason for the previous ordering was to allow a bit of parallelism
while the diff commands ran in the background.  Let's try to preserve
that for map definitions by running them in parallel to the status
command instead.

I'm not sure why 'nomodifiable' was set after BufReadPost.  Let's try
the more natural ordering and see if anything breaks.
2024-02-10 16:28:13 -05:00
Tim Pope
41ef77c058 Defer initializing b:fugitive_files until rendering status 2024-02-10 16:28:13 -05:00
Tim Pope
fab00f7c0f Always use absolute path for :Ggrep quickfix list
Ran into an issue where a running Vim (Neovim 0.9.5) consistently
treated a relative path not as the file in the current directory, but as
a different open buffer that matched the file name.  The relative path
was just for cosmetics; let's switch to absolute so Vim doesn't butcher
it.
2024-02-08 14:08:06 -05:00
Luke Davis
e7bf502a6a Avoid resetting 'last accessed tab' status 2024-02-02 11:57:28 -05:00
Alex Klapheke
f116dcc8e2 Fix misaligned output of :G blame -s
Due to a regex not capturing (and concealing) all the spaces behind
the current file's line numbers, the close parentheses after the line
numbers are misaligned, and the blame buffer is made too wide.
2024-01-27 14:36:55 -05:00
Tim Pope
854a8df0d0 Support edit script when temp dir name contains space
Looks like GIT_EDITOR supports quotes now.

Resolves: https://github.com/tpope/vim-fugitive/issues/2255
2024-01-19 18:01:25 -05:00
Tim Pope
ec8f7eed10 Fix handling of Include in SSH config
The Include directive behaves very literally.  The old implementation
assumed a level of encapsulation that just doesn't match the actual
implementation.
2024-01-17 18:49:30 -05:00
Tim Pope
ac673f1e08 Relay stdin in s:StdoutFile() on Vim 7
Resolves: https://github.com/tpope/vim-fugitive/issues/2254
2024-01-17 18:48:07 -05:00
Tim Pope
c4a38c92dc Return first, not last, value for FugitiveConfigGet() 2024-01-17 18:33:54 -05:00
Tim Pope
2c999d4a69 Fix write to index on Vim 7
Resolves: https://github.com/tpope/vim-fugitive/issues/2254
2024-01-17 18:25:41 -05:00
Gregory Anders
5965909358 Buffer output when using the pager
As of 10ed587f65 all output is captured to
a temp file before being displayed. When the output is not buffered, the
stdout/stderr callback is called to perform post-processing for each
output chunk. Instead, buffer all output and perform the post-processing
all at once.

This results in a substantial performance improvement for repositories
with many commits.
2023-12-15 18:17:17 -05:00
Tim Pope
46eaf8918b Fix variable scope 2023-10-29 13:00:04 -04:00
Tim Pope
df36d194ce Prototype "reverse :GBrowse"
Use `:Gedit https://github.com/...` (or any other URL supported by an
installed :GBrowse provider) to edit the corresponding `fugitive://`
URL.  The dictionary g:fugitive_url_origins maps between homepage URLs
and local repositories:

	let g:fugitive_url_origins = {
	      'https://github.com/me/my-repo': '~/Projects/my-repo'}

It also checks the remotes of the repository that the currently edited
buffer belongs to.

This is an experimental prototype.  That means no documentation, and no
guarantees about behavior.  In particular, g:fugitive_url_origins and
the current contortions to leverage the existing :GBrowse API will
likely be dropped once a better API has been developed.

References: https://github.com/tpope/vim-fugitive/issues/2223
2023-10-09 20:53:12 -04:00
Tim Pope
cbe9dfa162 Salvage :Ggrep ... commit:path/
Resolves: https://github.com/tpope/vim-fugitive/issues/2224
2023-10-09 20:53:12 -04:00
Tim Pope
f6ec378d1d Decouple running git-status from parsing output 2023-09-27 20:50:43 -04:00
Tim Pope
99db68d9b3 Handle status diff file arguments more rigorously 2023-09-18 11:19:09 -04:00
Tim Pope
b9cf6ad994 Avoid implicit repository when rendering status buffer
Enable this code to run asynchronously by removing any assumptions about
the current buffer.
2023-09-18 11:19:09 -04:00
Tim Pope
7679842b90 Only diff known changed files for status
This should improve performance on large repositories.

References: https://github.com/tpope/vim-fugitive/issues/2207
2023-09-17 21:11:14 -04:00
Tim Pope
86a372d8c3 Respect GIT_INDEX_FILE when diffing for status buffer 2023-09-17 21:11:14 -04:00
Tim Pope
f2133ca50b Expire cached blank Git dir on active Fugitive invocation
Resolves: https://github.com/tpope/vim-fugitive/issues/2213
2023-09-17 21:11:14 -04:00
Tim Pope
7e72fb9cde Decouple s:DirCheck() from s:VersionCheck() 2023-09-17 19:21:30 -04:00
Tim Pope
2e6cf7287c Don't bother with sleep!
Neovim doesn't properly support this.  I guess the regular behavior is
*fine*.
2023-09-17 19:21:30 -04:00
Tim Pope
b4bb0c27f1 Close stdin for nvim jobs, to match vim 2023-09-17 19:21:30 -04:00
Tim Pope
6fcb0ad039 Fix p map in blame buffers
Resolves: https://github.com/tpope/vim-fugitive/issues/2211
2023-09-08 16:21:16 -04:00
Tim Pope
ba0b3163ca Avoid double reload of status window triggered by BufEnter
The second reload was short-circuited by a reltime() check, so no big
deal, but it does get in the way when trying to make the reload
conditional.

References: https://github.com/tpope/vim-fugitive/issues/2207
2023-09-07 16:44:12 -04:00
Tim Pope
c7333f63e7 Clean up optional arguments around status reload
Best I can tell the ability to pass a line number or tab number argument
has never been used.

Cleaning this up in anticipating of adding actually useful arguments,
and in anticipation of that, I'm preemptively making ReloadWinStatus()
blindly relay any arguments to ReloadStatusBuffer().

References: https://github.com/tpope/vim-fugitive/issues/2207
2023-09-07 16:44:12 -04:00
Tim Pope
d4914b361b Discourage use of P and ~ in blame window.
Since 09908d82ef, I've been getting a
parade of issues and PRs about "missing" documentation.

Resolves: https://github.com/tpope/vim-fugitive/pull/2210
References: https://github.com/tpope/vim-fugitive/issues/2070
2023-09-06 14:33:40 -04:00
Tim Pope
f71fb99360 Clarify behavior of :G summary window
Resolves: https://github.com/tpope/vim-fugitive/issues/2192
2023-09-03 15:27:15 -04:00
Tim Pope
572c851012 Never jump to invalid entry after quickfix command
In particular, if the first :Ggrep result is a binary file, skip over
it.  I'm also leaning strongly towards not filling in the filename field
at all for binary files, but I'll address that separately.
2023-08-27 15:39:21 -04:00
Tim Pope
b3b838d690 Show current revert/cherry-pick in status buffer
Resolves: https://github.com/tpope/vim-fugitive/issues/2175
2023-07-04 17:44:53 -04:00
Tim Pope
43f18ab915 Support netrw buffers with blank buffer names
Resolves: https://github.com/tpope/vim-fugitive/pull/2179
2023-06-12 19:27:31 -04:00
David Briscoe
5f0d280b51 Always fire BufReadStatus's autocmd
Fix #2161.

Always execute BufReadStatus's return value because that's the code that
fires the FugitiveIndex autocmd.
2023-04-28 23:23:46 -04:00
Tim Pope
e6651a79fa Allow ftplugin maps to override historical buffer maps
Resolves: https://github.com/tpope/vim-fugitive/issues/2151
2023-04-14 15:14:03 -04:00
Tim Pope
ef99f1d90c Support :GBrowse with paths outside current repo
Resolves: https://github.com/tpope/vim-fugitive/issues/2144
2023-03-30 11:01:58 -04:00
Tim Pope
9acbad1335 Try harder to match diff headers with ambiguous spacing
Resolves: https://github.com/tpope/vim-fugitive/issues/2135
2023-03-25 04:58:39 -04:00
Tim Pope
309c68117e Restore status commit lists for "." remote
Resolves: https://github.com/tpope/vim-fugitive/issues/2137
2023-03-23 07:43:56 -04:00
Tim Pope
66e8d19f89 Document czs
References: https://github.com/tpope/vim-fugitive/issues/1941
2023-03-22 02:52:30 -04:00
Tim Pope
8ad2b96cdf Guard against missing win_id2win on Vim 7.4
Resolves: https://github.com/tpope/vim-fugitive/issues/2136
2023-03-21 10:33:14 -04:00
Tim Pope
5b52a0f395 Provide default merge head for "." remote
Almost included this in f75dbb1967, but
dropped it because it always equal to the current branch, guaranteeing
an empty log, and because unlike the "origin" default, it shouldn't
really happen in practice.  However if a user screws up their config in
a way that forces it to happen, we should still try to avoid the same
"Push" header issue.
2023-03-09 14:20:42 -05:00
Karl Yngve Lervåg
d4941aec93 Use the dir variable in fugitive#Head 2023-03-09 11:55:42 -05:00
Tim Pope
82a9af133c Reject remotes without appropriate push/fetch key
Verifying by URL is insufficient, as git clone --bare will create a
remote with a URL but not a fetch key, resulting in no refs in
refs/remotes/.

Resolves: https://github.com/tpope/vim-fugitive/issues/2129
2023-03-07 19:11:04 -05:00
Tim Pope
13ed146694 Fix duplicate "Unpulled" section when push and pull match 2023-03-07 19:07:28 -05:00
Tim Pope
9b72d0c7c8 Don't default to origin remote in bare repos
Resolves: https://github.com/tpope/vim-fugitive/issues/2129
2023-03-07 14:57:08 -05:00
Tim Pope
f75dbb1967 Default pull ref to branch of same name
If we defaulted branch.x.remote to "origin", then we should also default
branch.x.merge to the obvious choice.  Otherwise we can end up in the
situation of a push ref without a pull ref, which leads to a rather
confusing "Push" header without a "Merge"/"Rebase" header.

References: https://github.com/tpope/vim-fugitive/issues/2129
2023-03-07 14:57:08 -05:00
yasuda
c9c08ff9ef Fix dropped quote of entries 2023-03-06 22:03:53 -05:00
Tim Pope
01964fa859 When push ref is missing, show unpushed upstream commits instead
This is a lie, but it matches what I (and probably most people) expect
to happen.
2023-03-06 20:34:16 -05:00
Tim Pope
d5758be511 Refactor retrieval of push/pull refs in status buffer, again
My last attempt at this gave up and combined retrieving the list of
commits and rendering the list of commits into a single function.  This
restores that distinction, albeit with a different approach, as I now
aim to use the same list of commits twice, in some circumstances.
2023-03-06 20:34:16 -05:00
Tim Pope
caf1bc99b6 Fall back to "Unpushed to *" when no upstream head is found
This allows local history to be shown before the initial push to a brand
new repository.

References: https://github.com/tpope/vim-fugitive/issues/2106
2023-03-05 20:02:07 -05:00
Tim Pope
b265dba99a Retool retrieval of push/pull refs in status buffer
This is mostly a refactor, but it fixes a bug where we could end up with
a push ref but not a pull ref when the underlying remote didn't exist,
resulting in a "Push:" header but not a "Pull:" header, which is
nonsensical.  This changes it to produce a "Pull:" header but not a
"Push:" header, which is arguably still incorrect, but at least makes
logical sense.
2023-03-05 20:02:07 -05:00
Tim Pope
891b0a92fe Don't show "Unpushed to *" if no remotes
If there are no remotes, then this section will always contain the
entire branch history, or a truncated version thereof.  I want all
sections to be meaningfully bounded.
2023-03-05 20:02:07 -05:00
Tim Pope
fa33145cc1 Make commit/rebase maps available in blame buffers
Resolves: https://github.com/tpope/vim-fugitive/issues/2035
2023-03-02 19:36:21 -05:00
Tim Pope
bba8d1beb3 Avoid narrow :Git subcommand splits in blame windows
If commit maps are to made available in blame buffers, then the existing
behavior of editing the commit message in a horizontal split of a narrow
window isn't going to cut it.  My ideal solution would be to create a
split that spans both the blame buffer and the original file, but I
don't think there's a practical way to do that, so I've instead settled
for using :topleft/:botright instead, as appropriate.  The other natural
solution would be to switch to the original file and split there, but
that means we'd end up with a scroll-bound window with a mismatched
height, which behaves exactly as poorly as you would expect.

Furthermore, I've made the decision to extend this behavior to paginated
output windows (e.g., `:Git log`), but *not* to other window creation
commands like :Gsplit.

References: https://github.com/tpope/vim-fugitive/issues/2035
2023-03-01 23:07:06 -05:00
Tim Pope
e5f9fda842 Tighten matches for URL buffer names 2023-03-01 16:42:10 -05:00
Tim Pope
b54ee90d56 Avoid blurring status when :Gedit argument parsing throws an error 2023-03-01 16:42:10 -05:00
Tim Pope
d507d00bd0 Drop g:fugitive_defer_to_existing_maps
This doesn't actually work correctly as in a few places we deliberately
override a map.  I'll accept a PR to bring it back, but it will need to
fix said issues.  Until then, unmapping undesired maps is the
recommended solution.
2023-02-27 21:52:52 -05:00
Tim Pope
ad2dcd628a Undo inadvertent revert
This reverts commit dd538bb046.
2023-02-27 21:08:30 -05:00
Tim Pope
dd538bb046 Fix typo 2023-02-27 20:49:41 -05:00
Tim Pope
853ec6f58d Focus correct window after gq in :Git blame
Resolves: https://github.com/tpope/vim-fugitive/issues/770
2023-02-27 20:47:22 -05:00
Ben Morgan
62f42f013d Fix Gdelete error message 2023-02-09 16:44:40 -05:00
Tim Pope
2019e0e413 Support folding sections
Resolves: https://github.com/tpope/vim-fugitive/issues/2111
References: https://github.com/tpope/vim-fugitive/issues/1317
2023-02-05 18:40:33 -05:00
Tim Pope
2febbe1f00 Make statusline redraw less aggressive
Mainly trying to avoid tainting `:verbose set readonly?`.
2023-01-16 22:04:38 -05:00
Tim Pope
9b50074e44 Better error message when :GBrowse remote not found
Resolves: https://github.com/tpope/vim-fugitive/issues/2103
2023-01-16 22:04:38 -05:00
Tim Pope
9c5f675db5 Allow PTY for paginated shortlog, to prevent stdin read
This workaround only works where PTY jobs are supported.  The real fix
is to give an explicit argument: `:Git shortlog HEAD`.

Resolves: https://github.com/tpope/vim-fugitive/issues/2100
2023-01-11 20:22:15 -05:00
Tim Pope
99cdb88bc6 Improve horizontal scrolling performance of :Git blame
References: https://github.com/tpope/vim-sensible/pull/124
2022-12-30 00:44:37 -05:00
Maksim Odnoletkov
5b0b138483 Fix parsing of diff hunk headers with omitted length
7dd76231e6 made the comma and the second
number required in a line range. But they can be omitted, for example:

* Adding a single line file:

    @@ -0,0 +1 @@

* Modifying a single line file:

    @@ -1 +1 @@
2022-12-02 06:51:11 -05:00
Eric Milford
49cc58573e Tighten match for commit under cursor
Using `coo` to open a branch under the cursor that started with 4+ hex
digits (e.g., 1111-feat) would fail with the error `fatal: invalid
reference: 1111.`

This happened because the prior regex would consider these branch names
as commits when determining whether to treat what was under the cursor
as a branch or commit.

This changes the regex to use a negative look-ahead to further tighten
the match for a commit and require that a match on 4+ hex digits also
not end with a non-hex digit.

Resolves #2085.
2022-11-23 13:57:13 -05:00
Zhizhen He
23b9b9b2a3 Fix typo 2022-11-16 07:28:20 -05:00
Ernst Widerberg
362201bce5 Fix typo 2022-11-15 04:53:25 -05:00
Tim Pope
01f3e0af92 Account for escaping differences when expanding on win32
The core issue here is that on UNIX, fnameescape() always doubles
backslashes, while on Windows, it leaves them be.  But it's a lot more
complicated than that, because Vim also avoids escaping other
characters, to minimize ambiguity.  This can mostly be compensated for
by removing the corresponding characters from s:fnameescape, including
backslash itself.  I'm a little worried that removing backslash will
have other implications, so keep an eye out for regressions here.

One character we can't remove is "!", because we need a way to escape
our own "the commit owning the current file" syntax.  As a long term
strategy to address this, I'm introducing new !% and !# variations to
replace it.  This is a bit on the ugly side, so I'm going to hold off on
committing to it as a documented interface until I've had more time to
muse on alternatives.

See also 6356bbc4a7, wherein I fixed a bug
with the exact same description.  This suggests a change in Vim prompted
this new variation, but then again, there's no proof that I actually
tested my fix on Windows.

Resolves: https://github.com/tpope/vim-fugitive/issues/2071
2022-11-01 00:04:08 -04:00
Tim Pope
09908d82ef Remove ~ and P maps from blame documentation
These maps are not nearly as useful as they seem.  Let's avoid tempting
newcomers to use them.  I recommend to instead use <CR>, which shows the
change in context.

References: https://github.com/tpope/vim-fugitive/issues/2070
2022-10-31 15:28:49 -04:00
Tim Pope
dd8107cabf Avoid invalid glob during tab complete
Resolves: https://github.com/tpope/vim-fugitive/issues/2050
2022-09-04 05:38:13 -04:00
Tim Pope
b411b753f8 Add deprecation warning on editing .git/index 2022-08-17 10:20:51 -04:00
Tim Pope
9fcac5b380 Fix broken blame maps
This was accidentally mapping `0` or `1` instead.

Switch to :exe while we're at it.

Resolves: https://github.com/tpope/vim-fugitive/issues/2031
2022-08-17 10:20:35 -04:00
Tim Pope
3485e22a0a Restore popular fugitive#repo() functions
I'm quite eager to kill the "chomp" functions, as they're the last use
of system().  However, the successor, FugitiveExecute(),  is only a year
old, and isn't a drop-in replacement.  So let's bring them back for
awhile to avoid the need for a massive conditional to give backwards
compatibility.

The rest are pretty benign to support, so I guess they can stick around
until the band-aid is officially ripped off.
2022-08-02 13:48:01 -04:00
Tim Pope
66a921bbe3 Consistently handle missing command jobs across platforms
* On UNIX, jobs proceed normally, and exit with status 122.
* On Windows, jobs fail early, and no callbacks run.
* On Neovim, an exception is thrown.

Normalize the second and third cases to behave like the first, as that
was my assumed behavior during the initial implementation.

References: https://github.com/tpope/vim-fugitive/issues/1815
2022-07-28 08:52:00 -04:00
Tim Pope
23570688d2 Drop g:fugitive_legacy_quoting 2022-07-28 08:52:00 -04:00
Tim Pope
6955915af5 Account for ch_status() == 'fail'
References: https://github.com/tpope/vim-fugitive/issues/1815
2022-07-27 07:18:42 -04:00
Tim Pope
9a13fc87c4 Move status buffer to fugitive:// URL
Having already implemented this for better symlink support, we may as
well leverage it to phase out the "index" path leaky abstraction.
2022-07-22 01:45:41 -04:00
yut23
23b321b740 Fix backward navigation from the middle of a line
Ensure backward searches don't match the current line. This shows up
more in neovim, which sets 'nostartofline' by default.
2022-07-21 22:45:56 -04:00
yut23
4e11f9dabf Fix [c from the first hunk of a file
This makes the rest of the function operate on the previous file rather
than the file of the hunk under the cursor.
2022-07-21 22:45:56 -04:00
Tim Pope
d84582d5f7 Drop URL encoding workaround from :GBrowse API
No longer necessary as all known providers handle URL encoding
correctly.

References: https://github.com/cedarbaum/fugitive-azure-devops.vim/issues/3
2022-07-18 16:19:49 -04:00
Tim Pope
ff04324bff Don't use "~" for in-band signaling in :GBrowse API
I figured "~" was unlikely to have legitimate uses, but it turns out
sourcehut uses it to prefix usernames in all of its URLs.  Let's go with
a control character instead.

Resolves: https://github.com/tpope/vim-fugitive/issues/2021
2022-07-08 02:44:51 -04:00
Tim Pope
32b61c1665 URL encode "=" 2022-07-08 00:58:02 -04:00
Tim Pope
b8c5128f89 Fix automatic status reload when at fugitive:// URL 2022-07-08 00:47:00 -04:00
Tim Pope
f809dde0e7 Use URL encoding for Fugitive URLs
This makes them conform to whatever the RFC for URLs is.
2022-06-29 21:06:46 -04:00
Tim Pope
8fd6bad4a4 Handle URL-unsafe characters in :GBrowse API
Of the 8 :GBrowse providers listed in the README, 7 make no attempt to
handle URL encoding.  So it makes sense for Fugitive to take
responsibility for this.  By transposing "%" and "~" in API parameters
and then reversing the process on the generated URL, we can accommodate
both usages.  This is transitional and will later be ditched in favor of
straightforward URL encoding.

References: https://github.com/cedarbaum/fugitive-azure-devops.vim/issues/3
2022-06-29 15:50:16 -04:00
Tim Pope
224b65ef58 URL decode FugitiveRemote().path and .user
This is technically backwards incompatible, but I've never seen a remote
with URL encoding in practice.  (Also I don't think anyone is actually
using this function.)  One can use .pathname if they need the encoded
version.
2022-06-29 14:20:57 -04:00
Tim Pope
f0acd25d45 Accept multiple arguments to :Gdrop, like :drop 2022-06-29 14:20:56 -04:00
Tim Pope
69ead802d7 Don't default :Gedit to cwd in empty window 2022-06-28 15:39:18 -04:00
Tim Pope
09dfed092a Use forward slashes for non-Fugitive URLs on win32
Might do this for everything but let's start here.  I initially went
with backslashes for URLs because that's how Vim on win32 normalizes
buffer names, and figured it might simplify things like equality checks.
But Vim itself breaks in some places.  Editing a `file://` URL doesn't
work if backslashes are in use, and Vim unescapes incorrectly when
constructing <q-args> (see 6356bbc4a7).
2022-06-27 01:05:06 -04:00
Tim Pope
ecc5e8fa40 Tease apart :Gedit argument parsing and expansion 2022-06-26 21:38:01 -04:00
Tim Pope
c545a7d451 Correctly handle :Gedit + +SecondCommand 2022-06-26 21:38:01 -04:00
Tim Pope
47cbfc00cc Reject invalid URLs from GBrowse providers 2022-06-26 17:28:20 -04:00
Tim Pope
e80c460e48 Fix misc errors on Vim 7.4 2022-06-26 17:28:20 -04:00
Tim Pope
36b80c190c Remove inadvertent dict function flag 2022-06-26 16:59:59 -04:00
Tim Pope
87b3891c77 Encapsulate appending relative path to Fugitive URL
This gives us a central place to add URL encoding
2022-06-26 16:47:32 -04:00
Tim Pope
e7a33baccc Sync up win32 and UNIX fugitive:// regexps
Remove support for an optional second slash delimiter that was
accidentally committed in the previous win32 change.
2022-06-26 15:53:23 -04:00
Tim Pope
0bd3885169 Fix match of fugitive:////unchost/path// on win32 2022-06-26 15:41:23 -04:00
Tim Pope
9af6de1668 Use fugitive:///c:/ instead of fugitive://c:/ on win32
This avoids a bogus use of the host field in a standard URL and matches
how file:// URLs work.
2022-06-26 15:24:12 -04:00
Jaehwang Jung
00cc23868a Don't silence cmap 2022-06-25 14:55:04 -04:00
Tim Pope
33a7cdf213 Fix FugitiveExtractGitDir() with dict argument
Resolves: https://github.com/tpope/vim-fugitive/issues/2018
2022-06-24 17:00:33 -04:00
Tim Pope
80cd9c876e Move FugitiveParse() implementation into autoload file
Anticipating changes here, so let's try to avoid the dreaded "old plugin
file loads new autoload file" edge case burning us.
2022-06-23 18:09:40 -04:00
Tim Pope
8165eada59 Fix Projectionist root for .git/info/projections.json 2022-06-23 17:55:27 -04:00
Tim Pope
eac5ffd35b Don't reuse status window for :Gdrop 2022-06-23 14:41:20 -04:00
Tim Pope
aafbdf84cd Look for "fugitive_dir" as dictionary key
Work trees and submodules have two things that could be called the Git
dir: the directory itself, and the ".git" at the root of the work tree.
Introduce "fugitive_dir" as our name for the one we consider canonical.
2022-06-22 12:30:47 -04:00
Tim Pope
8b39d29d94 Rework ref handing in :GBrowse
This is still a garbage fire, but at least now the use of `.git/refs/`
paths has been relegated to the public interface.  This also fixes a lot
of quirks, and hopefully doesn't introduce too many new ones.
2022-06-19 09:42:26 -04:00
Tim Pope
3fd2c21ee0 DWIM for :GBrowse remote-name
Previously I had worried about the ambiguity this would produce, but
that can be resolved by calling `:GBrowse remote-name/HEAD`.
2022-06-18 23:05:27 -04:00
Tim Pope
a95f1c11ad Remove redundant URL escaping in :GBrowse
See b42f95c0c2.
2022-06-18 23:05:27 -04:00
Tim Pope
a337eb5114 Compute correct line numbers in blame buffer 2022-06-18 10:28:37 -04:00
Tim Pope
9ea1f43a6a Delete temp files created computing :GBrowse line numbers 2022-06-18 00:33:00 -04:00
Tim Pope
763f42cab5 Simplify conditional around :GBrowse line number computation
This is solely to improve the readability of upcoming diffs.
2022-06-18 00:33:00 -04:00
Tim Pope
bef885fd00 Fix :GBrowse in :Git blame window 2022-06-18 00:33:00 -04:00
Tim Pope
1aefa1aed2 Cope gracefully with missing .git/index 2022-06-17 13:17:43 -04:00
Tim Pope
abe29d4891 Restore .git_dir on fugitive#repo()
This will enable functions like FugitiveFind() to use fugitive#repo() as
the optional second parameter, which should make transitioning to the
new API a bit easier to do incrementally.
2022-06-17 13:17:43 -04:00
Tim Pope
9fadd7a778 Provide :Gdrop 2022-06-16 09:41:34 -04:00
Tim Pope
acee967384 Remove :Gcommit family of error stubs 2022-06-16 09:41:34 -04:00
Tim Pope
7dd76231e6 Extract helper to determine position in diff hunk
References: https://github.com/tpope/vim-fugitive/issues/1171
2022-06-16 09:29:01 -04:00
Tim Pope
6ae79e75a4 Handle quoted filenames in diff --git headers 2022-06-15 08:19:23 -04:00
Tim Pope
3f5975e906 Include "\ No newline at end of file" in status buffer 2022-06-14 14:15:47 -04:00
Tim Pope
d9059413e2 Fix inconsistent whitespace matching in regexps
The \s and \S atoms consider space and tabs to be the only valid
whitespace characters, while the [:space:] character class also includes
control characters like newline and form feed.
2022-06-14 13:20:17 -04:00
Tim Pope
0996bae836 Partially support ".git" files and symlinks without core.worktree
This is not and can never be 100% perfect.  There's no way to work back
from a file like info/exclude COMMIT_EDITMSG to the work tree.  So
core.worktree continues to be recommended.

References: https://github.com/tpope/vim-fugitive/issues/1920
2022-06-13 12:15:48 -04:00
Tim Pope
d72fbcb0a4 Loosen autocommand patterns for fugitive:// URLs
Allow for potential upcoming changes to the format.
2022-06-13 10:09:36 -04:00
Tim Pope
d002715084 Optimize inline expansion for large diffs
Resolves: https://github.com/tpope/vim-fugitive/issues/2011
2022-06-13 10:09:36 -04:00
Tim Pope
0680c3ae3c Remove last vestiges of :Gread! 2022-06-13 07:13:34 -04:00
Tim Pope
8c63ac0f2f Fix error message on fugitive#repo().config() 2022-06-13 07:13:34 -04:00
Tim Pope
b42f95c0c2 DWIM for % and # in URL argument 2022-06-13 07:13:34 -04:00
Tim Pope
020802475c Add error stubs for old fugitive#repo() object
This is still used in the wild, so provide error messages to aid in
transitioning.
2022-06-12 12:47:36 -04:00
Tim Pope
535389b9a6 Improve performance of FugitiveStatusline()
Avoiding fugitive#Find() saves a millisecond or 2.  Not a big deal but
still worth avoiding given how often this function is called.
2022-06-11 09:32:50 -04:00
Tim Pope
d1d485cdef Leverage FugitiveActualDir() abstraction 2022-06-11 09:32:50 -04:00
Tim Pope
8378b329b8 Drop obsolete public functions 2022-06-07 05:40:49 -04:00
Tim Pope
92c73bb050 Set b:git_dir in FugitiveEditor buffers
This should make us a bit more robust in the face of things like
symlinks.
2022-06-07 05:40:49 -04:00
Tim Pope
1d6e601298 Extract helper to initialize b:git_dir 2022-06-07 05:40:49 -04:00
Tim Pope
118e9de937 Define global <Plug> maps regardless of g:fugitive_no_maps 2022-06-07 04:03:42 -04:00
Tim Pope
4aeca0c566 Drop support for Vim older than 7.4 2022-06-07 03:14:49 -04:00
Tim Pope
55256c7de2 Fix syntax error
Resolves: https://github.com/tpope/vim-fugitive/issues/2008
Resolves: https://github.com/tpope/vim-fugitive/issues/2009
2022-06-07 02:10:42 -04:00
Tim Pope
2386b9b39f Drop support for autocmd User Fugitive 2022-06-07 01:09:56 -04:00
Tim Pope
96c1009fcf fugitive.vim 3.7
Move "Unpushed" sections above "Unpulled".
Show commits that are unpushed anywhere when no upstream is set.
Provide czs map as :Git stash push --staged.
Support the MSYS Vim bundled with Git for Windows.
Turn remaining deprecated commands (:Gbrowse, etc.) into error stubs.
2022-06-07 01:03:24 -04:00
Tim Pope
5920f807f5 Expire b:git_dir on buffer rename 2022-06-03 20:33:48 -04:00
Tim Pope
f60fc79e53 Avoid unnamed buffer with :set hidden
Resolves: https://github.com/tpope/vim-fugitive/issues/2004
2022-06-01 12:54:13 -04:00
Tim Pope
fb07620878 Retool $GIT_INDEX_FILE handling
* Don't attempt to handle relative paths, as there's no guarantee the
  current working directory is the one Vim was started with.  In
  practice, the only relative path I've seen is `.git/index`, which is
  already the default and thus harmless to ignore.
* Cache the result of FugitiveVimPath(), to allow for slow
  implementations.
2022-05-31 16:11:22 -04:00
Tim Pope
8fba012775 Fix fugitive#simplify() with summary URL 2022-05-31 16:11:22 -04:00
Tim Pope
596621dc6e Support Git for Windows bundled MSYS Vim
References: https://github.com/tpope/vim-fugitive/issues/1970
2022-05-30 16:48:48 -04:00
Tim Pope
5bf3fd40f6 Provide FugitiveActualDir()
This is intended to free up FugitiveGitDir() to refer to the ".git" file
in that work tree and submodule repositories use.  I wish I had better
names for these two.  Settling for "Actual" as that at least has a
pleasing 6 letter symmetry with "Common".
2022-05-30 14:03:43 -04:00
Tim Pope
950f9c49fc Introduce helper to normalize to backslashes on win32
FugitiveVimPath() is intended to potentially convert between UNIX and
Windows paths in mixed environments.  Let's separate uses that require
that from those that simply normalize slashes.
2022-05-30 14:03:43 -04:00
Tim Pope
92870eb6d2 Remove dead code for resolving symlinked buffer name
The `:p` flag resolves symlinks, so the resolve() call is a no-op, and
the subsequent conditional is always false.  It also appears to be no
longer necessary, though I'd have to do a bit more digging to figure out
why.
2022-05-28 21:57:21 -04:00
Tim Pope
5ec0793b88 Accept both fugitive://C:/ and fugitive:///C:/ on win32
The 2 slash version slots the drive letter into the host field, which
I'm worried will cause problems when the URLs are used non-opaquely, for
example, with an LSP.  Let's start transitioning to the convention used
by file:// URLs.
2022-05-28 21:00:24 -04:00
Tim Pope
a504abb8b8 Avoid reusing variable 2022-05-28 21:00:24 -04:00
Tim Pope
ad16275775 Fix statusline indicator on older Vim
Vim was clearing the statusline due to an error, despite the fact the
exception was caught and ignored.
2022-05-27 22:56:20 -04:00
Tim Pope
41939b09cb Move s:SameRepo() next to other Git dir functions 2022-05-27 21:01:42 -04:00
Tim Pope
097ce939da Make summary buffer available at fugitive:// URL
Using $GIT_DIR/index for the summary buffer has 2 problems:

* It requires a BufReadCmd for all files named "index", necessitating
  special handling for false positives.
* It forces us to resolve ".git" files and symlinks, decoupling us from
  the worktree and thus forcing us to depend on `core.worktree`.  Git
  always sets this when necessary, but users and third-party tooling
  sometimes do not.

Using a fugitive:// URL for the buffer solves both.

This is a large, breaking change, so let's leave $GIT_DIR/index as the
default for now.
2022-05-27 19:50:53 -04:00
Tim Pope
9a4f1e9df2 Extract helper for checking for same repository 2022-05-27 18:20:45 -04:00
Tim Pope
0e9f763c7b Allow :GBrowse : to browse to repository homepage 2022-05-22 22:26:45 -04:00
Tim Pope
fb32927ff5 Use correct normalization of URL in fugitive#Path() 2022-05-22 22:26:45 -04:00
Tim Pope
22a843f8e6 Add missing ! to function definition 2022-05-22 22:26:45 -04:00
Tim Pope
9f30e4d904 Experimentally allow passing Git dir to fugitive#Command()
References: https://github.com/tpope/vim-fugitive/issues/1981
2022-05-22 17:33:53 -04:00
Tim Pope
cdacef342d Distinguish between uses of Git dir, part 2
See 5d1a276b45.
2022-05-21 21:35:50 -04:00
Tim Pope
f48cbb92c5 Read more of config file for core.worktree check
References: https://github.com/tpope/vim-fugitive/issues/1920
2022-05-21 21:35:50 -04:00
Tim Pope
589e8b51c2 Track correct window when blaming twice-open buffer
Resolves: https://github.com/tpope/vim-fugitive/issues/1992
2022-05-21 21:35:49 -04:00
Tim Pope
5b62c75238 Extract Git dir cache keys to local variables
Allow for a non-string representation of the repository to replace the
dir parameter.
2022-05-14 02:35:39 -04:00
Tim Pope
a8139d37b2 Properly normalize Git dir in 'keywordprg' 2022-05-13 01:56:20 -04:00
Tim Pope
f529acef74 Force Vim path normalization in fugitive#Path()
This only matters for use cases where the paths differ by more than just
slashes (theoretically possible with mixed WSL setups).
2022-05-11 02:12:21 -04:00
Tim Pope
87923d1b1b Fix HEAD cache expiry on FugitiveDidChange() 2022-05-11 00:23:14 -04:00
Tim Pope
af8b352dbf Remove redundant "dir" keys from dictionaries 2022-05-11 00:23:14 -04:00
Tim Pope
b81c59bd6a Remove fugitive#head() 2022-05-10 22:47:05 -04:00
Tim Pope
b7287bd542 Provide explicit explanation of command naming 2022-04-26 16:21:33 -04:00
Tim Pope
b5bbd0d181 Clarify ~ and P maps in blame window
Resolves: https://github.com/tpope/vim-fugitive/issues/1980
2022-04-21 15:05:35 -04:00
Tim Pope
b04708af2d Revert "Avoid IO from ":p" during detection"
This change failed to account for the directory edge case, where ":p:h"
has the very nice property of giving us back the original input, due to
":p" appending a trailing slash.  Without this, we fail to detect when
editing the root of the repository.

This reverts commit 1b811b88a4.

Resolves: https://github.com/tpope/vim-fugitive/issues/1978
Resolves: https://github.com/tpope/vim-fugitive/issues/1979
2022-04-20 23:25:14 -04:00
Tim Pope
1b811b88a4 Avoid IO from ":p" during detection 2022-04-20 18:29:45 -04:00
Tim Pope
ed1ff363df Remove another acwrite check 2022-04-20 18:29:45 -04:00
Tim Pope
e064f42770 Don't consider buftype=acwrite buffers to have real filenames
Immediately after I changed this I rediscovered the documentation at
`:help E676`.
2022-04-20 18:28:44 -04:00
Maksim Odnoletkov
70251a915f Show local commits when no upstream is set
References: https://github.com/tpope/vim-fugitive/issues/1963
Resolves: https://github.com/tpope/vim-fugitive/issues/1977
2022-04-20 14:47:15 -04:00
Tim Pope
200593827e Adjust handling of 'buftype' during detection 2022-04-19 18:35:15 -04:00
Tim Pope
4b0f2b6045 Default g:ceiling_directories to parent of $HOME
References: https://github.com/tpope/vim-fugitive/issues/1457
2022-04-14 02:31:49 -04:00
Tim Pope
a252be79c0 Check for ch_close_in() to ensure full Vim jobs support
Resolves: https://github.com/tpope/vim-fugitive/issues/1973
2022-04-12 19:51:42 -04:00
Tim Pope
cba863444c Move unpushed sections above unpulled, again
This reverts commit 279d56eb47
(effectively).

References: https://github.com/tpope/vim-fugitive/issues/1963
2022-04-05 12:13:40 -04:00
Tim Pope
d725ef529e Turn remaining deprecated commands into error stubs 2022-04-01 18:27:49 -04:00
Tim Pope
8f169a84ff Allow simultaneous blames in diffed buffers
References: https://github.com/tpope/vim-fugitive/pull/1327
2022-04-01 18:27:49 -04:00
Tim Pope
d9a914b14d Replace 'cursorbind' in blame with manual line syncing
This is the only way to sync the line without also syncing the column.
Syncing the column is particularly problematic when it causes the blame
window to vertically scroll while typing.
2022-04-01 18:27:44 -04:00
Tim Pope
c0701f7a0e Fix expansion of SSH host aliases
Resolves: https://github.com/tpope/vim-fugitive/issues/1962
2022-03-30 11:08:14 -04:00
Tim Pope
321328c6c5 Avoid I/O from ":p" when handling temp files
This isn't a big deal for temp files themselves, but if we're checking
an arbitrary buffer, it's possible we'll end up hitting a slow network
share just to find out if the path is relative.

This new s:AbsoluteVimPath() helper could potentially be reused in a lot
of places.  But this diff is big enough as is; save that for later.
2022-03-26 15:41:55 -04:00
Tim Pope
8157efff49 Provide g:fugitive_defer_to_existing_maps
References: https://github.com/tpope/vim-fugitive/issues/1425
2022-03-25 18:08:01 -04:00
Tim Pope
b6405d8908 Provide literally named <Plug> maps
For every map X, also provide a map <Plug>fugitive:X.

References: https://github.com/tpope/vim-fugitive/issues/1425
2022-03-25 17:50:32 -04:00
Tim Pope
5716e11776 Fix line wrap in README 2022-03-24 08:02:43 -04:00
Tim Pope
46652a304f Add :GUnlink, like in eunuch.vim
This currently mirrors :GRemove, but gives us the option to add a third
variant.
2022-03-09 10:50:24 -05:00
Tim Pope
afd6c13c6b Fix infinite loop when summary window contains no sections
Resolves: https://github.com/tpope/vim-fugitive/issues/1954
2022-03-01 07:35:31 -05:00
Tim Pope
485ce07c27 Match FugitiveRemote() interface to window.location in JS 2022-02-11 13:02:45 -05:00
Tim Pope
c29ef11cd6 Parse anchor in remote URL
I've never seen this in practice, but if it does happen, we shouldn't
include it in the value for "path".
2022-02-11 13:02:45 -05:00
Tim Pope
6c19f1ddfb More robut escaping of +cmd arguments
Resolves: https://github.com/tpope/vim-fugitive/issues/1938
2022-02-02 11:53:01 -05:00
Tim Pope
a443104489 Add czs as :Git stash push --staged
Resolves: https://github.com/tpope/vim-fugitive/issues/1941
2022-02-02 05:49:09 -05:00
Roger Bongers
59529a2c36 Add basic bisect subcommand completion 2022-01-24 21:13:07 -05:00
Tim Pope
a93ceff61f Support extensions.worktreeConfig
Resolves: https://github.com/tpope/vim-fugitive/issues/1898
2022-01-13 14:06:42 -05:00
Tim Pope
f4d94c5985 Move CommonDir() from autoload to plugin 2022-01-11 18:47:38 -05:00
Tim Pope
bb4f9e660b Add core.worktree to FAQ 2022-01-11 18:39:40 -05:00
Tim Pope
189e3c406e Eliminate filereadable() guards by catching readfile() error 2022-01-11 18:36:36 -05:00
Tim Pope
944dc602c6 Require core.bare=true for bare repositories
Resolves: https://github.com/tpope/vim-fugitive/issues/1920
2022-01-11 13:50:55 -05:00
Tim Pope
fa20e5e77c Remove :silent from all :checktime uses
This can appear to hang with 'noautoread', or if the buffer has changed
in memory.  In reality it's not hanging, it's just silenced the
interactive prompt.

Resolves: https://github.com/tpope/vim-fugitive/issues/1917
2022-01-10 11:08:29 -05:00
Tim Pope
57968b63c2 Support tab complete of :Git push remote \+branch
Resolves: https://github.com/tpope/vim-fugitive/issues/1916
2022-01-05 11:10:57 -05:00
Tim Pope
88a97127d1 Account for optional escaping in tab complete
Tab complete results are always passed to fnameescape(), which can
result in the output having more backslashes than the input, causing
those results to be filtered out.  Attempt to reconcile this.

References: https://github.com/tpope/vim-fugitive/issues/1916
2022-01-05 11:08:38 -05:00
Tim Pope
b6dbb97759 Extend lazy detection to netrw
The requires dropping support for b:netrw_curdir, which was added in
fecd42864a for the vague reason of
handling "unusually named netrw buffers".  I'll figure out what to do
about those alleged buffers when one of them surfaces again.
2022-01-05 11:07:15 -05:00
Tim Pope
b1c3cdffc9 Fix status reload after staging entire section
Resolves: https://github.com/tpope/vim-fugitive/issues/1912
2021-12-29 16:50:00 -05:00
Tim Pope
ee992c808c Narrow application of broken jobwait() workaround
Neovim seemlingly forces a redraw if :sleep is called while defocused,
but only if at least one FocusGained/FocusLost autocommand is defined.
The purpose of this :sleep is to force the exit callback to run when
jobwait() erroneously refuses to do the job.  Our exit callback removes
the job from the dictionary, so we can use the lack of a job key in any
dictionary as a signal that we can skip it.  Hacks on top of hacks.

Resolves: https://github.com/tpope/vim-fugitive/issues/1909
References: https://github.com/tpope/vim-fugitive/issues/1857
2021-12-28 16:03:34 -05:00
Tim Pope
831fdab983 Simplify extraction of directory of buffer name
The behavior of :p is more predictable than I realized when I first
wrote this.
2021-12-28 16:03:34 -05:00
Tim Pope
da30818d17 Resize EDITOR window automatically when necessary
Resolves: https://github.com/tpope/vim-fugitive/issues/1907
2021-12-24 12:53:00 -05:00
Tim Pope
ab57abf1d0 Don't feedkeys() into terminal window
Resolves: https://github.com/tpope/vim-fugitive/issues/1908
2021-12-23 21:47:29 -05:00
Tim Pope
f18571e647 Remove redundant ":p" modification during detection
Every ":p" does I/O to check for a directory, so let's do away with the
belt-and-suspenders usage.
2021-12-23 15:00:14 -05:00
Tim Pope
3fb9beacbc Fix possible infinite loop 2021-12-12 13:28:20 -05:00
Tim Pope
365231384c Don't treat buftype=nofile buffer names as file names
Resolves: https://github.com/tpope/vim-fugitive/issues/1905
2021-12-08 16:17:41 -05:00
Tim Pope
c04e80c6eb Fix accidental :execute 0 2021-12-08 16:13:28 -05:00
Tim Pope
79c2b3f48d Try nested autocmds for ReadCmd/WriteCmd
I'm trying to leverage OptionSet for something.  Let's see if this
causes issues for anybody.
2021-12-07 09:17:47 -05:00
Tim Pope
2064312ad7 Don't reject invalid Git dir when detecting common dir
Consumers of this function should be giving us a valid Git dir, and if
they don't, returning an empty string will only make matters worse.

References: https://github.com/tpope/vim-fugitive/pull/1898
2021-12-01 20:05:47 -05:00
Tim Pope
c666c86882 Fix blame from stage buffer
References: https://github.com/tpope/vim-fugitive/issues/1892
2021-12-01 19:48:43 -05:00
Tim Pope
a099a2631c Disable diff.suppressBlankEmpty for summary window diff
Resolves: https://github.com/tpope/vim-fugitive/issues/1897
2021-12-01 19:27:29 -05:00
Tim Pope
82f2841bdf Fix gf error in commit message outside of repository 2021-11-28 15:36:44 -05:00
Tim Pope
5a24c25275 fugitive.vim 3.6
* Fix support for older Vim 7 patch levels.
* Support copies on :Gclog --follow.
2021-11-25 14:53:57 -05:00
Tim Pope
e82332ee9e Try to avoid trailing newline blame issues
Resolves: https://github.com/tpope/vim-fugitive/issues/1892
2021-11-22 13:24:21 -05:00
Tim Pope
64bc1a3431 Remove dead code
The use of remove() here wouldn't actually work as it expects an index,
not a value.
2021-11-19 17:42:33 -05:00
Tim Pope
4a8db6b856 Support copies with :Gclog --follow
Resolves: https://github.com/tpope/vim-fugitive/issues/1891
2021-11-19 17:19:30 -05:00
Tim Pope
3d5d23fe80 Remove q map stubs
Resolves: https://github.com/tpope/vim-fugitive/issues/1890
2021-11-19 17:16:36 -05:00
Tim Pope
2dfaf17f9e Use dummy events to prevent "No matching autocommands" message
This list of events was hand-curated to eliminate events already defined
elsewhere in the autoload file.

Resolves: https://github.com/tpope/vim-fugitive/issues/1887
2021-11-16 16:09:59 -05:00
Tim Pope
69ae31d402 Fix command execution on Vim 7
This worked on my test environment of 7.4.888, but did not work on
7.4.000.

References: https://github.com/tpope/vim-fugitive/issues/1889
2021-11-16 13:44:55 -05:00
Tim Pope
f9c0b8eafe Fix readfile() usage
Resolves: https://github.com/tpope/vim-fugitive/issues/1886
2021-11-15 20:54:19 -05:00
Tim Pope
e47121f8fd Fix typo 2021-11-15 00:31:32 -05:00
Tim Pope
cd67d087df fugitive.vim 3.5
* Lazy initialization.
* Make status buffer diff retrieval asynchronous.
* Support jump to diff from :Git log --name-status.
* Use smudge filters when viewing blobs.
* Provide User FugitiveEditor event.
* Provide FugitiveRemote() API function.
2021-11-15 00:17:52 -05:00
Tim Pope
b736e457b3 Provide FugitiveRemote() 2021-11-13 16:25:36 -05:00
Tim Pope
2e4ee0b5d6 Don't scroll :Git! window for paginated commands
References: https://github.com/tpope/vim-fugitive/issues/1832
2021-11-11 00:44:14 -05:00
Tim Pope
a6b823b8d0 Fix race condition on nvim 0.4
I could have sworn this wasn't necessary on 0.4, which is why I added
the extra clause, but I can consistently reproduce E716 now.

Resolves: https://github.com/tpope/vim-fugitive/issues/1881
2021-11-02 14:07:58 -04:00
Tim Pope
174fd6a39b Revert "Use :redrawstatus rather than &ro = &ro"
Turns out :redrawstatus is a lot more aggressive and can prevent seeing
Fugitive output.

This reverts commit 6ad15506cc.

References: https://github.com/tpope/vim-fugitive/issues/1180
2021-10-27 03:17:44 -04:00
Tim Pope
6ad15506cc Use :redrawstatus rather than &ro = &ro
References: https://github.com/tpope/vim-fugitive/issues/1180
2021-10-26 09:22:33 -04:00
Tim Pope
30933405bb Support blame maps without filetype plugin on
References: https://github.com/tpope/vim-fugitive/issues/1745
2021-10-19 11:44:22 -04:00
Tim Pope
4d29c1d6a0 Provide for retrieving parsed remote URL
The plan is to expose this as FugitiveRemote(), but let's give it some
bake time before making it official.
2021-10-17 20:25:23 -04:00
Tim Pope
93f41ace7d Move to beginning of line in "(" map
Resolves: https://github.com/tpope/vim-fugitive/issues/1867
2021-10-17 11:22:10 -04:00
Tim Pope
d5a6419fcf Guard against parallel status reload
Resolves: https://github.com/tpope/vim-fugitive/issues/1863
2021-10-17 11:22:10 -04:00
Tim Pope
88c7f867cf Further decouple #BufReadStatus() from v:cmdbang 2021-10-16 12:58:13 -04:00
5 changed files with 1907 additions and 1345 deletions

View File

@@ -86,13 +86,22 @@ For more information, see `:help fugitive`.
## Installation
Install using your favorite package manager, or use Vim's built-in package support:
Install using your favorite package manager, or use Vim's built-in package
support:
mkdir -p ~/.vim/pack/tpope/start
cd ~/.vim/pack/tpope/start
git clone https://tpope.io/vim/fugitive.git
vim -u NONE -c "helptags fugitive/doc" -c q
### Using Lazy
**Minimal Example for Lazy:**
```lua
{ "tpope/vim-fugitive" }
```
## FAQ
> What happened to the dispatch.vim backed asynchronous `:Gpush` and
@@ -103,6 +112,17 @@ it was removed. Use `:Git! push` to use Fugitive's own asynchronous
execution, or retroactively make `:Git push` asynchronous by pressing
`CTRL-D`.
> Why am I getting `core.worktree is required when using an external Git dir`?
Git generally sets `core.worktree` for you automatically when necessary, but
if you're doing something weird, or using a third-party tool that does
something weird, you may need to set it manually:
git config core.worktree "$PWD"
This may be necessary even when simple `git` commands seem to work fine
without it.
> So I have a symlink and...
Stop. Just stop. If Git won't deal with your symlink, then Fugitive won't

File diff suppressed because it is too large Load Diff

View File

@@ -18,6 +18,12 @@ that are part of Git repositories).
*fugitive-:G*
:G [args] Same as :Git, but two characters shorter.
*fugitive-summary*
:Git With no arguments, bring up a summary window vaguely
akin to git-status. If a summary window is already
open for the current repository, it is focused
instead. Press g? or see |fugitive-maps| for usage.
*:Git*
:Git {args} Run an arbitrary git command and display any output.
On UNIX this uses a pty and on other platforms it uses
@@ -47,11 +53,6 @@ that are part of Git repositories).
:{range}Git! -p {args} Run an arbitrary git command, and insert the output
after {range} in the current buffer.
*fugitive-summary*
:Git With no arguments, bring up a summary window vaguely
akin to git-status. Press g? or see |fugitive-maps|
for usage.
*:Git_blame*
:Git blame [flags] Run git-blame [flags] on the current file and open the
results in a scroll-bound vertical split. The
@@ -70,12 +71,20 @@ that are part of Git repositories).
O jump to patch or blob in new tab
p jump to patch or blob in preview window
- reblame at commit
~ reblame at [count]th first grandparent
P reblame at [count]th parent (like HEAD^[count])
The maps |fugitive_P| and |fugitive_~| are also
supported to reblame on a parent commit, but this is
inherently fragile, as the line being blamed will no
longer exist. The preferred alternative is to use
<CR> to open up the commit, select the corresponding
`-` line that you care about, and press <CR> twice
more to reblame at that line. Viewing the commit also
gives you additional context as to why the line
changed.
*g:fugitive_dynamic_colors*
In the GUI or a 256 color terminal, commit hashes will
highlighted in different colors. To disable this:
be highlighted in different colors. To disable this:
>
let g:fugitive_dynamic_colors = 0
<
@@ -98,6 +107,12 @@ that are part of Git repositories).
*:Git_mergetool*
:Git mergetool [args] Like |:Git_difftool|, but target merge conflicts.
Wrappers for Vim built-ins ~
These all directly map onto a built-in Vim command, and generally have names
that prepend "G" to the command they are wrapping. For example, :Ggrep is G
plus |:grep|.
*:Ggrep* *:Git_grep*
:Ggrep[!] [args] An approximation of |:grep|[!] with git-grep as
:Git[!] grep -O [args] 'grepprg'.
@@ -113,11 +128,12 @@ that are part of Git repositories).
*:Gclog*
:Gclog[!] [args] Use git-log [args] to load the commit history into the
|quickfix| list. Jumps to the first commit unless [!]
is given.
is given. This command wraps |:cfile|.
The quickfix list can be awkward for many use cases
and exhibits extremely poor performance with larger
data sets. Consider using |:Git| log instead.
data sets. Consider using |:Git| log --oneline
instead.
:{range}Gclog[!] [args] Use git-log -L to load previous revisions of the given
range of the current file into the |quickfix| list.
@@ -150,6 +166,9 @@ that are part of Git repositories).
*:Gpedit*
:Gpedit [object] |:pedit| a |fugitive-object|.
*:Gdrop*
:Gdrop [object] |:drop| a |fugitive-object|.
*:Gread* *fugitive-:Gr*
:Gread [object] Empty the buffer and |:read| a |fugitive-object|.
When the argument is omitted, this is similar to
@@ -158,12 +177,6 @@ that are part of Git repositories).
:{range}Gread [object] |:read| in a |fugitive-object| after {range}.
*:Gread!* *fugitive-:Gr!*
:Gread! [args] Empty the buffer and |:read| the output of a Git
command. For example, :Gread! show HEAD:%.
:{range}Gread! [args] |:read| the output of a Git command after {range}.
*:Gwrite* *fugitive-:Gw*
:Gwrite Write to the current file's path and stage the results.
When run in a work tree file, it is effectively git
@@ -213,6 +226,13 @@ that are part of Git repositories).
'diffopt'. The split will still be vertical if
combined with |:vertical|.
Other commands ~
These do not directly correspond to any built-in Vim command, and have a
capital letter after the "G" to convey this. For example, the file move
operation has nothing to do with the |:move| built-in, so it is named :GMove,
not :Gmove.
*:GMove*
:GMove {destination} Wrapper around git-mv that renames the buffer
afterward. Add a ! to pass -f.
@@ -227,8 +247,9 @@ that are part of Git repositories).
passed. Add a ! to pass -f and forcefully discard the
buffer.
*:GRemove*
*:GRemove* *:GUnlink*
:GRemove Like |:GDelete|, but keep the (now empty) buffer around.
:GUnlink
*:GBrowse*
:GBrowse Open the current file, blob, tree, commit, or tag
@@ -320,8 +341,8 @@ ds Perform a |:Ghdiffsplit| on the file under the cursor.
dh
*fugitive_dq*
dq Close all but one diff buffer, and |:diffoff|! the
last one.
dq Close all but the currently focused diff buffer, and
invoke |:diffoff|!.
*fugitive_d?*
d? Show this help.
@@ -359,6 +380,9 @@ p Open the file or |fugitive-object| under the cursor in
*fugitive_P*
P Open the current file in the [count]th parent.
Experimental: In the "Unpushed" section of the status
buffer, this will populate the command line with a
":Git push" command for the commit under the cursor.
*fugitive_C*
C Open the commit containing the current file.
@@ -441,15 +465,18 @@ Commit maps ~
cc Create a commit.
cvc Create a commit with -v.
ca Amend the last commit and edit the message.
cva Amend the last commit with -v.
ce Amend the last commit without editing the message.
cw Reword the last commit.
cvc Create a commit with -v.
cva Amend the last commit with -v
cW Create an `amend!` commit that rewords the commit
under the cursor.
cf Create a `fixup!` commit for the commit under the
cursor.
@@ -463,8 +490,8 @@ cs Create a `squash!` commit for the commit under the
cS Create a `squash!` commit for the commit under the
cursor and immediately rebase it.
cA Create a `squash!` commit for the commit under the
cursor and edit the message.
cn Create a `squash!` commit for the commit under the
(formerly cA) cursor and edit the message.
c<Space> Populate command line with ":Git commit ".
@@ -500,9 +527,11 @@ Stash maps ~
czz Push stash. Pass a [count] of 1 to add
`--include-untracked` or 2 to add `--all`.
czw Push stash of worktree. Like `czz` with
czw Push stash of the work-tree. Like `czz` with
`--keep-index`.
czs Push stash of the stage. Does not accept a count.
czA Apply topmost stash, or stash@{count}.
cza Apply topmost stash, or stash@{count}, preserving the
@@ -703,7 +732,7 @@ version.
*User_Fugitive*
Fugitive used to support `:autocmd User Fugitive` to run an autocommand after
loading any buffer belonging to a Git repository, but this is being phased
loading any buffer belonging to a Git repository, but this has been phased
out. Instead, one can leverage regular autocommand events like |BufNewFile|
and |BufReadPost|, and check !empty(FugitiveGitDir()) to confirm Fugitive has
found a repository. See also |fugitive-autocommands| for other, more

View File

@@ -1,6 +1,6 @@
" fugitive.vim - A Git wrapper so awesome, it should be illegal
" Maintainer: Tim Pope <http://tpo.pe/>
" Version: 3.4
" Version: 3.7
" GetLatestVimScripts: 2975 1 :AutoInstall: fugitive.vim
if exists('g:loaded_fugitive')
@@ -16,30 +16,30 @@ let s:bad_git_dir = '/$\|^fugitive:'
" Fugitive is active in the current buffer. Do not rely on this for direct
" filesystem access; use FugitiveFind('.git/whatever') instead.
function! FugitiveGitDir(...) abort
if v:version < 703
if v:version < 704
return ''
elseif !a:0 || type(a:1) == type(0) && a:1 < 0 || a:1 is# get(v:, 'true', -1)
if exists('g:fugitive_event')
return g:fugitive_event
endif
let dir = get(b:, 'git_dir', '')
if empty(dir) && (empty(bufname('')) || &buftype =~# '^\%(nofile\|acwrite\|quickfix\|terminal\|prompt\)$')
if empty(dir) && (empty(bufname('')) && &filetype !=# 'netrw' || &buftype =~# '^\%(nofile\|acwrite\|quickfix\|terminal\|prompt\)$')
return FugitiveExtractGitDir(getcwd())
elseif (!exists('b:git_dir') || b:git_dir =~# s:bad_git_dir) && empty(&buftype)
let b:git_dir = FugitiveExtractGitDir(expand('%:p'))
elseif (!exists('b:git_dir') || b:git_dir =~# s:bad_git_dir) && &buftype =~# '^\%(nowrite\)\=$'
let b:git_dir = FugitiveExtractGitDir(bufnr(''))
return b:git_dir
endif
return dir =~# s:bad_git_dir ? '' : dir
elseif type(a:1) == type(0) && a:1 isnot# 0
if a:1 == bufnr('') && (!exists('b:git_dir') || b:git_dir =~# s:bad_git_dir) && empty(&buftype)
let b:git_dir = FugitiveExtractGitDir(expand('%:p'))
if a:1 == bufnr('') && (!exists('b:git_dir') || b:git_dir =~# s:bad_git_dir) && &buftype =~# '^\%(nowrite\)\=$'
let b:git_dir = FugitiveExtractGitDir(a:1)
endif
let dir = getbufvar(a:1, 'git_dir')
return dir =~# s:bad_git_dir ? '' : dir
elseif type(a:1) == type('')
return substitute(s:Slash(a:1), '/$', '', '')
elseif type(a:1) == type({})
return get(a:1, 'git_dir', '')
return get(a:1, 'fugitive_dir', get(a:1, 'git_dir', ''))
else
return ''
endif
@@ -58,7 +58,7 @@ function! FugitiveReal(...) abort
if type(file) ==# type({})
let dir = FugitiveGitDir(file)
let tree = s:Tree(dir)
return FugitiveVimPath(empty(tree) ? dir : tree)
return s:VimSlash(empty(tree) ? dir : tree)
elseif file =~# '^\a\a\+:' || a:0 > 1
return call('fugitive#Real', [file] + a:000[1:-1])
elseif file =~# '^/\|^\a:\|^$'
@@ -88,15 +88,14 @@ endfunction
" the inverse of FugitiveFind().
function! FugitiveParse(...) abort
let path = s:Slash(a:0 ? a:1 : @%)
if path !~# '^fugitive:'
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]]
let [rev, dir] = fugitive#Parse(path)
if !empty(dir)
return [rev, dir]
endif
let v:errmsg = 'fugitive: invalid Fugitive URL ' . path
throw v:errmsg
throw 'fugitive: invalid Fugitive URL ' . path
endfunction
" FugitiveGitVersion() queries the version of Git in use. Pass up to 3
@@ -141,7 +140,7 @@ function! FugitiveExecute(args, ...) abort
return call('fugitive#Execute', [a:args] + a:000)
endfunction
" FugitiveShellCommand() turns an array of arugments into a Git command string
" FugitiveShellCommand() turns an array of arguments into a Git command string
" which can be executed with functions like system() and commands like :!.
" Integer arguments will be treated as buffer numbers, and the appropriate
" relative path inserted in their place.
@@ -152,19 +151,6 @@ function! FugitiveShellCommand(...) abort
return call('fugitive#ShellCommand', a:000)
endfunction
" FugitivePrepare() is a deprecated alias for FugitiveShellCommand(). If you
" are using this in conjunction with system(), consider using
" FugitiveExecute() instead.
function! FugitivePrepare(...) abort
if !exists('s:did_prepare_warning')
let s:did_prepare_warning = 1
echohl WarningMsg
unsilent echomsg 'FugitivePrepare() has been superseded by FugitiveShellCommand()'
echohl NONE
endif
return call('fugitive#ShellCommand', a:000)
endfunction
" FugitiveConfig() get returns an opaque structure that can be passed to other
" FugitiveConfig functions in lieu of a Git directory. This can be faster
" when performing multiple config queries. Do not rely on the internal
@@ -182,7 +168,7 @@ endfunction
" argument can be either the object returned by FugitiveConfig(), or a Git
" dir or buffer number to be passed along to FugitiveConfig().
function! FugitiveConfigGet(name, ...) abort
return get(call('FugitiveConfigGetAll', [a:name] + (a:0 ? [a:1] : [])), 0, get(a:, 2, ''))
return get(call('FugitiveConfigGetAll', [a:name] + (a:0 ? [a:1] : [])), -1, get(a:, 2, ''))
endfunction
" FugitiveConfigGetAll() is like FugitiveConfigGet() but returns a list of
@@ -210,6 +196,24 @@ function! FugitiveRemoteUrl(...) abort
return call('fugitive#RemoteUrl', a:000)
endfunction
" FugitiveRemote() returns a data structure parsed from the remote URL.
" For example, for remote URL "https://me@example.com:1234/repo.git", the
" returned dictionary will contain the following:
"
" * "scheme": "https"
" * "authority": "user@example.com:1234"
" * "path": "/repo.git" (for SSH URLs this may be a relative path)
" * "pathname": "/repo.git" (always coerced to absolute path)
" * "host": "example.com:1234"
" * "hostname": "example.com"
" * "port": "1234"
" * "user": "me"
" * "path": "/repo.git"
" * "url": "https://me@example.com:1234/repo.git"
function! FugitiveRemote(...) abort
return call('fugitive#Remote', a:000)
endfunction
" FugitiveDidChange() triggers a FugitiveChanged event and reloads the summary
" buffer for the current or given buffer number's repository. You can also
" give the result of a FugitiveExecute() and that context will be made
@@ -265,12 +269,40 @@ function! FugitiveStatusline(...) abort
return fugitive#Statusline()
endfunction
function! FugitiveCommonDir(...) abort
let dir = FugitiveGitDir(a:0 ? a:1 : -1)
let s:resolved_git_dirs = {}
function! FugitiveActualDir(...) abort
let dir = call('FugitiveGitDir', a:000)
if empty(dir)
return ''
endif
return fugitive#Find('.git/refs/..', dir)
if !has_key(s:resolved_git_dirs, dir)
let s:resolved_git_dirs[dir] = s:ResolveGitDir(dir)
endif
return empty(s:resolved_git_dirs[dir]) ? dir : s:resolved_git_dirs[dir]
endfunction
let s:commondirs = {}
function! FugitiveCommonDir(...) abort
let dir = call('FugitiveActualDir', a:000)
if empty(dir)
return ''
endif
if has_key(s:commondirs, dir)
return s:commondirs[dir]
endif
if getfsize(dir . '/HEAD') >= 10
let cdir = get(s:ReadFile(dir . '/commondir', 1), 0, '')
if cdir =~# '^/\|^\a:/'
let s:commondirs[dir] = s:Slash(FugitiveVimPath(cdir))
elseif len(cdir)
let s:commondirs[dir] = simplify(dir . '/' . cdir)
else
let s:commondirs[dir] = dir
endif
else
let s:commondirs[dir] = dir
endif
return s:commondirs[dir]
endfunction
function! FugitiveWorkTree(...) abort
@@ -292,34 +324,54 @@ function! FugitiveIsGitDir(...) abort
\ getftype(path.'commondir') ==# 'file')
endfunction
function! s:ReadFile(path, line_count) abort
if v:version < 800 && !filereadable(a:path)
return []
endif
try
return readfile(a:path, 'b', a:line_count)
catch
return []
endtry
endfunction
let s:worktree_for_dir = {}
let s:dir_for_worktree = {}
function! s:Tree(path) abort
let dir = a:path
if dir =~# '/\.git$'
return len(dir) ==# 5 ? '/' : dir[0:-6]
elseif dir ==# ''
if a:path =~# '/\.git$'
return len(a:path) ==# 5 ? '/' : a:path[0:-6]
elseif a:path ==# ''
return ''
endif
let dir = FugitiveActualDir(a:path)
if !has_key(s:worktree_for_dir, dir)
let s:worktree_for_dir[dir] = ''
let config_file = dir . '/config'
if filereadable(config_file)
let config = readfile(config_file,'',10)
let wt_config = filter(copy(config),'v:val =~# "^\\s*worktree *="')
if len(wt_config) == 1
let worktree = FugitiveVimPath(matchstr(wt_config[0], '= *\zs.*'))
else
call filter(config,'v:val =~# "^\\s*bare *= *false *$"')
if len(config)
let s:worktree_for_dir[dir] = 0
endif
let ext_wtc_pat = 'v:val =~# "^\\s*worktreeConfig *= *\\%(true\\|yes\\|on\\|1\\) *$"'
let config = s:ReadFile(dir . '/config', 50)
if len(config)
let ext_wtc_config = filter(copy(config), ext_wtc_pat)
if len(ext_wtc_config) == 1 && filereadable(dir . '/config.worktree')
let config += s:ReadFile(dir . '/config.worktree', 50)
endif
elseif filereadable(dir . '/gitdir')
let worktree = fnamemodify(FugitiveVimPath(readfile(dir . '/gitdir')[0]), ':h')
else
let worktree = fnamemodify(FugitiveVimPath(get(s:ReadFile(dir . '/gitdir', 1), '0', '')), ':h')
if worktree ==# '.'
unlet! worktree
endif
if len(filter(s:ReadFile(FugitiveCommonDir(dir) . '/config', 50), ext_wtc_pat))
let config = s:ReadFile(dir . '/config.worktree', 50)
endif
endif
if len(config)
let wt_config = filter(copy(config), 'v:val =~# "^\\s*worktree *="')
if len(wt_config)
let worktree = FugitiveVimPath(matchstr(wt_config[0], '= *\zs.*'))
elseif !exists('worktree')
call filter(config,'v:val =~# "^\\s*bare *= *true *$"')
if empty(config)
let s:worktree_for_dir[dir] = 0
endif
endif
endif
if exists('worktree')
let s:worktree_for_dir[dir] = s:Slash(resolve(worktree))
@@ -341,48 +393,60 @@ function! s:CeilingDirectories() abort
if empty(dir)
let resolve = 0
elseif resolve
call add(s:ceiling_directories, resolve(dir))
call add(s:ceiling_directories, s:Slash(resolve(dir)))
else
call add(s:ceiling_directories, dir)
call add(s:ceiling_directories, s:Slash(dir))
endif
endfor
endif
return s:ceiling_directories + get(g:, 'ceiling_directories', [])
return s:ceiling_directories + get(g:, 'ceiling_directories', [s:Slash(fnamemodify(expand('~'), ':h'))])
endfunction
function! s:ResolveGitDir(git_dir) abort
let type = getftype(a:git_dir)
if type ==# 'dir' && FugitiveIsGitDir(a:git_dir)
return a:git_dir
elseif type ==# 'link' && FugitiveIsGitDir(a:git_dir)
return resolve(a:git_dir)
elseif type !=# ''
let line = get(s:ReadFile(a:git_dir, 1), 0, '')
let file_dir = s:Slash(FugitiveVimPath(matchstr(line, '^gitdir: \zs.*')))
if file_dir !~# '^/\|^\a:\|^$' && a:git_dir =~# '/\.git$' && FugitiveIsGitDir(a:git_dir[0:-5] . file_dir)
return simplify(a:git_dir[0:-5] . file_dir)
elseif file_dir =~# '^/\|^\a:' && FugitiveIsGitDir(file_dir)
return file_dir
endif
endif
return ''
endfunction
function! FugitiveExtractGitDir(path) abort
if type(a:path) ==# type({})
return get(a:path, 'git_dir', '')
return get(a:path, 'fugitive_dir', get(a:path, 'git_dir', ''))
elseif type(a:path) == type(0)
let path = s:Slash(a:path >= 0 ? bufname(a:path) : bufname(''))
let path = s:Slash(a:path > 0 ? bufname(a:path) : bufname(''))
if getbufvar(a:path, '&filetype') ==# 'netrw'
let path = s:Slash(getbufvar(a:path, 'netrw_curdir', path))
endif
else
let path = s:Slash(a:path)
endif
if path =~# '^fugitive:'
return matchstr(path, '\C^fugitive:\%(//\)\=\zs.\{-\}\ze\%(//\|::\|$\)')
if path =~# '^fugitive://'
return fugitive#Parse(path)[1]
elseif empty(path)
return ''
elseif isdirectory(path)
let path = fnamemodify(path, ':p:s?/$??')
else
let path = fnamemodify(path, ':p:h:s?/$??')
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)
if root !=# path
silent! exe (haslocaldir() ? 'lcd' : exists(':tcd') && haslocaldir(-1) ? 'tcd' : 'cd') '.'
let path = {pre}Real(path)
endif
let root = s:Slash(fnamemodify(path, ':p:h'))
let previous = ""
let env_git_dir = len($GIT_DIR) ? s:Slash(simplify(fnamemodify(FugitiveVimPath($GIT_DIR), ':p:s?[\/]$??'))) : ''
call s:Tree(env_git_dir)
while root !=# previous
if root =~# '\v^//%([^/]+/?)?$'
break
endif
if index(s:CeilingDirectories(), root) >= 0
let ceiling_directories = s:CeilingDirectories()
while root !=# previous && root !~# '^$\|^//[^/]*$'
if index(ceiling_directories, root) >= 0
break
endif
if root ==# $GIT_WORK_TREE && FugitiveIsGitDir(env_git_dir)
@@ -391,20 +455,12 @@ function! FugitiveExtractGitDir(path) abort
return s:dir_for_worktree[root]
endif
let dir = substitute(root, '[\/]$', '', '') . '/.git'
let type = getftype(dir)
if type ==# 'dir' && FugitiveIsGitDir(dir)
return dir
elseif type ==# 'link' && FugitiveIsGitDir(dir)
return resolve(dir)
elseif type !=# '' && filereadable(dir)
let line = get(readfile(dir, '', 1), 0, '')
let file_dir = s:Slash(FugitiveVimPath(matchstr(line, '^gitdir: \zs.*')))
if file_dir !~# '^/\|^\a:' && FugitiveIsGitDir(root . '/' . file_dir)
return simplify(root . '/' . file_dir)
elseif len(file_dir) && FugitiveIsGitDir(file_dir)
return file_dir
endif
let resolved = s:ResolveGitDir(dir)
if !empty(resolved)
let s:resolved_git_dirs[dir] = resolved
return dir is# resolved || s:Tree(resolved) is# 0 ? dir : resolved
elseif FugitiveIsGitDir(root)
let s:resolved_git_dirs[root] = root
return root
endif
let previous = root
@@ -414,57 +470,56 @@ function! FugitiveExtractGitDir(path) abort
endfunction
function! FugitiveDetect(...) abort
if v:version < 703
if v:version < 704
return ''
endif
if exists('b:git_dir') && b:git_dir =~# '^$\|' . s:bad_git_dir
unlet b:git_dir
endif
if a:0 > 1 && a:2 is# 0 && !exists('#User#Fugitive')
return ''
endif
if !exists('b:git_dir')
let b:git_dir = FugitiveExtractGitDir(a:0 ? a:1 : bufnr(''))
endif
if empty(b:git_dir) || !exists('#User#Fugitive')
return ''
endif
if v:version >= 704 || (v:version == 703 && has('patch442'))
doautocmd <nomodeline> User Fugitive
elseif &modelines > 0
let modelines = &modelines
try
set modelines=0
doautocmd User Fugitive
finally
let &modelines = modelines
endtry
else
doautocmd User Fugitive
endif
return ''
endfunction
function! FugitiveVimPath(path) abort
if exists('+shellslash') && !&shellslash
return tr(a:path, '/', '\')
else
return a:path
endif
endfunction
function! FugitiveGitPath(path) abort
return s:Slash(a:path)
endfunction
if exists('+shellslash')
function! s:Slash(path) abort
return tr(a:path, '\', '/')
endfunction
function! s:VimSlash(path) abort
return tr(a:path, '\/', &shellslash ? '//' : '\\')
endfunction
function FugitiveVimPath(path) abort
return tr(a:path, '\/', &shellslash ? '//' : '\\')
endfunction
else
function! s:Slash(path) abort
return a:path
endfunction
function! s:VimSlash(path) abort
return a:path
endfunction
if has('win32unix') && filereadable('/git-bash.exe')
function! FugitiveVimPath(path) abort
return substitute(a:path, '^\(\a\):', '/\l\1', '')
endfunction
else
function! FugitiveVimPath(path) abort
return a:path
endfunction
endif
endif
function! s:ProjectionistDetect() abort
@@ -497,9 +552,6 @@ command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#Complete Git exe
if exists(':Gstatus') != 2 && get(g:, 'fugitive_legacy_commands', 0)
exe 'command! -bang -bar -range=-1' s:addr_other 'Gstatus exe fugitive#Command(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
\ '|echohl WarningMSG|echomsg ":Gstatus is deprecated in favor of :Git (with no arguments)"|echohl NONE'
elseif exists(':Gstatus') != 2 && !exists('g:fugitive_legacy_commands')
exe 'command! -bang -bar -range=-1' s:addr_other 'Gstatus'
\ ' echoerr ":Gstatus has been removed in favor of :Git (with no arguments)"'
endif
for s:cmd in ['Commit', 'Revert', 'Merge', 'Rebase', 'Pull', 'Push', 'Fetch', 'Blame']
@@ -507,9 +559,6 @@ for s:cmd in ['Commit', 'Revert', 'Merge', 'Rebase', 'Pull', 'Push', 'Fetch', 'B
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#' . s:cmd . 'Complete G' . tolower(s:cmd)
\ 'echohl WarningMSG|echomsg ":G' . tolower(s:cmd) . ' is deprecated in favor of :Git ' . tolower(s:cmd) . '"|echohl NONE|'
\ 'exe fugitive#Command(<line1>, <count>, +"<range>", <bang>0, "<mods>", "' . tolower(s:cmd) . ' " . <q-args>)'
elseif exists(':G' . tolower(s:cmd)) != 2 && !exists('g:fugitive_legacy_commands')
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#' . s:cmd . 'Complete G' . tolower(s:cmd)
\ 'echoerr ":G' . tolower(s:cmd) . ' has been removed in favor of :Git ' . tolower(s:cmd) . '"'
endif
endfor
unlet s:cmd
@@ -520,13 +569,6 @@ exe "command! -bar -bang -nargs=? -complete=customlist,fugitive#CdComplete Glcd
exe 'command! -bang -nargs=? -range=-1' s:addr_wins '-complete=customlist,fugitive#GrepComplete Ggrep exe fugitive#GrepCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
exe 'command! -bang -nargs=? -range=-1' s:addr_wins '-complete=customlist,fugitive#GrepComplete Glgrep exe fugitive#GrepCommand(0, <count> > 0 ? <count> : 0, +"<range>", <bang>0, "<mods>", <q-args>)'
if exists(':Glog') != 2 && get(g:, 'fugitive_legacy_commands', 0)
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete Glog :exe fugitive#LogCommand(<line1>,<count>,+"<range>",<bang>0,"<mods>",<q-args>, "")'
\ '|echohl WarningMSG|echomsg ":Glog is deprecated in favor of :Gclog"|echohl NONE'
elseif exists(':Glog') != 2 && !exists('g:fugitive_legacy_commands')
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete Glog'
\ ' echoerr ":Glog has been removed in favor of :Gclog"'
endif
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete Gclog :exe fugitive#LogCommand(<line1>,<count>,+"<range>",<bang>0,"<mods>",<q-args>, "c")'
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete GcLog :exe fugitive#LogCommand(<line1>,<count>,+"<range>",<bang>0,"<mods>",<q-args>, "c")'
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete Gllog :exe fugitive#LogCommand(<line1>,<count>,+"<range>",<bang>0,"<mods>",<q-args>, "l")'
@@ -534,10 +576,11 @@ exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Ge exe fugitive#Open("edit<bang>", 0, "<mods>", <q-args>)'
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gedit exe fugitive#Open("edit<bang>", 0, "<mods>", <q-args>)'
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#ReadComplete Gpedit exe fugitive#Open("pedit", <bang>0, "<mods>", <q-args>)'
exe 'command! -bar -bang -nargs=* -range=-1' s:addr_other '-complete=customlist,fugitive#ReadComplete Gsplit exe fugitive#Open((<count> > 0 ? <count> : "").(<count> ? "split" : "edit"), <bang>0, "<mods>", <q-args>)'
exe 'command! -bar -bang -nargs=* -range=-1' s:addr_other '-complete=customlist,fugitive#ReadComplete Gvsplit exe fugitive#Open((<count> > 0 ? <count> : "").(<count> ? "vsplit" : "edit!"), <bang>0, "<mods>", <q-args>)'
exe 'command! -bar -bang -nargs=* -range=-1' s:addr_tabs '-complete=customlist,fugitive#ReadComplete Gtabedit exe fugitive#Open((<count> >= 0 ? <count> : "")."tabedit", <bang>0, "<mods>", <q-args>)'
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gpedit exe fugitive#Open("pedit", <bang>0, "<mods>", <q-args>)'
exe 'command! -bar -bang -nargs=* -range=-1' s:addr_other '-complete=customlist,fugitive#EditComplete Gsplit exe fugitive#Open((<count> > 0 ? <count> : "").(<count> ? "split" : "edit"), <bang>0, "<mods>", <q-args>)'
exe 'command! -bar -bang -nargs=* -range=-1' s:addr_other '-complete=customlist,fugitive#EditComplete Gvsplit exe fugitive#Open((<count> > 0 ? <count> : "").(<count> ? "vsplit" : "edit!"), <bang>0, "<mods>", <q-args>)'
exe 'command! -bar -bang -nargs=* -range=-1' s:addr_tabs '-complete=customlist,fugitive#EditComplete Gtabedit exe fugitive#Open((<count> >= 0 ? <count> : "")."tabedit", <bang>0, "<mods>", <q-args>)'
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gdrop exe fugitive#DropCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
if exists(':Gr') != 2
exe 'command! -bar -bang -nargs=* -range=-1 -complete=customlist,fugitive#ReadComplete Gr exe fugitive#ReadCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
@@ -553,33 +596,47 @@ exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gwr
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gwq exe fugitive#WqCommand( <line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
exe 'command! -bar -bang -nargs=0 GRemove exe fugitive#RemoveCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
exe 'command! -bar -bang -nargs=0 GUnlink exe fugitive#UnlinkCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
exe 'command! -bar -bang -nargs=0 GDelete exe fugitive#DeleteCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
exe 'command! -bar -bang -nargs=1 -complete=customlist,fugitive#CompleteObject GMove exe fugitive#MoveCommand( <line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
exe 'command! -bar -bang -nargs=1 -complete=customlist,fugitive#RenameComplete GRename exe fugitive#RenameCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
if exists(':Gremove') != 2 && get(g:, 'fugitive_legacy_commands', 1)
if exists(':Gremove') != 2 && get(g:, 'fugitive_legacy_commands', 0)
exe 'command! -bar -bang -nargs=0 Gremove exe fugitive#RemoveCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
\ '|echohl WarningMSG|echomsg ":Gremove is deprecated in favor of :GRemove"|echohl NONE'
elseif exists(':Gremove') != 2 && !exists('g:fugitive_legacy_commands')
exe 'command! -bar -bang -nargs=0 Gremove echoerr ":Gremove has been removed in favor of :GRemove"'
endif
if exists(':Gdelete') != 2 && get(g:, 'fugitive_legacy_commands', 1)
if exists(':Gdelete') != 2 && get(g:, 'fugitive_legacy_commands', 0)
exe 'command! -bar -bang -nargs=0 Gdelete exe fugitive#DeleteCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
\ '|echohl WarningMSG|echomsg ":Gdelete is deprecated in favor of :GDelete"|echohl NONE'
elseif exists(':Gdelete') != 2 && !exists('g:fugitive_legacy_commands')
exe 'command! -bar -bang -nargs=0 Gdelete echoerr ":Gdelete has been removed in favor of :GDelete"'
endif
if exists(':Gmove') != 2 && get(g:, 'fugitive_legacy_commands', 1)
if exists(':Gmove') != 2 && get(g:, 'fugitive_legacy_commands', 0)
exe 'command! -bar -bang -nargs=1 -complete=customlist,fugitive#CompleteObject Gmove exe fugitive#MoveCommand( <line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
\ '|echohl WarningMSG|echomsg ":Gmove is deprecated in favor of :GMove"|echohl NONE'
elseif exists(':Gmove') != 2 && !exists('g:fugitive_legacy_commands')
exe 'command! -bar -bang -nargs=? -complete=customlist,fugitive#CompleteObject Gmove'
\ 'echoerr ":Gmove has been removed in favor of :GMove"'
endif
if exists(':Grename') != 2 && get(g:, 'fugitive_legacy_commands', 1)
if exists(':Grename') != 2 && get(g:, 'fugitive_legacy_commands', 0)
exe 'command! -bar -bang -nargs=1 -complete=customlist,fugitive#RenameComplete Grename exe fugitive#RenameCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
\ '|echohl WarningMSG|echomsg ":Grename is deprecated in favor of :GRename"|echohl NONE'
elseif exists(':Grename') != 2 && !exists('g:fugitive_legacy_commands')
exe 'command! -bar -bang -nargs=? -complete=customlist,fugitive#RenameComplete Grename'
\ 'echoerr ":Grename has been removed in favor of :GRename"'
endif
exe 'command! -bar -bang -range=-1 -nargs=* -complete=customlist,fugitive#CompleteObject GBrowse exe fugitive#BrowseCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
if exists(':Gbrowse') != 2 && get(g:, 'fugitive_legacy_commands', 1)
if exists(':Gbrowse') != 2 && get(g:, 'fugitive_legacy_commands', 0)
exe 'command! -bar -bang -range=-1 -nargs=* -complete=customlist,fugitive#CompleteObject Gbrowse exe fugitive#BrowseCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
\ '|if <bang>1|redraw!|endif|echohl WarningMSG|echomsg ":Gbrowse is deprecated in favor of :GBrowse"|echohl NONE'
elseif exists(':Gbrowse') != 2 && !exists('g:fugitive_legacy_commands')
exe 'command! -bar -bang -range=-1 -nargs=* -complete=customlist,fugitive#CompleteObject Gbrowse'
\ 'echoerr ":Gbrowse has been removed in favor of :GBrowse"'
endif
if v:version < 703
if v:version < 704
finish
endif
@@ -604,8 +661,14 @@ augroup fugitive
autocmd!
autocmd BufNewFile,BufReadPost *
\ call FugitiveDetect(expand('<amatch>:p'), 0)
autocmd FileType netrw call FugitiveDetect(fnamemodify(get(b:, 'netrw_curdir', expand('<afile>:p')), ':p'), 1)
\ if exists('b:git_dir') && b:git_dir =~# '^$\|' . s:bad_git_dir |
\ unlet b:git_dir |
\ endif
autocmd FileType netrw
\ if exists('b:git_dir') && b:git_dir =~# '^$\|' . s:bad_git_dir |
\ unlet b:git_dir |
\ endif
autocmd BufFilePost * unlet! b:git_dir
autocmd FileType git
\ call fugitive#MapCfile()
@@ -625,28 +688,31 @@ augroup fugitive
\ endif |
\ let b:undo_ftplugin = get(b:, 'undo_ftplugin', 'exe') . '|setl inex= inc='
autocmd BufReadCmd index{,.lock}
autocmd BufReadCmd index{,.lock} nested
\ if FugitiveIsGitDir(expand('<amatch>:p:h')) |
\ let b:git_dir = s:Slash(expand('<amatch>:p:h')) |
\ exe fugitive#BufReadStatus() |
\ exe fugitive#BufReadStatus(v:cmdbang) |
\ echohl WarningMSG |
\ echo "fugitive: Direct editing of .git/" . expand('%:t') . " is deprecated" |
\ echohl NONE |
\ elseif filereadable(expand('<amatch>')) |
\ silent doautocmd BufReadPre |
\ keepalt read <amatch> |
\ 1delete_ |
\ keepalt noautocmd read <amatch> |
\ silent 1delete_ |
\ silent doautocmd BufReadPost |
\ else |
\ silent doautocmd BufNewFile |
\ endif
autocmd BufReadCmd fugitive://*//* exe fugitive#BufReadCmd() |
autocmd BufReadCmd fugitive://* nested exe fugitive#BufReadCmd() |
\ if &path =~# '^\.\%(,\|$\)' |
\ let &l:path = substitute(&path, '^\.,\=', '', '') |
\ endif
autocmd BufWriteCmd fugitive://*//[0-3]/* exe fugitive#BufWriteCmd()
autocmd FileReadCmd fugitive://*//* exe fugitive#FileReadCmd()
autocmd FileWriteCmd fugitive://*//[0-3]/* exe fugitive#FileWriteCmd()
autocmd BufWriteCmd fugitive://* nested exe fugitive#BufWriteCmd()
autocmd FileReadCmd fugitive://* nested exe fugitive#FileReadCmd()
autocmd FileWriteCmd fugitive://* nested exe fugitive#FileWriteCmd()
if exists('##SourceCmd')
autocmd SourceCmd fugitive://*//* nested exe fugitive#SourceCmd()
autocmd SourceCmd fugitive://* nested exe fugitive#SourceCmd()
endif
autocmd User Flags call Hoist('buffer', function('FugitiveStatusline'))
@@ -654,14 +720,15 @@ augroup fugitive
autocmd User ProjectionistDetect call s:ProjectionistDetect()
augroup END
nmap <script><silent> <Plug>fugitive:y<C-G> :<C-U>call setreg(v:register, fugitive#Object(@%))<CR>
nmap <script> <Plug>fugitive: <Nop>
if get(g:, 'fugitive_no_maps')
finish
endif
let s:nowait = v:version >= 704 ? '<nowait>' : ''
function! s:Map(mode, lhs, rhs, flags) abort
let flags = a:flags . (a:rhs =~# '<Plug>' ? '' : '<script>')
let flags = a:flags . (a:rhs =~# '<Plug>' ? '' : '<script>') . '<nowait>'
let head = a:lhs
let tail = ''
let keys = get(g:, a:mode.'remap', {})
@@ -678,8 +745,8 @@ function! s:Map(mode, lhs, rhs, flags) abort
let head = substitute(head, '<[^<>]*>$\|.$', '', '')
endwhile
endif
if flags !~# '<unique>' || empty(mapcheck(head.tail, a:mode))
exe a:mode.'map' s:nowait flags head.tail a:rhs
if empty(mapcheck(head.tail, a:mode))
exe a:mode.'map' flags head.tail a:rhs
endif
endfunction

View File

@@ -13,7 +13,7 @@ syn match fugitiveHeader /^Pull:\|^Rebase:\|^Merge:\|^Push:/ nextgroup=fugitiveS
syn match fugitiveHelpHeader /^Help:/ nextgroup=fugitiveHelpTag skipwhite
syn match fugitiveHelpTag /\S\+/ contained
syn region fugitiveSection start=/^\%(.*(\d\++\=)$\)\@=/ contains=fugitiveHeading end=/^$/
syn region fugitiveSection start=/^\%(.*(\d\++\=)$\)\@=/ contains=fugitiveHeading end=/^$/ fold
syn cluster fugitiveSection contains=fugitiveSection
syn match fugitiveHeading /^[A-Z][a-z][^:]*\ze (\d\++\=)$/ contains=fugitivePreposition contained nextgroup=fugitiveCount skipwhite
syn match fugitiveCount /(\d\++\=)/hs=s+1,he=e-1 contained
@@ -30,7 +30,7 @@ syn match fugitiveHash /\S\@<!\x\{4,\}\S\@!/ contained
syn region fugitiveHunk start=/^\%(@@\+ -\)\@=/ end=/^\%([A-Za-z?@]\|$\)\@=/ contains=diffLine,diffRemoved,diffAdded,diffNoEOL containedin=@fugitiveSection fold
for s:section in ['Untracked', 'Unstaged', 'Staged']
exe 'syn region fugitive' . s:section . 'Section start=/^\%(' . s:section . ' .*(\d\++\=)$\)\@=/ contains=fugitive' . s:section . 'Heading end=/^$/'
exe 'syn region fugitive' . s:section . 'Section start=/^\%(' . s:section . ' .*(\d\++\=)$\)\@=/ contains=fugitive' . s:section . 'Heading end=/^$/ fold'
exe 'syn match fugitive' . s:section . 'Modifier /^[MADRCU?] / contained containedin=fugitive' . s:section . 'Section'
exe 'syn cluster fugitiveSection add=fugitive' . s:section . 'Section'
exe 'syn match fugitive' . s:section . 'Heading /^[A-Z][a-z][^:]*\ze (\d\++\=)$/ contains=fugitivePreposition contained nextgroup=fugitiveCount skipwhite'