Skip to content

Commit e39212a

Browse files
committed
Merge branch 'nd/maint-fix-add-typo-detection'
* nd/maint-fix-add-typo-detection: Revert "excluded_1(): support exclude files in index" unpack-trees: fix sparse checkout's "unable to match directories" unpack-trees: move all skip-worktree checks back to unpack_trees() dir.c: add free_excludes() cache.h: realign and use (1 << x) form for CE_* constants
2 parents 716958c + 9e08273 commit e39212a

File tree

6 files changed

+254
-53
lines changed

6 files changed

+254
-53
lines changed

Documentation/git-read-tree.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -416,13 +416,6 @@ turn `core.sparseCheckout` on in order to have sparse checkout
416416
support.
417417

418418

419-
BUGS
420-
----
421-
In order to match a directory with $GIT_DIR/info/sparse-checkout,
422-
trailing slash must be used. The form without trailing slash, while
423-
works with .gitignore, does not work with sparse checkout.
424-
425-
426419
SEE ALSO
427420
--------
428421
linkgit:git-write-tree[1]; linkgit:git-ls-files[1];

cache.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -170,26 +170,26 @@ struct cache_entry {
170170
*
171171
* In-memory only flags
172172
*/
173-
#define CE_UPDATE (0x10000)
174-
#define CE_REMOVE (0x20000)
175-
#define CE_UPTODATE (0x40000)
176-
#define CE_ADDED (0x80000)
173+
#define CE_UPDATE (1 << 16)
174+
#define CE_REMOVE (1 << 17)
175+
#define CE_UPTODATE (1 << 18)
176+
#define CE_ADDED (1 << 19)
177177

178-
#define CE_HASHED (0x100000)
179-
#define CE_UNHASHED (0x200000)
180-
#define CE_CONFLICTED (0x800000)
178+
#define CE_HASHED (1 << 20)
179+
#define CE_UNHASHED (1 << 21)
180+
#define CE_WT_REMOVE (1 << 22) /* remove in work directory */
181+
#define CE_CONFLICTED (1 << 23)
181182

182-
#define CE_WT_REMOVE (0x400000) /* remove in work directory */
183-
184-
#define CE_UNPACKED (0x1000000)
183+
#define CE_UNPACKED (1 << 24)
184+
#define CE_NEW_SKIP_WORKTREE (1 << 25)
185185

186186
/*
187187
* Extended on-disk flags
188188
*/
189-
#define CE_INTENT_TO_ADD 0x20000000
190-
#define CE_SKIP_WORKTREE 0x40000000
189+
#define CE_INTENT_TO_ADD (1 << 29)
190+
#define CE_SKIP_WORKTREE (1 << 30)
191191
/* CE_EXTENDED2 is for future extension */
192-
#define CE_EXTENDED2 0x80000000
192+
#define CE_EXTENDED2 (1 << 31)
193193

194194
#define CE_EXTENDED_FLAGS (CE_INTENT_TO_ADD | CE_SKIP_WORKTREE)
195195

dir.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,18 @@ static void *read_skip_worktree_file_from_index(const char *path, size_t *size)
253253
return data;
254254
}
255255

256+
void free_excludes(struct exclude_list *el)
257+
{
258+
int i;
259+
260+
for (i = 0; i < el->nr; i++)
261+
free(el->excludes[i]);
262+
free(el->excludes);
263+
264+
el->nr = 0;
265+
el->excludes = NULL;
266+
}
267+
256268
int add_excludes_from_file_to_list(const char *fname,
257269
const char *base,
258270
int baselen,
@@ -389,13 +401,6 @@ int excluded_from_list(const char *pathname,
389401
int to_exclude = x->to_exclude;
390402

391403
if (x->flags & EXC_FLAG_MUSTBEDIR) {
392-
if (!dtype) {
393-
if (!prefixcmp(pathname, exclude) &&
394-
pathname[x->patternlen] == '/')
395-
return to_exclude;
396-
else
397-
continue;
398-
}
399404
if (*dtype == DT_UNKNOWN)
400405
*dtype = get_dtype(NULL, pathname, pathlen);
401406
if (*dtype != DT_DIR)

dir.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ extern int add_excludes_from_file_to_list(const char *fname, const char *base, i
7878
extern void add_excludes_from_file(struct dir_struct *, const char *fname);
7979
extern void add_exclude(const char *string, const char *base,
8080
int baselen, struct exclude_list *which);
81+
extern void free_excludes(struct exclude_list *el);
8182
extern int file_exists(const char *);
8283

8384
extern char *get_relative_cwd(char *buffer, int size, const char *dir);

t/t1011-read-tree-sparse-checkout.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,20 @@ test_expect_success 'match directories with trailing slash' '
9494
test -f sub/added
9595
'
9696

97-
test_expect_failure 'match directories without trailing slash' '
98-
echo init.t >.git/info/sparse-checkout &&
97+
test_expect_success 'match directories without trailing slash' '
9998
echo sub >>.git/info/sparse-checkout &&
10099
git read-tree -m -u HEAD &&
101100
git ls-files -t >result &&
102-
test_cmp expected.swt result &&
101+
test_cmp expected.swt-noinit result &&
102+
test ! -f init.t &&
103+
test -f sub/added
104+
'
105+
106+
test_expect_success 'match directory pattern' '
107+
echo "s?b" >>.git/info/sparse-checkout &&
108+
git read-tree -m -u HEAD &&
109+
git ls-files -t >result &&
110+
test_cmp expected.swt-noinit result &&
103111
test ! -f init.t &&
104112
test -f sub/added
105113
'

0 commit comments

Comments
 (0)