Commit Graph

1990 Commits

Author SHA1 Message Date
Tim Pope
3a319cd5b8 Don't rely on current buffer's Git dir for :GBrowse
This makes :GBrowse fugitive://... work when the buffer name is from a
different repository.  It doesn't solve the harder problems of making it
work with a regular filename, or making it not bail early when the
current buffer doesn't belong to a repository at all.
2021-04-07 01:04:36 -04:00
Tim Pope
cd8bd39567 Support all <cword> style expansions
The previous implementation for <cfile> didn't handle <cfile>:h
correctly.  May as well support the rest of the gang while fixing this.
Note that unlike for % and #, these can return a commit in addition to a
file name.  Use a ":." expansion, as in "<cfile>:.", to get the
corresponding work tree file.
2021-04-07 01:04:36 -04:00
Tim Pope
d4d2b9c6b2 Ignore :GBrowse line numbers for non-blob objects
Pave the way to use these for other purposes.
2021-04-06 23:41:18 -04:00
Tim Pope
485251ec73 Provide "." and "<C-R><C-G>" in blame buffers 2021-04-06 23:41:18 -04:00
Tim Pope
50b57ba400 Fix double "fugitive:" in error message 2021-04-06 23:41:18 -04:00
Tim Pope
b4255d6679 Add notices to deprecated lowercase commands 2021-04-06 20:43:26 -04:00
Tim Pope
87b169728c Add aliases for blame "-" map
This is one of the more common conflicts people have with their own
maps, so make it available on "s" and "u".  This roughly lines up with
the status buffer maps, which I think is as good of decision as any,
lacking a better mnemonic.
2021-04-06 20:43:26 -04:00
Tim Pope
f29c9e5079 Support :GBrowse {url} outside of Git repository 2021-04-04 18:26:17 -04:00
Tim Pope
81074db0ee Pass <mods> along to URL opener
I don't know if there is a use for this, but it seems like the right
thing to do.
2021-04-03 23:35:42 -04:00
Tim Pope
2ef9d9a748 Use :echo not :echomsg for displaying :GBrowse URL
Logging the URL permanently to :messages was a mistake.
2021-04-03 23:35:42 -04:00
Tim Pope
ce58344c9e Jump to correct Unpushed/Unpulled section on reload 2021-04-03 20:44:31 -04:00
Tim Pope
e474785adb Handle non-config dictionary passed to FugitiveConfig() 2021-04-03 20:44:31 -04:00
Tim Pope
d3341147ef URL escape :command special characters
Handle the case where the :Browse or :OpenBrowser command we delegate to
is defined with -bar.
2021-04-03 20:44:31 -04:00
Tim Pope
1a765a46c1 Add git_dir key to :GBrowse API
This enables passing the whole options dictionary to helpers like
FugitiveWorkTree().
2021-04-03 20:44:31 -04:00
Tim Pope
5a54ea4333 Handle race condition closing job stdin
This race condition is there for any key press, but it's greatly
exaggerated by Vim's default one second timeout on Escape.  This delay
also disqualifies Escape as the official interface to this feature, but
leave it as a DWIM alternative to CTRL-D for now.

Closes https://github.com/tpope/vim-fugitive/issues/1722
2021-04-01 20:50:34 -04:00
Tim Pope
1d91517cdb Don't discard deleted submodules
There isn't a good command to use for the undo.

References https://github.com/tpope/vim-fugitive/issues/1705
2021-04-01 20:50:34 -04:00
Tim Pope
c028ea5a44 Add foldtext for hunk headers 2021-04-01 08:57:58 -04:00
Tim Pope
88f50bba60 Press escape to background :Git to preview window
This can one day hopefully be generalized to handle --paginate, but for
now, leave it as undocumented experiment.
2021-03-31 16:06:40 -04:00
Tim Pope
9bd7c26466 Expand <cfile>
This doesn't play well with :Git as it can result in a fugitive:// URL,
but it does make :Gedit <cfile> and :GBrowse <cfile> do what I mean.
2021-03-31 16:05:14 -04:00
Tim Pope
002ed8de2e Make FugitiveChanged event aware of :Git result
If g:fugitive_result is defined during the User FugitiveChanged event,
one can trigger a custom behavior based on the arguments in .args or the
output in .file.

