Граф коммитов

147002 Коммитов

Автор SHA1 Сообщение Дата
Johannes Schindelin 01906db2ef backwards-compatibility: support the post-indexchanged hook
When our patches to support that hook were upstreamed, the hook's name
was eliciting some reviewer suggestions, and it was renamed to
`post-index-change`. These patches (with the new name) made it into
v2.22.0.

However, VFSforGit users may very well have checkouts with that hook
installed under the original name.

To support this, let's just introduce a hack where we look a bit more
closely when we just failed to find the `post-index-change` hook, and
allow any `post-indexchanged` hook to run instead (if it exists).
2023-06-01 10:53:50 -07:00
Jameson Miller 69b804a902 vfs: fix case where directories not handled correctly
The vfs does not correctly handle the case when there is a file
that begins with the same prefix as a directory. For example, the
following setup would encounter this issue:

    A directory contains a file named `dir1.sln` and a directory
    named `dir1/`.

    The directory `dir1` contains other files.

    The directory `dir1` is in the virtual file system list

The contents of `dir1` should be in the virtual file system, but
it is not. The contents of this directory do not have the skip
worktree bit cleared as expected. The problem is in the
`apply_virtualfilesystem(...)` function where it does not include
the trailing slash of the directory name when looking up the
position in the index to start clearing the skip worktree bit.

This fix is it include the trailing slash when finding the first
index entry from `index_name_pos(...)`.
2023-06-01 10:53:50 -07:00
Kevin Willford 46474e0d4e virtualfilesystem: check if directory is included
Add check to see if a directory is included in the virtualfilesystem
before checking the directory hashmap.  This allows a directory entry
like foo/ to find all untracked files in subdirectories.
2023-06-01 10:53:50 -07:00
Ben Peart 4a47515e37 virtualfilesystem: fix bug with symlinks being ignored
The virtual file system code incorrectly treated symlinks as directories
instead of regular files.  This meant symlinks were not included even if
they are listed in the list of files returned by the core.virtualFilesystem
hook proc.  Fixes #25

Signed-off-by: Ben Peart <Ben.Peart@microsoft.com>
2023-06-01 10:53:50 -07:00
Ben Peart eb185b886a virtualfilesystem: don't run the virtual file system hook if the index has been redirected
Fixes #13

Some git commands spawn helpers and redirect the index to a different
location.  These include "difftool -d" and the sequencer
(i.e. `git rebase -i`, `git cherry-pick` and `git revert`) and others.
In those instances we don't want to update their temporary index with
our virtualization data.

Helped-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Ben Peart <Ben.Peart@microsoft.com>
2023-06-01 10:53:50 -07:00
Ben Peart 44d5d29600 Add virtual file system settings and hook proc
On index load, clear/set the skip worktree bits based on the virtual
file system data. Use virtual file system data to update skip-worktree
bit in unpack-trees. Use virtual file system data to exclude files and
folders not explicitly requested.

Update 2022-04-05: disable the "present-despite-SKIP_WORKTREE" file removal
behavior when 'core.virtualfilesystem' is enabled.

Signed-off-by: Ben Peart <benpeart@microsoft.com>
2023-06-01 10:53:50 -07:00
Kevin Willford 907058a104 BRANCHES.md: Add explanation of branches and using forks 2023-06-01 10:53:50 -07:00
Derrick Stolee 1d63b4ad65 gvfs: allow overriding core.gvfs
We found a user who had set "core.gvfs = false" in their global
config. This should not have been necessary, but it also should not
have caused a problem. However, it did.

The reason is that gvfs_load_config_value() is called from config.c
when reading config key/value pairs from all the config files. The
local config should override the global config, and this is done by
config.c reading the global config first then reading the local
config. However, our logic only allowed writing the core_gvfs
variable once.

