Skip to contentSkip to conversation

t3700: note a .gitignore matching fault

PATCH In review Nguyễn Thái Ngọc Duy 4 participants 18 messages Jun 15, 2016 1 message not in the archive Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 t3700: note a .gitignore matching fault

.gitignore support both positive and negative patterns. One may negate the other. Current code works well if both patterns target files in the same directory.

When a pattern targets a directory and an opposite pattern targets some files/directories within that directory, we need to descend in the directory until we're clear which ones are matched and which are not.

excluded_from_list() (or its callers) fails to handle this case. It too eagerly decides the fate of the whole directory without looking further in.

---
Haven't figured out how to cleanly fix this yet, unfortunately.

 t/t3700-add.sh |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
t/t3700-add.sh +16 -0
index 7de42fa..6c3eed6 100755
@@ -295,4 +295,20 @@ test_expect_success C_LOCALE_OUTPUT 'git add --dry-run --ignore-missing of non-e
 	test_cmp expect.err actual.err
 '
 
+cat >expected <<EOF
+add 'test/.gitignore'
+add 'test/out/in'
+EOF
+
+test_expect_failure C_LOCALE_OUTPUT '' '
+	mkdir -p test/out &&
+	touch test/out/in test/out/out &&
+	cat >test/.gitignore <<EOF &&
+out
+!out/in
+EOF
+	git add --dry-run test >actual &&
+	test_cmp expected actual
+'
+
 test_done
Signature · 1 line
1.7.4.74.g639db
#1 lore raw

PATCH 1/3 t3700: note a .gitignore matching fault

.gitignore support both positive and negative patterns. One may negate the other. Current code works well if both patterns target files in the same directory.

When a pattern targets a directory and an opposite pattern targets some files/directories within that directory, we need to descend in the directory until we're clear which ones are matched and which are not.

excluded_from_list() fails to handle this case. It too eagerly decides the fate of the whole directory without looking further in.

---
Sorry, forgot the test name.

 t/t3700-add.sh |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
t/t3700-add.sh +16 -0
index 7de42fa..c9f3a28 100755
@@ -295,4 +295,20 @@ test_expect_success C_LOCALE_OUTPUT 'git add --dry-run --ignore-missing of non-e
 	test_cmp expect.err actual.err
 '
 
+cat >expected <<EOF
+add 'test/.gitignore'
+add 'test/out/in'
+EOF
+
+test_expect_failure C_LOCALE_OUTPUT 'positive/negative patterns at different dir levels' '
+	mkdir -p test/out &&
+	touch test/out/in test/out/out &&
+	cat >test/.gitignore <<EOF &&
+out
+!out/in
+EOF
+	git add --dry-run test >actual &&
+	test_cmp expected actual
+'
+
 test_done
Signature · 1 line
1.7.4.74.g639db
#2 lore raw

Am 5/2/2011 14:55, schrieb Nguyễn Thái Ngọc Duy:

Quoted 11 lines

.gitignore support both positive and negative patterns. One may negate the other. Current code works well if both patterns target files in the same directory.

When a pattern targets a directory and an opposite pattern targets some files/directories within that directory, we need to descend in the directory until we're clear which ones are matched and which are not.

excluded_from_list() fails to handle this case. It too eagerly decides the fate of the whole directory without looking further in.

This has been debated just recently, and I don't think the current behavior is broken. See

http://thread.gmane.org/gmane.comp.version-control.git/169913
http://thread.gmane.org/gmane.comp.version-control.git/157190/focus=157196

-- Hannes

#3 lore raw

2011/5/2 Johannes Sixt <[email protected]>:

Quoted 9 lines

Am 5/2/2011 14:55, schrieb Nguyễn Thái Ngọc Duy:

Quoted 2 lines

excluded_from_list() fails to handle this case. It too eagerly decides the fate of the whole directory without looking further in.

This has been debated just recently, and I don't think the current behavior is broken. See

http://thread.gmane.org/gmane.comp.version-control.git/169913
http://thread.gmane.org/gmane.comp.version-control.git/157190/focus=157196

