191 Commits
v3.7 ... master

Author SHA1 Message Date
Tim Pope
61b51c09b7 Fix race conditions generating sequencer sections
Resolves: https://github.com/tpope/vim-fugitive/issues/2411
2025-07-15 17:27:19 -04:00
Tim Pope
e0715fe729 Fix check for revert/cherry-pick
Undoing a bad search and replace in
4bc9d98993
2025-07-15 17:27:19 -04:00
Tim Pope
53d6ba99bc Remove unnecessary include guard 2025-07-15 17:27:19 -04:00
Josh Priddle
d3e2b58dec Fix GBrowse for newer Netrw versions
In vim/vim@ef92555 the arity of `netrw#BrowseX` changed from 2 to 1.
There is now a `netrw#os#Open()` function that can be used to open URLs
instead.
2025-07-11 20:18:39 -04:00
Tim Pope
593f831d6f Fix interpretation of :% when % is absolute
We're trying to support two different Git syntaxes here that were never
meant to be mixed.  We want :/foo/bar to be interpreted as the pathspec
:(top)foo/bar, but we want :% to be interpreted as the % file in the
index, even when % is /foo/bar.

Resolves: https://github.com/tpope/vim-fugitive/issues/2404
2025-06-19 14:33:59 -04:00
Tim Pope
4a745ea72f Remove antiquated a map
Resolves: https://github.com/tpope/vim-fugitive/issues/2380
2025-02-19 17:44:04 -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
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
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
4 changed files with 1355 additions and 1049 deletions

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 commit~[count]
P reblame at commit^[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
<
@@ -157,6 +166,9 @@ plus |:grep|.
*: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
@@ -165,12 +177,6 @@ plus |:grep|.
:{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
@@ -335,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.
@@ -374,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.
@@ -456,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.
@@ -478,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 ".
@@ -515,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
@@ -718,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

@@ -16,14 +16,14 @@ 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) && &buftype =~# '^\%(nowrite\)\=$'
let b:git_dir = FugitiveExtractGitDir(bufnr(''))
@@ -39,7 +39,7 @@ function! FugitiveGitDir(...) abort
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
@@ -91,12 +91,11 @@ function! FugitiveParse(...) abort
if path !~# '^fugitive://'
return ['', '']
endif
let vals = matchlist(path, s:dir_commit_file)
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
@@ -283,8 +269,16 @@ function! FugitiveStatusline(...) abort
return fugitive#Statusline()
endfunction
let s:resolved_git_dirs = {}
function! FugitiveActualDir(...) abort
return call('FugitiveGitDir', a:000)
let dir = call('FugitiveGitDir', a:000)
if empty(dir)
return ''
endif
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 = {}
@@ -344,12 +338,12 @@ 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 ext_wtc_pat = 'v:val =~# "^\\s*worktreeConfig *= *\\%(true\\|yes\\|on\\|1\\) *$"'
@@ -408,16 +402,37 @@ function! s:CeilingDirectories() abort
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(''))
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 get(matchlist(path, s:dir_commit_file), 1, '')
return fugitive#Parse(path)[1]
elseif empty(path)
return ''
endif
@@ -440,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 !=# ''
let line = get(s: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
@@ -463,34 +470,15 @@ 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
@@ -500,8 +488,6 @@ endfunction
if exists('+shellslash')
let s:dir_commit_file = '\c^fugitive://\%(/\a\@=\)\=\(.\{-\}\)//\%(\(\x\{40,\}\|[0-3]\)\(/.*\)\=\)\=$'
function! s:Slash(path) abort
return tr(a:path, '\', '/')
endfunction
@@ -516,8 +502,6 @@ if exists('+shellslash')
else
let s:dir_commit_file = '\c^fugitive://\(.\{-\}\)//\%(\(\x\{40,\}\|[0-3]\)\(/.*\)\=\)\=$'
function! s:Slash(path) abort
return a:path
endfunction
@@ -541,7 +525,7 @@ endif
function! s:ProjectionistDetect() abort
let file = s:Slash(get(g:, 'projectionist_file', ''))
let dir = FugitiveExtractGitDir(file)
let base = get(matchlist(file, s:dir_commit_file), 1, '')
let base = matchstr(file, '^fugitive://.\{-\}//\x\+')
if empty(base)
let base = s:Tree(dir)
endif
@@ -568,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']
@@ -578,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
@@ -591,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")'
@@ -605,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>)'
@@ -638,7 +610,7 @@ 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 ":Gremove has been removed in favor of :GRemove"'
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', 0)
exe 'command! -bar -bang -nargs=1 -complete=customlist,fugitive#CompleteObject Gmove exe fugitive#MoveCommand( <line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
@@ -664,7 +636,7 @@ elseif exists(':Gbrowse') != 2 && !exists('g:fugitive_legacy_commands')
\ 'echoerr ":Gbrowse has been removed in favor of :GBrowse"'
endif
if v:version < 703
if v:version < 704
finish
endif
@@ -688,8 +660,14 @@ let g:io_fugitive = {
augroup fugitive
autocmd!
autocmd BufNewFile,BufReadPost * call FugitiveDetect(+expand('<abuf>'), 0)
autocmd FileType netrw call FugitiveDetect(+expand('<abuf>'), 0)
autocmd BufNewFile,BufReadPost *
\ 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
@@ -714,6 +692,9 @@ augroup fugitive
\ if FugitiveIsGitDir(expand('<amatch>:p:h')) |
\ let b:git_dir = s:Slash(expand('<amatch>:p:h')) |
\ 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 noautocmd read <amatch> |
@@ -723,15 +704,15 @@ augroup fugitive
\ silent doautocmd BufNewFile |
\ endif
autocmd BufReadCmd fugitive://*//* nested exe fugitive#BufReadCmd() |
autocmd BufReadCmd fugitive://* nested exe fugitive#BufReadCmd() |
\ if &path =~# '^\.\%(,\|$\)' |
\ let &l:path = substitute(&path, '^\.,\=', '', '') |
\ endif
autocmd BufWriteCmd fugitive://*//[0-3]/* nested exe fugitive#BufWriteCmd()
autocmd FileReadCmd fugitive://*//* nested exe fugitive#FileReadCmd()
autocmd FileWriteCmd fugitive://*//[0-3]/* nested 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'))
@@ -739,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', {})
@@ -764,11 +746,9 @@ function! s:Map(mode, lhs, rhs, flags) abort
endwhile
endif
if empty(mapcheck(head.tail, a:mode))
exe a:mode.'map' s:nowait flags head.tail a:rhs
exe a:mode.'map' flags head.tail a:rhs
endif
endfunction
call s:Map('c', '<C-R><C-G>', 'fnameescape(fugitive#Object(@%))', '<expr>')
call s:Map('n', 'y<C-G>', ':<C-U>call setreg(v:register, fugitive#Object(@%))<CR>', '<silent>')
nmap <script><silent> <Plug>fugitive:y<C-G> :<C-U>call setreg(v:register, fugitive#Object(@%))<CR>
nmap <script> <Plug>fugitive: <Nop>

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'