Put the guards against multiple assignments of core_gvfs into
gvfs_config_is_set() instead, because that will fix the problem
_and_ keep multiple calls to gvfs_config_is_set() from slowing down.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
2023-06-01 10:53:49 -07:00
Derrick Stolee 131672d42e worktree: allow in Scalar repositories
The 'git worktree' command was marked as BLOCK_ON_GVFS_REPO because it
does not interact well with the virtual filesystem of VFS for Git. When
a Scalar clone uses the GVFS protocol, it enables the
GVFS_BLOCK_COMMANDS flag, since commands like 'git gc' do not work well
with the GVFS protocol.

However, 'git worktree' works just fine with the GVFS protocol since it
isn't doing anything special. It copies the sparse-checkout from the
current worktree, so it does not have performance issues.

This is a highly requested option.

The solution is to stop using the BLOCK_ON_GVFS_REPO option and instead
add a special-case check in cmd_worktree() specifically for a particular
bit of the 'core_gvfs' global variable (loaded by very early config
reading) that corresponds to the virtual filesystem. The bit that most
closely resembled this behavior was non-obviously named, but does
provide a signal that we are in a Scalar clone and not a VFS for Git
clone. The error message is copied from git.c, so it will have the same
output as before if a user runs this in a VFS for Git clone.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
2023-06-01 10:53:49 -07:00
Ben Peart c1cfc3dd39 gvfs: block unsupported commands when running in a GVFS repo
The following commands and options are not currently supported when working
in a GVFS repo.  Add code to detect and block these commands from executing.

1) fsck
2) gc
4) prune
5) repack
6) submodule
8) update-index --split-index
9) update-index --index-version (other than 4)
10) update-index --[no-]skip-worktree
11) worktree

Signed-off-by: Ben Peart <benpeart@microsoft.com>
2023-06-01 10:53:49 -07:00
Kevin Willford 9caa878e82 cache-tree: remove use of strbuf_addf in update_one
String formatting can be a performance issue when there are
hundreds of thousands of trees.

Change to stop using the strbuf_addf and just add the strings
or characters individually.

There are a limited number of modes so added a switch for the
known ones and a default case if something comes through that
are not a known one for git.

In one scenario regarding a huge worktree, this reduces the
time required for a `git checkout <branch>` from 44 seconds
to 38 seconds, i.e. it is a non-negligible performance
improvement.

Signed-off-by: Kevin Willford <kewillf@microsoft.com>
2023-06-01 10:53:49 -07:00
Kevin Willford b4544dcbb0 send-pack: do not check for sha1 file when GVFS_MISSING_OK set 2023-06-01 10:53:49 -07:00
Kevin Willford 6e8736a029 gvfs: refactor loading the core.gvfs config value
This code change makes sure that the config value for core_gvfs
is always loaded before checking it.

Signed-off-by: Kevin Willford <kewillf@microsoft.com>
2023-06-01 10:53:49 -07:00
Kevin Willford 2f5d8853e5 Do not remove files outside the sparse-checkout
Signed-off-by: Kevin Willford <kewillf@microsoft.com>
2023-06-01 10:53:49 -07:00
Kevin Willford 8348e6eed4 sparse-checkout: avoid writing entries with the skip-worktree bit
When using the sparse-checkout feature git should not write to the working
directory for files with the skip-worktree bit on.  With the skip-worktree
bit on the file may or may not be in the working directory and if it is
not we don't want or need to create it by calling checkout_entry.

There are two callers of checkout_target.  Both of which check that the
file does not exist before calling checkout_target.  load_current which
make a call to lstat right before calling checkout_target and
check_preimage which will only run checkout_taret it stat_ret is less than
zero.  It sets stat_ret to zero and only if !stat->cached will it lstat
the file and set stat_ret to something other than zero.

This patch checks if skip-worktree bit is on in checkout_target and just
returns so that the entry doesn't not end up in the working directory.
This is so that apply will not create a file in the working directory,
then update the index but not keep the working directory up to date with
the changes that happened in the index.

