Skip to content

Commit 3153537

Browse files
dschoderrickstolee
authored andcommitted
Merge advanced VFS-specific features
Most of these were done in private before microsoft/git. However, the following pull requests modified the core feature: git-for-windows#85 git-for-windows#89 git-for-windows#91 git-for-windows#98 git-for-windows#243 git-for-windows#263 Signed-off-by: Derrick Stolee <[email protected]>
2 parents ca327cf + 7efb232 commit 3153537

20 files changed

+574
-42
lines changed

BRANCHES.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
Branches used in this repo
2+
==========================
3+
4+
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.
5+
6+
Repo Branches
7+
-------------
8+
9+
1. `vfs-#`
10+
11+
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.
12+
13+
#### Examples
14+
15+
```
16+
vfs-2.27.0
17+
vfs-2.30.0
18+
```
19+
20+
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.
21+
22+
2. `vfs-#-exp`
23+
24+
These branches are for releasing experimental features to early adopters. They
25+
should contain everything within the corresponding `vfs-#` branch; if the base
26+
branch updates, then merge into the `vfs-#-exp` branch as well.
27+
28+
Tags
29+
----
30+
31+
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.
32+
33+
Full releases are of the form `v2.XX.Y.vfs.Z.W` where `v2.XX.Y` comes from the
34+
upstream version and `Z.W` are custom updates within our fork. Specifically,
35+
the `.Z` value represents the "compatibility level" with VFS for Git. Only
36+
increase this version when making a breaking change with a released version
37+
of VFS for Git. The `.W` version is used for minor updates between major
38+
versions.
39+
40+
Experimental releases are of the form `v2.XX.Y.vfs.Z.W.exp`. The `.exp`
41+
suffix indicates that experimental features are available. The rest of the
42+
version string comes from the full release tag. These versions will only
43+
be made available as pre-releases on the releases page, never a full release.
44+
45+
Forking
46+
-------
47+
48+
A personal fork of this repository and a branch in that repository should be used for development.
49+
50+
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.
51+
52+
#### Example
53+
54+
```
55+
git clone <personal fork repo URL>
56+
git remote add ms https://github.com/Microsoft/git.git
57+
git checkout -b my-changes ms/vfs-2.20.0 --no-track
58+
git push -fu origin HEAD
59+
```

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,7 @@ LIB_OBJS += gettext.o
920920
LIB_OBJS += gpg-interface.o
921921
LIB_OBJS += graph.o
922922
LIB_OBJS += grep.o
923+
LIB_OBJS += gvfs.o
923924
LIB_OBJS += hash-lookup.o
924925
LIB_OBJS += hashmap.o
925926
LIB_OBJS += help.o