References https://github.com/tpope/vim-fugitive/pull/1015
2021-03-30 13:33:23 -04:00
Tim Pope
a1cb01da5b Provide :Gedit - to open previous :Git output
Also, provide :GBrowse - to open the first URL contained in that output.
2021-03-29 21:20:28 -04:00
Tim Pope
6b39f6c641 Restore X on submodules
References https://github.com/tpope/vim-fugitive/issues/1705
2021-03-29 20:32:11 -04:00
Tim Pope
09cbabe793 Don't trigger FugitiveChanged until :Git finishes output
Since this user event can error or otherwise interrupt us, run it as
late as possible.  Also rearrange a bit so that a user error won't
cascade to "missing :endif".
2021-03-29 19:33:01 -04:00
Tim Pope
258dd16938 Fix undesired line wrap in :Git output
If Vim is 100 columns wide, and we echo a string exactly 100 characters
long, Vim will insert a line break that a terminal wouldn't.  This is
particularly noticeable with progress bars that Git erases with a screen
width's worth of whitespace.  Work around this by decreasing the number
of columns by 1.
2021-03-28 14:42:46 -04:00
Tim Pope
112310c026 Move edit sentinel removal out of resume handler
Enable using this function in cases other than pausing for edit.
2021-03-28 14:42:46 -04:00
Tim Pope
f4acdcc5b4 Eliminate blank line after resuming from GIT_EDITOR
Also add has_key(a:tmp, 'echo') checks to allow for future async
workflows.
2021-03-27 23:08:13 -04:00
Tim Pope
f7321f6d5b Allow close callback to run before leaving job wait loop
Apparently, both job_status() == "dead" and ch_status() == "closed"
isn't enough to guarantee all callbacks have run.  One last sleep seems
to do the trick, but let's also add a sanity check because this can
cause confusing, hard to debug behavior.
2021-03-27 23:08:13 -04:00
Tim Pope
00cb68e627 Echo from wait loop, not job callback
This makes the pager behave a better, allowing the -- More -- prompt to
actually display and not dropping output if the process exits while
there's a backlog.  An additional benefit is if Git for some reason
produces additional output while GIT_EDITOR is running, that output will
be buffered rather than interrupting the user.

The extracted s:RunTick() helper changes the Vim behavior to check the
process status after waiting as well as before.  This brings it in line
with how Neovim's jobwait() appears to work.

The zero argument :echo after the final s:RunEcho() clears up some weird
draw issues with `:Git command|someothercommand`.

