Skip to content

Commit

Permalink
Merge branch 'nd/maint-fix-add-typo-detection'
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Junio C Hamano committed Dec 22, 2010
2 parents 716958c + 9e08273 commit e39212a
Show file tree
Hide file tree
Showing 6 changed files with 254 additions and 53 deletions.
7 changes: 0 additions & 7 deletions Documentation/git-read-tree.txt
Original file line number Diff line number Diff line change
Expand Up @@ -416,13 +416,6 @@ turn `core.sparseCheckout` on in order to have sparse checkout
support.


BUGS
----
In order to match a directory with $GIT_DIR/info/sparse-checkout,
trailing slash must be used. The form without trailing slash, while
works with .gitignore, does not work with sparse checkout.


SEE ALSO
--------
linkgit:git-write-tree[1]; linkgit:git-ls-files[1];
Expand Down
26 changes: 13 additions & 13 deletions cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,26 +170,26 @@ struct cache_entry {
*
* In-memory only flags
*/
#define CE_UPDATE (0x10000)
#define CE_REMOVE (0x20000)
#define CE_UPTODATE (0x40000)
#define CE_ADDED (0x80000)
#define CE_UPDATE (1 << 16)
#define CE_REMOVE (1 << 17)
#define CE_UPTODATE (1 << 18)
#define CE_ADDED (1 << 19)

#define CE_HASHED (0x100000)
#define CE_UNHASHED (0x200000)
#define CE_CONFLICTED (0x800000)
#define CE_HASHED (1 << 20)
#define CE_UNHASHED (1 << 21)
#define CE_WT_REMOVE (1 << 22) /* remove in work directory */
#define CE_CONFLICTED (1 << 23)

#define CE_WT_REMOVE (0x400000) /* remove in work directory */

#define CE_UNPACKED (0x1000000)
#define CE_UNPACKED (1 << 24)
#define CE_NEW_SKIP_WORKTREE (1 << 25)

/*
* Extended on-disk flags
*/
#define CE_INTENT_TO_ADD 0x20000000
#define CE_SKIP_WORKTREE 0x40000000
#define CE_INTENT_TO_ADD (1 << 29)
#define CE_SKIP_WORKTREE (1 << 30)
/* CE_EXTENDED2 is for future extension */
#define CE_EXTENDED2 0x80000000
#define CE_EXTENDED2 (1 << 31)

#define CE_EXTENDED_FLAGS (CE_INTENT_TO_ADD | CE_SKIP_WORKTREE)

Expand Down
19 changes: 12 additions & 7 deletions dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,18 @@ static void *read_skip_worktree_file_from_index(const char *path, size_t *size)
return data;
}

void free_excludes(struct exclude_list *el)
{
int i;

for (i = 0; i < el->nr; i++)
free(el->excludes[i]);
free(el->excludes);

el->nr = 0;
el->excludes = NULL;
}

int add_excludes_from_file_to_list(const char *fname,
const char *base,
int baselen,
Expand Down Expand Up @@ -389,13 +401,6 @@ int excluded_from_list(const char *pathname,
int to_exclude = x->to_exclude;

if (x->flags & EXC_FLAG_MUSTBEDIR) {
if (!dtype) {
if (!prefixcmp(pathname, exclude) &&
pathname[x->patternlen] == '/')
return to_exclude;
else
continue;
}
if (*dtype == DT_UNKNOWN)
*dtype = get_dtype(NULL, pathname, pathlen);
if (*dtype != DT_DIR)
Expand Down
1 change: 1 addition & 0 deletions dir.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ extern int add_excludes_from_file_to_list(const char *fname, const char *base, i
extern void add_excludes_from_file(struct dir_struct *, const char *fname);
extern void add_exclude(const char *string, const char *base,
int baselen, struct exclude_list *which);
extern void free_excludes(struct exclude_list *el);
extern int file_exists(const char *);

extern char *get_relative_cwd(char *buffer, int size, const char *dir);
Expand Down
14 changes: 11 additions & 3 deletions t/t1011-read-tree-sparse-checkout.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,20 @@ test_expect_success 'match directories with trailing slash' '
test -f sub/added
'

test_expect_failure 'match directories without trailing slash' '
echo init.t >.git/info/sparse-checkout &&
test_expect_success 'match directories without trailing slash' '
echo sub >>.git/info/sparse-checkout &&
git read-tree -m -u HEAD &&
git ls-files -t >result &&
test_cmp expected.swt result &&
test_cmp expected.swt-noinit result &&
test ! -f init.t &&
test -f sub/added
'

test_expect_success 'match directory pattern' '
echo "s?b" >>.git/info/sparse-checkout &&
git read-tree -m -u HEAD &&
git ls-files -t >result &&
test_cmp expected.swt-noinit result &&
test ! -f init.t &&
test -f sub/added
'
Expand Down
Loading

0 comments on commit e39212a

Please sign in to comment.