Because it's expensive to do does not make it right not to do it. I agree that traversing all the way down just to make the final decision is expensive. But we could at least state that we only support looking for .gitignore down to some level (0 as in current git), or based on .gitignore paths in index, then stop. The point is make it configurable with sane default. It's up to users to decide how they want to pay.

Signature · 1 line
Duy
#4 lore raw
Quoted 3 lines · Nguyen Thai Ngoc Duy

... The point is make it
configurable with sane default. It's up to users to decide how they want to pay.

Hmm, I am confused.

Isn't that what we already have? If you want to pay, you just do not define a do-not-descend ignore entry at such a location so close to the root of the working tree.

#11 lore raw

PATCH 2/3 t1011: fix sparse-checkout initialization and add new file

In reply to Nguyễn Thái Ngọc Duy

Do not append to $GIT_DIR/info/sparse-checkout at each test, overwrite it instead.

Also add sub/addedtoo for more complex tests later on

---
 t/t1011-read-tree-sparse-checkout.sh |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
t/t1011-read-tree-sparse-checkout.sh +8 -4
index de84e35..3f9d66f 100755
@@ -17,19 +17,21 @@ test_expect_success 'setup' '
 	cat >expected <<-\EOF &&
 	100644 77f0ba1734ed79d12881f81b36ee134de6a3327b 0	init.t
 	100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0	sub/added
+	100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0	sub/addedtoo
 	100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0	subsub/added
 	EOF
 	cat >expected.swt <<-\EOF &&
 	H init.t
 	H sub/added
+	H sub/addedtoo
 	H subsub/added
 	EOF
 
 	test_commit init &&
 	echo modified >>init.t &&
 	mkdir sub subsub &&
-	touch sub/added subsub/added &&
-	git add init.t sub/added subsub/added &&
+	touch sub/added sub/addedtoo subsub/added &&
+	git add init.t sub/added sub/addedtoo subsub/added &&
 	git commit -m "modified and added" &&
 	git tag top &&
 	git rm sub/added &&
@@ -83,6 +85,7 @@ test_expect_success 'match directories with trailing slash' '
 	cat >expected.swt-noinit <<-\EOF &&
 	S init.t
 	H sub/added
+	H sub/addedtoo
 	S subsub/added
 	EOF
 
@@ -95,7 +98,7 @@ test_expect_success 'match directories with trailing slash' '
 '
 
 test_expect_success 'match directories without trailing slash' '
-	echo sub >>.git/info/sparse-checkout &&
+	echo sub >.git/info/sparse-checkout &&
 	git read-tree -m -u HEAD &&
 	git ls-files -t >result &&
 	test_cmp expected.swt-noinit result &&
@@ -104,7 +107,7 @@ test_expect_success 'match directories without trailing slash' '
 '
 
 test_expect_success 'match directory pattern' '
-	echo "s?b" >>.git/info/sparse-checkout &&
+	echo "s?b" >.git/info/sparse-checkout &&
 	git read-tree -m -u HEAD &&
 	git ls-files -t >result &&
 	test_cmp expected.swt-noinit result &&
@@ -116,6 +119,7 @@ test_expect_success 'checkout area changes' '
 	cat >expected.swt-nosub <<-\EOF &&
 	H init.t
 	S sub/added
+	S sub/addedtoo
 	S subsub/added
 	EOF
 
Signature · 1 line
1.7.4.74.g639db
#12 lore raw

PATCH 3/3 sparse checkout: do not eagerly decide the fate for whole directory

In reply to Nguyễn Thái Ngọc Duy

Sparse-setting code follows closely how files are excluded in read_directory(), every entry (including directories) are fed to excluded_from_list() to decide if the entry is suitable. Directories are treated no different than files. If a directory is matched (or not), the whole directory is considered matched (or not) and the process moves on.

This generally works as long as there are no patterns to exclude parts of the directory. In case of sparse checkout code, the following patterns