Signed-off-by: Kevin Willford <kewillf@microsoft.com>
2023-06-01 10:53:49 -07:00
Kevin Willford 95d1f0a146 sparse-checkout: update files with a modify/delete conflict
When using the sparse-checkout feature, the file might not be on disk
because the skip-worktree bit is on.

Signed-off-by: Kevin Willford <kewillf@microsoft.com>
2023-06-01 10:53:49 -07:00
Johannes Schindelin de68b1159c pre-command: always respect core.hooksPath
We need to respect that config setting even if we already know that we
have a repository, but have not yet read the config.

The regression test was written by Alejandro Pauly.

2021-10-30: Recent movement of find_hook() into hook.c required moving this
change from run-command.c.

Signed-off-by: Johannes Schindelin <johasc@microsoft.com>
2023-06-01 10:53:49 -07:00
Alejandro Pauly 50188158b8 Pass PID of git process to hooks.
Signed-off-by: Alejandro Pauly <alpauly@microsoft.com>
2023-06-01 10:53:49 -07:00
Johannes Schindelin b2cac1b72a t0400: verify that the hook is called correctly from a subdirectory
Suggested by Ben Peart.

Signed-off-by: Johannes Schindelin <johasc@microsoft.com>
2023-06-01 10:53:49 -07:00
Ben Peart 303b4792ec gvfs: add global command pre and post hook procs
This adds hard-coded call to GVFS.hooks.exe before and after each Git
command runs.

To make sure that this is only called on repositories cloned with GVFS, we
test for the tell-tale .gvfs.

2021-10-30: Recent movement of find_hook() to hook.c required moving these
changes out of run-command.c to hook.c.

Signed-off-by: Ben Peart <Ben.Peart@microsoft.com>
2023-06-01 10:53:49 -07:00
Johannes Schindelin 51126c63d9 sha1_file: when writing objects, skip the read_object_hook
If we are going to write an object there is no use in calling
the read object hook to get an object from a potentially remote
source.  We would rather just write out the object and avoid the
potential round trip for an object that doesn't exist.

This change adds a flag to the check_and_freshen() and
freshen_loose_object() functions' signatures so that the hook
is bypassed when the functions are called before writing loose
objects. The check for a local object is still performed so we
don't overwrite something that has already been written to one
of the objects directories.

Based on a patch by Kevin Willford.

Signed-off-by: Johannes Schindelin <johasc@microsoft.com>
2023-06-01 10:53:49 -07:00
Ben Peart df0309baaa Hydrate missing loose objects in check_and_freshen()
Hydrate missing loose objects in check_and_freshen() when running
virtualized. Add test cases to verify read-object hook works when
running virtualized.

This hook is called in check_and_freshen() rather than
check_and_freshen_local() to make the hook work also with alternates.

Helped-by: Kevin Willford <kewillf@microsoft.com>
Signed-off-by: Ben Peart <Ben.Peart@microsoft.com>
2023-06-01 10:53:49 -07:00
Ben Peart 4d6aa2f1b3 gvfs: allow "virtualizing" objects
The idea is to allow blob objects to be missing from the local repository,
and to load them lazily on demand.

After discussing this idea on the mailing list, we will rename the feature
to "lazy clone" and work more on this.

Signed-off-by: Ben Peart <Ben.Peart@microsoft.com>
2023-06-01 10:53:49 -07:00
Ben Peart b31415b99f gvfs: ensure all filters and EOL conversions are blocked
Ensure all filters and EOL conversions are blocked when running under
GVFS so that our projected file sizes will match the actual file size
when it is hydrated on the local machine.

Signed-off-by: Ben Peart <Ben.Peart@microsoft.com>
2023-06-01 10:53:49 -07:00
Kevin Willford e3cf5545e0 gvfs: optionally skip reachability checks/upload pack during fetch
While performing a fetch with a virtual file system we know that there
will be missing objects and we don't want to download them just because
of the reachability of the commits.  We also don't want to download a
pack file with commits, trees, and blobs since these will be downloaded
on demand.

