Skip to content

Commit

Permalink
Merge advanced VFS-specific features
Browse files Browse the repository at this point in the history
Most of these were done in private before microsoft/git. However,
the following pull requests modified the core feature:

	msysgit#85
	msysgit#89
	msysgit#91
	msysgit#98
	msysgit#243
	msysgit#263

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
  • Loading branch information
dscho authored and derrickstolee committed May 28, 2021
2 parents e27099e + de74859 commit cbddb33
Show file tree
Hide file tree
Showing 20 changed files with 574 additions and 42 deletions.
59 changes: 59 additions & 0 deletions BRANCHES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
Branches used in this repo
==========================

The document explains the branching structure that we are using in the VFSForGit repository as well as the forking strategy that we have adopted for contributing.

Repo Branches
-------------

1. `vfs-#`

These branches are used to track the specific version that match Git for Windows with the VFSForGit specific patches on top. When a new version of Git for Windows is released, the VFSForGit patches will be rebased on that windows version and a new gvfs-# branch created to create pull requests against.

#### Examples

```
vfs-2.27.0
vfs-2.30.0
```

The versions of git for VFSForGit are based on the Git for Windows versions. v2.20.0.vfs.1 will correspond with the v2.20.0.windows.1 with the VFSForGit specific patches applied to the windows version.

2. `vfs-#-exp`

These branches are for releasing experimental features to early adopters. They
should contain everything within the corresponding `vfs-#` branch; if the base
branch updates, then merge into the `vfs-#-exp` branch as well.

Tags
----

We are using annotated tags to build the version number for git. The build will look back through the commit history to find the first tag matching `v[0-9]*vfs*` and build the git version number using that tag.

Full releases are of the form `v2.XX.Y.vfs.Z.W` where `v2.XX.Y` comes from the
upstream version and `Z.W` are custom updates within our fork. Specifically,
the `.Z` value represents the "compatibility level" with VFS for Git. Only
increase this version when making a breaking change with a released version
of VFS for Git. The `.W` version is used for minor updates between major
versions.

Experimental releases are of the form `v2.XX.Y.vfs.Z.W.exp`. The `.exp`
suffix indicates that experimental features are available. The rest of the
version string comes from the full release tag. These versions will only
be made available as pre-releases on the releases page, never a full release.

Forking
-------

A personal fork of this repository and a branch in that repository should be used for development.

These branches should be based on the latest vfs-# branch. If there are work in progress pull requests that you have based on a previous version branch when a new version branch is created, you will need to move your patches to the new branch to get them in that latest version.

#### Example