t
!t/t0000-basic.sh

will produce a worktree with full directory "t" even if t0000-basic.sh is requested to stay out.

By the same reasoning, if a directory is to be excluded, any rules to re-include certain files within that directory will be ignored.

Fix it by always checking files against patterns. If no pattern can decide (ie. excluded_from_list() returns -1), those files will be included/excluded as same as their parent directory.

---
The TODO better be solved once read_directory() fixes the same fault. I have a feeling that some code can be shared..

 t/t1011-read-tree-sparse-checkout.sh |   41 ++++++++++++++++++++++
 unpack-trees.c                       |   63 ++++++++++++++++++---------------
 2 files changed, 75 insertions(+), 29 deletions(-)
t/t1011-read-tree-sparse-checkout.sh +41 -0
index 3f9d66f..20a50eb 100755
@@ -106,6 +106,47 @@ test_expect_success 'match directories without trailing slash' '
 	test -f sub/added
 '
 
+test_expect_success 'match directories with negated patterns' '
+	cat >expected.swt-negation <<\EOF &&
+S init.t
+S sub/added
+H sub/addedtoo
+S subsub/added
+EOF
+
+	cat >.git/info/sparse-checkout <<\EOF &&
+sub
+!sub/added
+EOF
+	git read-tree -m -u HEAD &&
+	git ls-files -t >result &&
+	test_cmp expected.swt-negation result &&
+	test ! -f init.t &&
+	test ! -f sub/added &&
+	test -f sub/addedtoo
+'
+
+test_expect_success 'match directories with negated patterns (2)' '
+	cat >expected.swt-negation2 <<\EOF &&
+H init.t
+H sub/added
+S sub/addedtoo
+H subsub/added
+EOF
+
+	cat >.git/info/sparse-checkout <<\EOF &&
+/*
+!sub
+sub/added
+EOF
+	git read-tree -m -u HEAD &&
+	git ls-files -t >result &&
+	test_cmp expected.swt-negation2 result &&
+	test -f init.t &&
+	test -f sub/added &&
+	test ! -f sub/addedtoo
+'
+
 test_expect_success 'match directory pattern' '
 	echo "s?b" >.git/info/sparse-checkout &&
 	git read-tree -m -u HEAD &&
unpack-trees.c +34 -29

118 lines not on this page · raw message

Signature · 1 line
1.7.4.74.g639db
#13 lore raw

Re: [PATCH 3/3] sparse checkout: do not eagerly decide the fate for whole directory

2011/5/2 Nguyễn Thái Ngọc Duy <[email protected]>:

Quoted 13 lines

Sparse-setting code follows closely how files are excluded in read_directory(), every entry (including directories) are fed to excluded_from_list() to decide if the entry is suitable. Directories are treated no different than files. If a directory is matched (or not), the whole directory is considered matched (or not) and the process moves on.

This generally works as long as there are no patterns to exclude parts of the directory. In case of sparse checkout code, the following patterns

 t
 !t/t0000-basic.sh

Quoted 8 lines

will produce a worktree with full directory "t" even if t0000-basic.sh is requested to stay out.

By the same reasoning, if a directory is to be excluded, any rules to re-include certain files within that directory will be ignored.

Fix it by always checking files against patterns. If no pattern can decide (ie. excluded_from_list() returns -1), those files will be

Maybe: can be decided?

Quoted 92 lines

included/excluded as same as their parent directory.

---
 The TODO better be solved once read_directory() fixes the same fault. I have a feeling that some code can be shared..

 t/t1011-read-tree-sparse-checkout.sh |   41 ++++++++++++++++++++++ unpack-trees.c                       |   63 ++++++++++++++++++---------------

 2 files changed, 75 insertions(+), 29 deletions(-)
t/t1011-read-tree-sparse-checkout.sh +0 -0
index 3f9d66f..20a50eb 100755
@@ -106,6 +106,47 @@ test_expect_success 'match directories without trailing slash' '

       test -f sub/added
 '

t/t1011-read-tree-sparse-checkout.sh +41 -0
+test_expect_success 'match directories with negated patterns' '
+       cat >expected.swt-negation <<\EOF &&
+S init.t
+S sub/added
+H sub/addedtoo
+S subsub/added
+EOF
+
+       cat >.git/info/sparse-checkout <<\EOF &&
+sub
+!sub/added
+EOF
+       git read-tree -m -u HEAD &&
+       git ls-files -t >result &&
+       test_cmp expected.swt-negation result &&
+       test ! -f init.t &&
+       test ! -f sub/added &&
+       test -f sub/addedtoo
+'
+
+test_expect_success 'match directories with negated patterns (2)' '
+       cat >expected.swt-negation2 <<\EOF &&
+H init.t
+H sub/added
+S sub/addedtoo
+H subsub/added
+EOF
+
+       cat >.git/info/sparse-checkout <<\EOF &&
+/*
+!sub
+sub/added
+EOF
+       git read-tree -m -u HEAD &&
+       git ls-files -t >result &&
+       test_cmp expected.swt-negation2 result &&
+       test -f init.t &&
+       test -f sub/added &&
+       test ! -f sub/addedtoo
+'
+

 test_expect_success 'match directory pattern' '
       echo "s?b" >.git/info/sparse-checkout &&
       git read-tree -m -u HEAD &&

unpack-trees.c +7 -2
index 500ebcf..5b8419c 100644
@@ -814,43 +814,45 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
        return mask;
  }
 
+static int clear_ce_flags_1(struct cache_entry **cache, int nr,
+                           char *prefix, int prefix_len,
+                           int select_mask, int clear_mask,
+                           struct exclude_list *el, int defval);
+
  /* Whole directory matching */
  static int clear_ce_flags_dir(struct cache_entry **cache, int nr,
                              char *prefix, int prefix_len,
                              char *basename,
                              int select_mask, int clear_mask,
-                             struct exclude_list *el)
+                             struct exclude_list *el, int defval)
  {
-       struct cache_entry **cache_end = cache + nr;
+       struct cache_entry **cache_end;
        int dtype = DT_DIR;
        int ret = excluded_from_list(prefix, prefix_len, basename, &dtype, el);
 
        prefix[prefix_len++] = '/';
 

unpack-trees.c static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str · line 835

Quoted 10 lines
unpack-trees.c +1 -9
-       /* included, no clearing for any entries under this directory */
-       if (!ret) {
-               for (; cache != cache_end; cache++) {
-                       struct cache_entry *ce = *cache;
-                       if (strncmp(ce->name, prefix, prefix_len))
-                               break;
-               }
-               return nr - (cache_end - cache);
-       }
+       /* If undecided, use parent directory's decision in defval */

What means "use parent directory's decision"? Could you make this comment more clearer?

unpack-trees.c static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str · line 840

Quoted 4 lines
unpack-trees.c +2 -1
+       if (ret < 0)
+               ret = defval;
 
-       /* excluded, clear all selected entries under this directory. */

Start with capital letter?

Quoted 10 lines
unpack-trees.c +0 -10
-       if (ret == 1) {
-               for (; cache != cache_end; cache++) {
-                       struct cache_entry *ce = *cache;
-                       if (select_mask && !(ce->ce_flags & select_mask))
-                               continue;
-                       if (strncmp(ce->name, prefix, prefix_len))
-                               break;
-                       ce->ce_flags &= ~clear_mask;
-               }
-               return nr - (cache_end - cache);

unpack-trees.c static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str · line 847

Quoted 10 lines
unpack-trees.c +7 -1
+       for (cache_end = cache; cache_end != cache + nr; cache_end++) {
+               struct cache_entry *ce = *cache_end;
+               if (strncmp(ce->name, prefix, prefix_len))
+                       break;
        }
 
-       return 0;
+       /*
+        * TODO: check el, if there are no patterns that may conflict
+        * with ret (iow, we know in advance the the incl/excl

the the ?

Quoted 74 lines
unpack-trees.c +17 -7
+        * decision for the entire directory), clear flag here without
+        * calling clear_ce_flags_1(). That function will call
+        * the expensive excluded_from_list() on every entry.
+        */
+       return clear_ce_flags_1(cache, cache_end - cache,
+                               prefix, prefix_len,
+                               select_mask, clear_mask,
+                               el, ret);
  }
 
  /*
@@ -871,7 +873,7 @@ static int clear_ce_flags_dir(struct cache_entry **cache, int nr,
  static int clear_ce_flags_1(struct cache_entry **cache, int nr,
                            char *prefix, int prefix_len,
                            int select_mask, int clear_mask,
-                           struct exclude_list *el)
+                           struct exclude_list *el, int defval)
  {
        struct cache_entry **cache_end = cache + nr;
 
@@ -882,7 +884,7 @@ static int clear_ce_flags_1(struct cache_entry **cache, int nr,
        while(cache != cache_end) {
                struct cache_entry *ce = *cache;
                const char *name, *slash;
-               int len, dtype;
+               int len, dtype, ret;
 
                if (select_mask && !(ce->ce_flags & select_mask)) {
                        cache++;
@@ -911,7 +913,7 @@ static int clear_ce_flags_1(struct cache_entry **cache, int nr,
                                                       prefix, prefix_len + len,
                                                       prefix + prefix_len,
                                                       select_mask, clear_mask,
-                                                      el);
+                                                      el, defval);
 
                        /* clear_c_f_dir eats a whole dir already? */
                        if (processed) {
@@ -922,13 +924,16 @@ static int clear_ce_flags_1(struct cache_entry **cache, int nr,
                        prefix[prefix_len + len++] = '/';
                        cache += clear_ce_flags_1(cache, cache_end - cache,
                                                  prefix, prefix_len + len,
-                                                 select_mask, clear_mask, el);
+                                                 select_mask, clear_mask, el, defval);
                        continue;
                }
 
                /* Non-directory */
                dtype = ce_to_dtype(ce);
-               if (excluded_from_list(ce->name, ce_namelen(ce), name, &dtype, el) > 0)
+               ret = excluded_from_list(ce->name, ce_namelen(ce), name, &dtype, el);
+               if (ret < 0)
+                       ret = defval;
+               if (ret > 0)
                        ce->ce_flags &= ~clear_mask;
                cache++;
        }