This flag will skip the first connectivity check and by returning zero
will skip the upload pack. It will also skip the second connectivity
check but continue to update the branches to the latest commit ids.

Signed-off-by: Kevin Willford <kewillf@microsoft.com>
2023-06-01 10:53:49 -07:00
Kevin Willford 29bd7171e1 gvfs: prevent files to be deleted outside the sparse checkout
Prevent the sparse checkout to delete files that were marked with
skip-worktree bit and are not in the sparse-checkout file.

This is because everything with the skip-worktree bit turned on is being
virtualized and will be removed with the change of HEAD.

There was only one failing test when running with these changes that was
checking to make sure the worktree narrows on checkout which was
expected since we would no longer be narrowing the worktree.

Update 2022-04-05: temporarily set 'sparse.expectfilesoutsideofpatterns' in
test (until we start disabling the "remove present-despite-SKIP_WORKTREE"
behavior with 'core.virtualfilesystem' in a later commit).

Signed-off-by: Kevin Willford <kewillf@microsoft.com>
2023-06-01 10:53:49 -07:00
Kevin Willford 6f299dff2f gvfs: add the feature that blobs may be missing
Signed-off-by: Kevin Willford <kewillf@microsoft.com>
2023-06-01 10:53:49 -07:00
Kevin Willford 276f14289d gvfs: add the feature to skip writing the index' SHA-1
This takes a substantial amount of time, and if the user is reasonably
sure that the files' integrity is not compromised, that time can be saved.

Git no longer verifies the SHA-1 by default, anyway.

Signed-off-by: Kevin Willford <kewillf@microsoft.com>

Update for 2023-02-27: This feature was upstreamed as the index.skipHash
config option. This resulted in some changes to the struct and some of
the setup code. In particular, the config reading was moved to
prepare_repo_settings(), so the core.gvfs bit check was moved there,
too.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
2023-06-01 10:53:49 -07:00
Kevin Willford 8d57c9e44b gvfs: add the core.gvfs config setting
This does not do anything yet. The next patches will add various values
for that config setting that correspond to the various features
offered/required by GVFS.

Signed-off-by: Kevin Willford <kewillf@microsoft.com>
2023-06-01 10:53:48 -07:00
Kevin Willford 53cfcd99b9 gvfs: add a GVFS-specific header file
This header file will accumulate GVFS-specific definitions.

Signed-off-by: Kevin Willford <kewillf@microsoft.com>
2023-06-01 10:53:48 -07:00
Johannes Schindelin 5f594f4356 gvfs: ensure that the version is based on a GVFS tag
Since we really want to be based on a `.vfs.*` tag, let's make sure that
there was a new-enough one, i.e. one that agrees with the first three
version numbers of the recorded default version.

This prevents e.g. v2.22.0.vfs.0.<some-huge-number>.<commit> from being
used when the current release train was not yet tagged.

It is important to get the first three numbers of the version right
because e.g. Scalar makes decisions depending on those (such as assuming
that the `git maintenance` built-in is not available, even though it
actually _is_ available).

Signed-off-by: Johannes Schindelin <johasc@microsoft.com>
2023-06-01 10:53:48 -07:00
Saeed Noursalehi 522afbd610 gvfs: start by adding the -gvfs suffix to the version
Signed-off-by: Saeed Noursalehi <sanoursa@microsoft.com>
2023-06-01 10:53:47 -07:00
Kevin Willford ecce78e057 reset --stdin: trim carriage return from the paths
While using the reset --stdin feature on windows path added may have a
\r at the end of the path that wasn't getting removed so didn't match
the path in the index and wasn't reset.