```
git clone <personal fork repo URL>
git remote add ms https://github.com/Microsoft/git.git
git checkout -b my-changes ms/vfs-2.20.0 --no-track
git push -fu origin HEAD
```
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,7 @@ LIB_OBJS += gettext.o
LIB_OBJS += gpg-interface.o
LIB_OBJS += graph.o
LIB_OBJS += grep.o
LIB_OBJS += gvfs.o
LIB_OBJS += hash-lookup.o
LIB_OBJS += hashmap.o
LIB_OBJS += help.o
Expand Down
18 changes: 18 additions & 0 deletions apply.c
Original file line number Diff line number Diff line change
Expand Up @@ -3345,6 +3345,24 @@ static int checkout_target(struct index_state *istate,
{
struct checkout costate = CHECKOUT_INIT;

/*
* Do not checkout the entry if the skipworktree bit is set
*
* Both callers of this method (check_preimage and load_current)
* check for the existance of the file before calling this
* method so we know that the file doesn't exist at this point
* and we don't need to perform that check again here.
* We just need to check the skip-worktree and return.
*
* This is to prevent git from creating a file in the
* working directory that has the skip-worktree bit on,
* then updating the index from the patch and not keeping
* the working directory version up to date with what it
* changed the index version to be.
*/
if (ce_skip_worktree(ce))
return 0;

costate.refresh_cache = 1;
costate.istate = istate;
if (checkout_entry(ce, &costate, NULL, NULL) ||
Expand Down
4 changes: 4 additions & 0 deletions builtin/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "builtin.h"
#include "repository.h"
#include "gvfs.h"
#include "config.h"
#include "tempfile.h"
#include "lockfile.h"
Expand Down Expand Up @@ -596,6 +597,9 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
if (quiet)
strvec_push(&repack, "-q");

if ((!auto_gc || (auto_gc && gc_auto_threshold > 0)) && gvfs_config_is_set(GVFS_BLOCK_COMMANDS))
die(_("'git gc' is not supported on a GVFS repo"));

if (auto_gc) {
/*
* Auto-gc should be least intrusive as possible.
Expand Down
35 changes: 35 additions & 0 deletions builtin/reset.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include "submodule-config.h"
#include "strbuf.h"
#include "quote.h"
#include "dir.h"
#include "entry.h"

#define REFRESH_INDEX_DELAY_WARNING_IN_MS (2 * 1000)

Expand Down Expand Up @@ -130,12 +132,45 @@ static void update_index_from_diff(struct diff_queue_struct *q,
struct diff_options *opt, void *data)
{
int i;
int pos;
int intent_to_add = *(int *)data;

for (i = 0; i < q->nr; i++) {
struct diff_filespec *one = q->queue[i]->one;
struct diff_filespec *two = q->queue[i]->two;
int is_missing = !(one->mode && !is_null_oid(&one->oid));
int was_missing = !two->mode && is_null_oid(&two->oid);
struct cache_entry *ce;
struct cache_entry *ceBefore;
struct checkout state = CHECKOUT_INIT;

/*
* When using the sparse-checkout feature the cache entries that are
* added here will not have the skip-worktree bit set.
* Without this code there is data that is lost because the files that
* would normally be in the working directory are not there and show as
* deleted for the next status or in the case of added files just disappear.
* We need to create the previous version of the files in the working
* directory so that they will have the right content and the next
* status call will show modified or untracked files correctly.
*/
if (core_apply_sparse_checkout && !file_exists(two->path))
{
pos = cache_name_pos(two->path, strlen(two->path));
if ((pos >= 0 && ce_skip_worktree(active_cache[pos])) && (is_missing || !was_missing))
{
state.force = 1;
state.refresh_cache = 1;
state.istate = &the_index;
ceBefore = make_cache_entry(&the_index, two->mode, &two->oid, two->path,
0, 0);
if (!ceBefore)
die(_("make_cache_entry failed for path '%s'"),
two->path);

checkout_entry(ceBefore, &state, NULL, NULL);
}
}

if (is_missing && !intent_to_add) {
remove_file_from_cache(one->path);
Expand Down
10 changes: 10 additions & 0 deletions builtin/update-index.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "gvfs.h"
#include "config.h"
#include "lockfile.h"
#include "quote.h"
Expand Down Expand Up @@ -1135,7 +1136,13 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
argc = parse_options_end(&ctx);

getline_fn = nul_term_line ? strbuf_getline_nul : strbuf_getline_lf;
if (mark_skip_worktree_only && gvfs_config_is_set(GVFS_BLOCK_COMMANDS))
die(_("modifying the skip worktree bit is not supported on a GVFS repo"));

if (preferred_index_format) {
if (preferred_index_format != 4 && gvfs_config_is_set(GVFS_BLOCK_COMMANDS))
die(_("changing the index version is not supported on a GVFS repo"));

if (preferred_index_format < INDEX_FORMAT_LB ||
INDEX_FORMAT_UB < preferred_index_format)
die("index-version %d not in range: %d..%d",
Expand Down Expand Up @@ -1171,6 +1178,9 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
}

if (split_index > 0) {
if (gvfs_config_is_set(GVFS_BLOCK_COMMANDS))
die(_("split index is not supported on a GVFS repo"));

if (git_config_get_split_index() == 0)
warning(_("core.splitIndex is set to false; "
"remove or change it, if you really want to "
Expand Down
24 changes: 23 additions & 1 deletion cache-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,29 @@ static int update_one(struct cache_tree *it,
continue;

strbuf_grow(&buffer, entlen + 100);
strbuf_addf(&buffer, "%o %.*s%c", mode, entlen, path + baselen, '\0');

switch (mode) {
case 0100644:
strbuf_add(&buffer, "100644 ", 7);
break;
case 0100664:
strbuf_add(&buffer, "100664 ", 7);
break;
case 0100755:
strbuf_add(&buffer, "100755 ", 7);
break;
case 0120000:
strbuf_add(&buffer, "120000 ", 7);
break;
case 0160000:
strbuf_add(&buffer, "160000 ", 7);
break;
default:
strbuf_addf(&buffer, "%o ", mode);
break;
}
strbuf_add(&buffer, path + baselen, entlen);
strbuf_addch(&buffer, '\0');
strbuf_add(&buffer, oid->hash, the_hash_algo->rawsz);

#if DEBUG_CACHE_TREE
Expand Down
Loading

0 comments on commit cbddb33

Please sign in to comment.