References https://github.com/tpope/vim-fugitive/issues/1717
2021-03-27 15:38:29 -04:00
Tim Pope
af1a46edb7 Don't record last job until after completion
This prevents orphaning a :Git commit when calling a second :Git command
while editing the commit message, and is more predictable all around.
2021-03-27 15:38:29 -04:00
Tim Pope
eaee845aba Unify remote resolution
HTTP redirects and SSH host aliases are just different manifestations of
the same indirection, so handle them both in FugitiveRemoteUrl().  Also
make this function idempotent if a URL is passed in, and pass some
sensible options to cURL.
2021-03-26 12:26:27 -04:00
Tim Pope
6860c592ad Capture cwd of :Git command 2021-03-26 12:26:27 -04:00
Tim Pope
a12e88bcc2 Add error message when editing after Vim exit
I don't think it's possible to see this, but we can use this error
delivery system for other purposes.
2021-03-26 12:26:21 -04:00
Tim Pope
0713b84f97 Don't wait silently on :wall with 'confirm' 2021-03-26 12:26:21 -04:00
Tim Pope
93b434949b Don't try to send :Git process CTRL-C when stdin is closed
Curiously, this appears to work anyways in Neovim, but not Vim.
2021-03-25 19:32:50 -04:00
Tim Pope
7de9b5a04b Retool :Git blame colored commits
Use 3 characters of the commit hash rather than 6, limiting the maximum
total declarations to 4,096 rather than 16 million. Avoid color
components lower than 0x20 and higher than 0xdf to help avoid colors
that blend into the background, light or dark.  And for the terminal,
replace the use of CSApprox with a simple usage of the 6x6x6 color cube
found on 256 color terminals.  CSApprox aims to provide accurate
replication of the input colors, whereas our goal is simply to use all
colors in roughly equal amounts.
2021-03-25 11:34:29 -04:00
Tim Pope
b2195e7690 Extract fugitiveblame ftplugin
References https://github.com/tpope/vim-fugitive/issues/1425
2021-03-24 21:17:37 -04:00
Tim Pope
5e5ce843ea Automatically mkdir when editing .git/info/exclude 2021-03-24 19:56:08 -04:00
Tim Pope
a03444404a Capture exit status of :Git 2021-03-24 17:42:16 -04:00
Tim Pope
64a3f99d03 Pass private job state to s:RunWait() 2021-03-24 17:42:16 -04:00
Tim Pope
9103a738c7 Fix :GBrowse with no argument 2021-03-24 17:42:16 -04:00
Tim Pope
156dbcd738 Don't set foldmethod=syntax in historical buffers
This was originally implemented in part to address the marker fold
method triggering on diffs, so try to still solve that.
2021-03-24 14:21:32 -04:00
Tim Pope
133bf406c7 Accept alternate syntax for :GBrowse remote
The @ syntax is kind of weird as you can't use fnameescape() to get
around it.  Add an alternative syntax for programmatic usage.
2021-03-24 14:21:32 -04:00
Tim Pope
d5d436bfa3 Tweak default list of paginated commands
The only functional change here should be the exclusion of the diff-*
plumbing commands.
2021-03-24 14:21:17 -04:00
Tim Pope
53df837ac6 Don't complete directories as subcommands 2021-03-24 14:20:45 -04:00
Tim Pope
0205ae8d45 Handle tabs in commit subject
References https://github.com/tpope/vim-fugitive/pull/1713
2021-03-24 14:20:45 -04:00
Tim Pope
11b824a0ee Forcefully disable colors on paginated :Git output
References https://github.com/tpope/vim-fugitive/discussions/1711
2021-03-24 14:20:45 -04:00
Tim Pope
857496c32f Unify temp state and job state 2021-03-23 13:39:45 -04:00
Tim Pope
9715dbe19e Replace broken check for nvim 0.5.0
Apparently has('nvim-0.5.0') actually means "any nightly release after
0.4.4".  I guess we'll have to settle for 0.5.1?

Closes https://github.com/tpope/vim-fugitive/issues/1709
2021-03-23 13:39:45 -04:00
Tim Pope
58d2b25836 Use git --list-cmds= to complete subcommands
For older Git versions, use the list of subcommands from when
--list-cmds= was first added, and subtract out "worktree" for Git
versions too old to have it.  This one simple conditional gives us
accurate completion for Git versions up to a decade old.

The option is described as "internal/experimental", so make sure the
exit status is successful, and filter out anything that looks like a
warning or deprecation notice.  In case of failure, use the commands
provided by --list-cmds= as of the date of this commit.

Closes https://github.com/tpope/vim-fugitive/pull/1629
2021-03-21 10:13:42 -04:00
Tim Pope
1999aef8cd Retool completion of subcommands
Support configured completion commands and aliases using our cached
config helpers, and support --exec-path and $PATH git-* executables by
globbing once and caching indefinitely.

References https://github.com/tpope/vim-fugitive/pull/1629
2021-03-21 10:13:42 -04:00