Signed-off-by: Kevin Willford <kewillf@microsoft.com>
2023-06-01 10:53:16 -07:00
Johannes Schindelin ff94e79c47 Merge 'readme' into HEAD
Add a README.md for GitHub goodness.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2023-06-01 10:14:49 -06:00
Johannes Schindelin 6e19a47450 Merge pull request #2837 from dscho/monitor-component-updates
Start monitoring updates of Git for Windows' component in the open
2023-06-01 10:14:49 -06:00
Johannes Schindelin e663f99e0f Merge branch 'deprecate-core.useBuiltinFSMonitor'
Originally introduced as `core.useBuiltinFSMonitor` in Git for Windows
and developed, improved and stabilized there, the built-in FSMonitor
only made it into upstream Git (after unnecessarily long hemming and
hawing and throwing overly perfectionist style review sticks into the
spokes) as `core.fsmonitor = true`.

In Git for Windows, with this topic branch, we re-introduce the
now-obsolete config setting, with warnings suggesting to existing users
how to switch to the new config setting, with the intention to
ultimately drop the patch at some stage.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2023-06-01 10:14:49 -06:00
Johannes Schindelin 2f9e50bd32 Merge branch 'phase-out-reset-stdin'
This topic branch re-adds the deprecated --stdin/-z options to `git
reset`. Those patches were overridden by a different set of options in
the upstream Git project before we could propose `--stdin`.

We offered this in MinGit to applications that wanted a safer way to
pass lots of pathspecs to Git, and these applications will need to be
adjusted.

Instead of `--stdin`, `--pathspec-from-file=-` should be used, and
instead of `-z`, `--pathspec-file-nul`.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2023-06-01 10:14:48 -06:00
Johannes Schindelin ebe26f4648 Merge branch 'un-revert-editor-save-and-reset'
A fix for calling `vim` in Windows Terminal caused a regression and was
reverted. We partially un-revert this, to get the fix again.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2023-06-01 10:14:48 -06:00
Victoria Dye a9f4d513b9 Merge pull request #3492 from dscho/ns/batched-fsync
Switch to batched fsync by default
2023-06-01 10:14:48 -06:00
Johannes Schindelin 4df560e2de Merge pull request #1170 from dscho/mingw-kill-process
Handle Ctrl+C in Git Bash nicely

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2023-06-01 10:14:48 -06:00
Johannes Schindelin 4ca4c0bf81 Merge branch 'busybox-w32'
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2023-06-01 10:14:47 -06:00
Johannes Schindelin 52633bff6d Merge pull request #1897 from piscisaureus/symlink-attr
Specify symlink type in .gitattributes
2023-06-01 10:14:47 -06:00
Johannes Schindelin 3b7241b7f5 Merge 'docker-volumes-are-no-symlinks'
This was pull request #1645 from ZCube/master

Support windows container.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2023-06-01 10:14:47 -06:00
Johannes Schindelin 1e3a63a00a Merge branch 'kblees/kb/symlinks' 2023-06-01 10:14:46 -06:00
Johannes Schindelin e4a50792e2 Merge branch 'msys2' 2023-06-01 10:14:46 -06:00
Johannes Schindelin fb34ca869c Merge pull request #3817 from mathstuf/name-too-long-advice
clean: suggest using `core.longPaths` if paths are too long to remove
2023-06-01 10:14:46 -06:00
Jeff Hostetler ccb4ced834 Merge branch 'fix-v4-fsmonitor-long-paths' into try-v4-fsmonitor 2023-06-01 10:14:46 -06:00
Johannes Schindelin 59f405a2af Merge branch 'long-paths' 2023-06-01 10:14:46 -06:00
Johannes Schindelin 20a9e188cc SECURITY.md: document Git for Windows' policies
This is the recommended way on GitHub to describe policies revolving around
security issues and about supported versions.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2023-06-01 10:14:45 -06:00
Johannes Schindelin a2ec179c6f Merge branch 'gitk-and-git-gui-patches'
These are Git for Windows' Git GUI and gitk patches. We will have to
decide at some point what to do about them, but that's a little lower
priority (as Git GUI seems to be unmaintained for the time being, and
the gitk maintainer keeps a very low profile on the Git mailing list,
too).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2023-06-01 10:14:45 -06:00