@@ -943,7 +948,7 @@ static int clear_ce_flags(struct cache_entry **cache, int nr,
        return clear_ce_flags_1(cache, nr,
                                prefix, 0,
                                select_mask, clear_mask,
-                               el);
+                               el, 0);
  }
 
  /*
--

1.7.4.74.g639db

--
To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

#14 lore raw

Re: [PATCH 3/3] sparse checkout: do not eagerly decide the fate for whole directory

2011/5/3 Thiago Farina <[email protected]>:

Quoted 21 lines
Quoted 11 lines

This generally works as long as there are no patterns to exclude parts of the directory. In case of sparse checkout code, the following patterns

 t
 !t/t0000-basic.sh

will produce a worktree with full directory "t" even if t0000-basic.sh is requested to stay out.
...
       prefix[prefix_len++] = '/';

Quoted 10 lines

-       /* included, no clearing for any entries under this directory */
-       if (!ret) {
-               for (; cache != cache_end; cache++) {
-                       struct cache_entry *ce = *cache;
-                       if (strncmp(ce->name, prefix, prefix_len))
-                               break;
-               }
-               return nr - (cache_end - cache);
-       }
+       /* If undecided, use parent directory's decision in defval */

Quoted 2 lines

What means "use parent directory's decision"? Could you make this comment more clearer?

