Commit Graph
100 Commits
Author SHA1 Message Date
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
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
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
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