Skip to content

Commit 025dfe9

Browse files
dschojeffhostetler
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 e6f08d3 + 3cef161 commit 025dfe9

22 files changed

+599
-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
@@ -896,6 +896,7 @@ LIB_OBJS += gettext.o
896896
LIB_OBJS += gpg-interface.o
897897
LIB_OBJS += graph.o
898898
LIB_OBJS += grep.o
899+
LIB_OBJS += gvfs.o
899900
LIB_OBJS += hash-lookup.o
900901
LIB_OBJS += hashmap.o
901902
LIB_OBJS += help.o

apply.c

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

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

builtin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix);
228228
int cmd_tar_tree(int argc, const char **argv, const char *prefix);
229229
int cmd_unpack_file(int argc, const char **argv, const char *prefix);
230230
int cmd_unpack_objects(int argc, const char **argv, const char *prefix);
231+
int cmd_update(int argc, const char **argv, const char *prefix);
231232
int cmd_update_index(int argc, const char **argv, const char *prefix);
232233
int cmd_update_ref(int argc, const char **argv, const char *prefix);
233234
int cmd_update_server_info(int argc, const char **argv, const char *prefix);

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: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "submodule-config.h"
2828
#include "strbuf.h"
2929
#include "quote.h"
30+
#include "dir.h"
3031

3132
#define REFRESH_INDEX_DELAY_WARNING_IN_MS (2 * 1000)
3233

@@ -130,12 +131,45 @@ static void update_index_from_diff(struct diff_queue_struct *q,
130131
struct diff_options *opt, void *data)
131132
{
132133
int i;
134+
int pos;
133135
int intent_to_add = *(int *)data;
134136

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

140174
if (is_missing && !intent_to_add) {
141175
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"
@@ -1133,7 +1134,13 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
11331134
argc = parse_options_end(&ctx);
11341135

11351136
getline_fn = nul_term_line ? strbuf_getline_nul : strbuf_getline_lf;
1137+
if (mark_skip_worktree_only && gvfs_config_is_set(GVFS_BLOCK_COMMANDS))
1138+
die(_("modifying the skip worktree bit is not supported on a GVFS repo"));
1139+
11361140
if (preferred_index_format) {
1141+
if (preferred_index_format != 4 && gvfs_config_is_set(GVFS_BLOCK_COMMANDS))
1142+
die(_("changing the index version is not supported on a GVFS repo"));
1143+
11371144
if (preferred_index_format < INDEX_FORMAT_LB ||
11381145
INDEX_FORMAT_UB < preferred_index_format)
11391146
die("index-version %d not in range: %d..%d",
@@ -1169,6 +1176,9 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
11691176
}
11701177

11711178
if (split_index > 0) {
1179+
if (gvfs_config_is_set(GVFS_BLOCK_COMMANDS))
1180+
die(_("split index is not supported on a GVFS repo"));
1181+
11721182
if (git_config_get_split_index() == 0)
11731183
warning(_("core.splitIndex is set to false; "
11741184
"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
@@ -399,7 +399,29 @@ static int update_one(struct cache_tree *it,
399399
continue;
400400

401401
strbuf_grow(&buffer, entlen + 100);
402-
strbuf_addf(&buffer, "%o %.*s%c", mode, entlen, path + baselen, '\0');
402+
403+
switch (mode) {
404+
case 0100644:
405+
strbuf_add(&buffer, "100644 ", 7);
406+
break;
407+
case 0100664:
408+
strbuf_add(&buffer, "100664 ", 7);
409+
break;
410+
case 0100755:
411+
strbuf_add(&buffer, "100755 ", 7);
412+
break;
413+
case 0120000:
414+
strbuf_add(&buffer, "120000 ", 7);
415+
break;
416+
case 0160000:
417+
strbuf_add(&buffer, "160000 ", 7);
418+
break;
419+
default:
420+
strbuf_addf(&buffer, "%o ", mode);
421+
break;
422+
}
423+
strbuf_add(&buffer, path + baselen, entlen);
424+
strbuf_addch(&buffer, '\0');
403425
strbuf_add(&buffer, oid->hash, the_hash_algo->rawsz);
404426

405427
#if DEBUG_CACHE_TREE

0 commit comments

Comments
 (0)