Take the example patterns in commit message, we know that we match directory "t" (pattern 1). When we check t/0001-init.sh, no patterns match it. But because it's under "t", so we consider it matched. On the other hand, t/t0000-basic.sh will match pattern 2 and override parent directory's decision.

Quoted 5 lines
Quoted 4 lines

+       if (ret < 0)
+               ret = defval;

-       /* excluded, clear all selected entries under this directory. */

Start with capital letter?

It's a line removal, what can I do about it?

Signature · 1 line
Duy
#5 lore raw
In reply to Junio C Hamano
Quoted 11 lines · Junio C Hamano
Quoted 3 lines · Nguyen Thai Ngoc Duy

... The point is make it
configurable with sane default. It's up to users to decide how they want to pay.

Hmm, I am confused.

Isn't that what we already have?  If you want to pay, you just do not define a do-not-descend ignore entry at such a location so close to the root of the working tree.

Yes. But git still silently ignores some rules in the .gitignore. There's another case when you rather update $GIT_DIR/info/exclude than
.gitignore in the tree (import tree for example). Same trap again.

Signature · 1 line
Duy
#6 lore raw
Quoted 1 line · Nguyen Thai Ngoc Duy

Yes. But git still silently ignores some rules in the .gitignore.

Do you want git to report each and every entry in .gitignore saying "this rule does not apply"? That sounds like madness to me.