apply.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3345,6 +3345,24 @@ static int checkout_target(struct index_state *istate,
33453345
{
33463346
struct checkout costate = CHECKOUT_INIT;
33473347

3348+
/*
3349+
* Do not checkout the entry if the skipworktree bit is set
3350+
*
3351+
* Both callers of this method (check_preimage and load_current)
3352+
* check for the existance of the file before calling this
3353+
* method so we know that the file doesn't exist at this point
3354+
* and we don't need to perform that check again here.
3355+
* We just need to check the skip-worktree and return.
3356+
*
3357+
* This is to prevent git from creating a file in the
3358+
* working directory that has the skip-worktree bit on,
3359+
* then updating the index from the patch and not keeping
3360+
* the working directory version up to date with what it
3361+
* changed the index version to be.
3362+
*/
3363+
if (ce_skip_worktree(ce))
3364+
return 0;
3365+
33483366
costate.refresh_cache = 1;
33493367
costate.istate = istate;
33503368
if (checkout_entry(ce, &costate, NULL, NULL) ||

builtin/gc.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include "builtin.h"
1414
#include "repository.h"
15+
#include "gvfs.h"
1516
#include "config.h"
1617
#include "tempfile.h"
1718
#include "lockfile.h"
@@ -596,6 +597,9 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
596597
if (quiet)
597598
strvec_push(&repack, "-q");
598599

600+
if ((!auto_gc || (auto_gc && gc_auto_threshold > 0)) && gvfs_config_is_set(GVFS_BLOCK_COMMANDS))
601+
die(_("'git gc' is not supported on a GVFS repo"));
602+
599603
if (auto_gc) {
600604
/*
601605
* Auto-gc should be least intrusive as possible.

builtin/reset.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#include "submodule-config.h"
2828
#include "strbuf.h"
2929
#include "quote.h"
30+
#include "dir.h"
31+
#include "entry.h"
3032

3133
#define REFRESH_INDEX_DELAY_WARNING_IN_MS (2 * 1000)
3234

@@ -130,12 +132,45 @@ static void update_index_from_diff(struct diff_queue_struct *q,
130132
struct diff_options *opt, void *data)
131133
{
132134
int i;
135+
int pos;
133136
int intent_to_add = *(int *)data;
134137

135138
for (i = 0; i < q->nr; i++) {
136139
struct diff_filespec *one = q->queue[i]->one;
140+
struct diff_filespec *two = q->queue[i]->two;
137141
int is_missing = !(one->mode && !is_null_oid(&one->oid));
142+
int was_missing = !two->mode && is_null_oid(&two->oid);
138143
struct cache_entry *ce;
144+
struct cache_entry *ceBefore;
145+
struct checkout state = CHECKOUT_INIT;
146+
147+
/*
148+
* When using the sparse-checkout feature the cache entries that are
149+
* added here will not have the skip-worktree bit set.
150+
* Without this code there is data that is lost because the files that
151+
* would normally be in the working directory are not there and show as
152+
* deleted for the next status or in the case of added files just disappear.
153+
* We need to create the previous version of the files in the working
154+
* directory so that they will have the right content and the next
155+
* status call will show modified or untracked files correctly.
156+
*/
157+
if (core_apply_sparse_checkout && !file_exists(two->path))
158+
{
159+
pos = cache_name_pos(two->path, strlen(two->path));
160+
if ((pos >= 0 && ce_skip_worktree(active_cache[pos])) && (is_missing || !was_missing))
161+
{
162+
state.force = 1;
163+
state.refresh_cache = 1;
164+
state.istate = &the_index;
165+
ceBefore = make_cache_entry(&the_index, two->mode, &two->oid, two->path,
166+
0, 0);
167+
if (!ceBefore)
168+
die(_("make_cache_entry failed for path '%s'"),
169+
two->path);
170+
171+
checkout_entry(ceBefore, &state, NULL, NULL);
172+
}
173+
}
139174

140175
if (is_missing && !intent_to_add) {
141176
remove_file_from_cache(one->path);

builtin/update-index.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
#define USE_THE_INDEX_COMPATIBILITY_MACROS
77
#include "cache.h"
8+
#include "gvfs.h"
89
#include "config.h"
910
#include "lockfile.h"
1011
#include "quote.h"
@@ -1135,7 +1136,13 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
11351136
argc = parse_options_end(&ctx);
11361137

11371138
getline_fn = nul_term_line ? strbuf_getline_nul : strbuf_getline_lf;
1139+
if (mark_skip_worktree_only && gvfs_config_is_set(GVFS_BLOCK_COMMANDS))
1140+
die(_("modifying the skip worktree bit is not supported on a GVFS repo"));
1141+
11381142
if (preferred_index_format) {
1143+
if (preferred_index_format != 4 && gvfs_config_is_set(GVFS_BLOCK_COMMANDS))
1144+
die(_("changing the index version is not supported on a GVFS repo"));
1145+
11391146
if (preferred_index_format < INDEX_FORMAT_LB ||
11401147
INDEX_FORMAT_UB < preferred_index_format)
11411148
die("index-version %d not in range: %d..%d",
@@ -1171,6 +1178,9 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
11711178
}
11721179

11731180
if (split_index > 0) {
1181+
if (gvfs_config_is_set(GVFS_BLOCK_COMMANDS))
1182+
die(_("split index is not supported on a GVFS repo"));
1183+
11741184
if (git_config_get_split_index() == 0)
11751185
warning(_("core.splitIndex is set to false; "
11761186
"remove or change it, if you really want to "

cache-tree.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,29 @@ static int update_one(struct cache_tree *it,
422422
continue;
423423

424424
strbuf_grow(&buffer, entlen + 100);
425-
strbuf_addf(&buffer, "%o %.*s%c", mode, entlen, path + baselen, '\0');
425+
426+
switch (mode) {
427+
case 0100644:
428+
strbuf_add(&buffer, "100644 ", 7);
429+
break;
430+
case 0100664:
431+
strbuf_add(&buffer, "100664 ", 7);
432+
break;
433+
case 0100755:
434+
strbuf_add(&buffer, "100755 ", 7);
435+
break;
436+
case 0120000:
437+
strbuf_add(&buffer, "120000 ", 7);
438+
break;
439+
case 0160000:
440+
strbuf_add(&buffer, "160000 ", 7);
441+
break;
442+
default:
443+
strbuf_addf(&buffer, "%o ", mode);
444+
break;
445+
}
446+
strbuf_add(&buffer, path + baselen, entlen);
447+
strbuf_addch(&buffer, '\0');
426448
strbuf_add(&buffer, oid->hash, the_hash_algo->rawsz);
427449

428450
#if DEBUG_CACHE_TREE

0 commit comments

Comments
 (0)