#7 lore raw
Quoted 6 lines · Junio C Hamano
Quoted 1 line · Nguyen Thai Ngoc Duy

Yes. But git still silently ignores some rules in the .gitignore.

Do you want git to report each and every entry in .gitignore saying "this rule does not apply"?  That sounds like madness to me.

This rule should apply, but not because of "efficiency reasons". Not just about any rule.

Signature · 1 line
Duy
#8 lore raw
Quoted 10 lines · Nguyen Thai Ngoc Duy
Quoted 6 lines · Junio C Hamano
Quoted 1 line · Nguyen Thai Ngoc Duy

Yes. But git still silently ignores some rules in the .gitignore.

Do you want git to report each and every entry in .gitignore saying "this rule does not apply"?  That sounds like madness to me.

This rule should apply, but not because of "efficiency reasons". Not just about any rule.

Maybe something like this instead of a implemantation fix?

Documentation/gitignore.txt +2 -0
index 8416f34..81e9d43 100644
@@ -71,6 +71,8 @@ PATTERN FORMAT
    matching file excluded by a previous pattern will become
    included again.  If a negated pattern matches, this will
    override lower precedence patterns sources.
+   If a directory is excluded by earlier patterns, negated
+   patterns that touch files inside the directory will be ignored.
 
  - If the pattern ends with a slash, it is removed for the
    purpose of the following description, but it would only find
Signature · 1 line
Duy
#9 lore raw

Am 5/4/2011 3:05, schrieb Nguyen Thai Ngoc Duy:

Quoted 1 line

Maybe something like this instead of a implemantation fix?

Yes, but...

Quoted 6 lines
Documentation/gitignore.txt +0 -0
index 8416f34..81e9d43 100644

Documentation/gitignore.txt PATTERN FORMAT · line 78

Quoted 8 lines
Documentation/gitignore.txt +2 -0
@@ -71,6 +71,8 @@ PATTERN FORMAT
    matching file excluded by a previous pattern will become
    included again.  If a negated pattern matches, this will
    override lower precedence patterns sources.
+   If a directory is excluded by earlier patterns, negated
+   patterns that touch files inside the directory will be ignored.
 
  - If the pattern ends with a slash, it is removed for the
    purpose of the following description, but it would only find

... as I already said here:

http://thread.gmane.org/gmane.comp.version-control.git/170907/focus=170916

I think that this is not quite the right place to mention this restriction. See my proposal in the same post.

-- Hannes

#10 lore raw
Quoted 22 lines · Johannes Sixt

Am 5/4/2011 3:05, schrieb Nguyen Thai Ngoc Duy:

Quoted 1 line

Maybe something like this instead of a implemantation fix?

Yes, but...

Quoted 11 lines
Documentation/gitignore.txt +0 -0
index 8416f34..81e9d43 100644
@@ -71,6 +71,8 @@ PATTERN FORMAT

    matching file excluded by a previous pattern will become included again.  If a negated pattern matches, this will override lower precedence patterns sources.
+   If a directory is excluded by earlier patterns, negated
+   patterns that touch files inside the directory will be ignored.

Quoted 3 lines

  - If the pattern ends with a slash, it is removed for the purpose of the following description, but it would only find

... as I already said here:

Quoted 4 lines

http://thread.gmane.org/gmane.comp.version-control.git/170907/focus=170916

I think that this is not quite the right place to mention this restriction. See my proposal in the same post.

Thanks. I missed that post. NOTES is fine although I prefer BUGS (or LIMITATIONS). We may decide not to look for more .gitignore inside, but we should respect all patterns we have got. Can you please submit your changes in a patch?

Signature · 1 line
Duy
#18 lore raw

Re: [PATCH 3/3] sparse checkout: do not eagerly decide the fate for whole directory

In reply to a message not in the archive
Quoted 7 lines · Nguyễn Thái Ngọc Duy

Sparse-setting code follows closely how files are excluded in read_directory(), every entry (including directories) are fed to excluded_from_list() to decide if the entry is suitable. Directories are treated no different than files. If a directory is matched (or not), the whole directory is considered matched (or not) and the process moves on.

Quoted 8 lines

This generally works as long as there are no patterns to exclude parts of the directory. In case of sparse checkout code, the following patterns

t
!t/t0000-basic.sh

will produce a worktree with full directory "t" even if t0000-basic.sh is requested to stay out.

That roughly corresponds to having

	!t
        t/t0000-basic.sh

in gitignore mechanism, right? Generally t/ is not to be excluded, but only t0000-basic.sh should be. Sounds like a right thing to do.

Quoted 5 lines

---
Fix some comments as Thiago suggested. 1/3 of this series should be dropped apparently.

I am not quite sure what to do with this patch though.

You marked this as 3/3 without saying anything about where 1 and 2 are (or if they even exist). You hint there is a 1 that should be dropped here.

Is this a re-rolled round, and if so where are the previous ones? Could you make things easier to find (just saying something like [PATCH v2 3/3] in the Subject: is good enough) next time?

#15 lore raw

Re: [PATCH 3/3] sparse checkout: do not eagerly decide the fate for whole directory

In reply to Nguyen Thai Ngoc Duy
Quoted 9 lines · Nguyen Thai Ngoc Duy
Quoted 3 lines
Quoted 1 line

+ /* If undecided, use parent directory's decision in defval */

What means "use parent directory's decision"? Could you make this comment more clearer?

Take the example patterns in commit message, we know that we match directory "t" (pattern 1). When we check t/0001-init.sh, no patterns match it. But because it's under "t", so we consider it matched. On the other hand, t/t0000-basic.sh will match pattern 2 and override parent directory's decision.

Somebody ask about the comment you wrote, and you had to explain it. Doesn't it tell us something about the readability of the comment?

After all the request was "Could you make it clearer?"

#16 lore raw

Re: [PATCH 3/3] sparse checkout: do not eagerly decide the fate for whole directory

Quoted 12 lines · Junio C Hamano
Quoted 9 lines · Nguyen Thai Ngoc Duy
Quoted 3 lines
Quoted 1 line

+       /* If undecided, use parent directory's decision in defval */

What means "use parent directory's decision"? Could you make this comment more clearer?

Take the example patterns in commit message, we know that we match directory "t" (pattern 1). When we check t/0001-init.sh, no patterns match it. But because it's under "t", so we consider it matched. On the other hand, t/t0000-basic.sh will match pattern 2 and override parent directory's decision.

Quoted 4 lines

Somebody ask about the comment you wrote, and you had to explain it. Doesn't it tell us something about the readability of the comment?

After all the request was "Could you make it clearer?"

He did not reply whether my further explanation was good enough. Maybe this?

excluded_from_list() can't decide whether the entry matches given patterns. If the current directory is matched before (ie. in defval), then by default the entry is also matched.

Signature · 1 line
Duy