* [PATCH] add: do not rely on dtype being NULL behavior
@ 2010-11-11 13:03 Nguyễn Thái Ngọc Duy
2010-11-11 17:47 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-11-11 13:03 UTC (permalink / raw)
To: git, Junio C Hamano, Jens.Lehmann; +Cc: Nguyễn Thái Ngọc Duy
Commit c84de70 (excluded_1(): support exclude files in index -
2009-08-20) added support for excluded() where dtype can be NULL. It
was designed specifically for index matching because there was no
other way to extract dtype information from index. It did not support
wildcard matching (for example, "a*/" pattern would fail to match).
The code was probably misread when commit 108da0d (git add: Add the
"--ignore-missing" option for the dry run - 2010-07-10) was made
because DT_UNKNOWN happens to be zero (NULL) too.
Do not pass DT_UNKNOWN/NULL to excluded(), instead pass a pointer to a
variable that contains DT_UNKNOWN. The real dtype will be extracted
from worktree by excluded(), as expected.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
I do not add tests for the "a*/" failure above because I plan
to fix it. Expect c84de70 will be reverted "soon" (in my timescale)
when sparse checkout can pass real dtype.
builtin/add.c | 3 ++-
dir.c | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/builtin/add.c b/builtin/add.c
index 56a4e0a..1a4672d 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -446,7 +446,8 @@ int cmd_add(int argc, const char **argv, const char *prefix)
if (!seen[i] && pathspec[i][0]
&& !file_exists(pathspec[i])) {
if (ignore_missing) {
- if (excluded(&dir, pathspec[i], DT_UNKNOWN))
+ int dtype = DT_UNKNOWN;
+ if (excluded(&dir, pathspec[i], &dtype))
dir_add_ignored(&dir, pathspec[i], strlen(pathspec[i]));
} else
die("pathspec '%s' did not match any files",
diff --git a/dir.c b/dir.c
index b2dfb69..c4bed66 100644
--- a/dir.c
+++ b/dir.c
@@ -359,7 +359,7 @@ int excluded_from_list(const char *pathname,
int to_exclude = x->to_exclude;
if (x->flags & EXC_FLAG_MUSTBEDIR) {
- if (!dtype) {
+ if (dtype != NULL) {
if (!prefixcmp(pathname, exclude) &&
pathname[x->patternlen] == '/')
return to_exclude;
--
1.7.3.2.210.g045198
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] add: do not rely on dtype being NULL behavior
2010-11-11 13:03 [PATCH] add: do not rely on dtype being NULL behavior Nguyễn Thái Ngọc Duy
@ 2010-11-11 17:47 ` Junio C Hamano
2010-11-12 1:55 ` Nguyen Thai Ngoc Duy
0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2010-11-11 17:47 UTC (permalink / raw)
To: Nguyễn Thái Ngọc Duy; +Cc: git, Junio C Hamano, Jens.Lehmann
Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
> Commit c84de70 (excluded_1(): support exclude files in index -
> 2009-08-20) added support for excluded() where dtype can be NULL. It
> was designed specifically for index matching because there was no
> other way to extract dtype information from index. It did not support
> wildcard matching (for example, "a*/" pattern would fail to match).
>
> The code was probably misread when commit 108da0d (git add: Add the
> "--ignore-missing" option for the dry run - 2010-07-10) was made
> because DT_UNKNOWN happens to be zero (NULL) too.
>
> Do not pass DT_UNKNOWN/NULL to excluded(), instead pass a pointer to a
> variable that contains DT_UNKNOWN. The real dtype will be extracted
> from worktree by excluded(), as expected.
>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
> I do not add tests for the "a*/" failure above because I plan
> to fix it. Expect c84de70 will be reverted "soon" (in my timescale)
> when sparse checkout can pass real dtype.
>
> builtin/add.c | 3 ++-
> dir.c | 2 +-
> 2 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/builtin/add.c b/builtin/add.c
> index 56a4e0a..1a4672d 100644
> --- a/builtin/add.c
> +++ b/builtin/add.c
> @@ -446,7 +446,8 @@ int cmd_add(int argc, const char **argv, const char *prefix)
> if (!seen[i] && pathspec[i][0]
> && !file_exists(pathspec[i])) {
> if (ignore_missing) {
> - if (excluded(&dir, pathspec[i], DT_UNKNOWN))
> + int dtype = DT_UNKNOWN;
> + if (excluded(&dir, pathspec[i], &dtype))
> dir_add_ignored(&dir, pathspec[i], strlen(pathspec[i]));
> } else
> die("pathspec '%s' did not match any files",
> diff --git a/dir.c b/dir.c
> index b2dfb69..c4bed66 100644
> --- a/dir.c
> +++ b/dir.c
> @@ -359,7 +359,7 @@ int excluded_from_list(const char *pathname,
> int to_exclude = x->to_exclude;
>
> if (x->flags & EXC_FLAG_MUSTBEDIR) {
> - if (!dtype) {
> + if (dtype != NULL) {
Hmm, are you sure about this part?
> if (!prefixcmp(pathname, exclude) &&
> pathname[x->patternlen] == '/')
> return to_exclude;
> --
> 1.7.3.2.210.g045198
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] add: do not rely on dtype being NULL behavior
2010-11-11 17:47 ` Junio C Hamano
@ 2010-11-12 1:55 ` Nguyen Thai Ngoc Duy
0 siblings, 0 replies; 3+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2010-11-12 1:55 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Jens.Lehmann
2010/11/12 Junio C Hamano <gitster@pobox.com>:
> Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
>
>> Commit c84de70 (excluded_1(): support exclude files in index -
>> 2009-08-20) added support for excluded() where dtype can be NULL. It
>> was designed specifically for index matching because there was no
>> other way to extract dtype information from index. It did not support
>> wildcard matching (for example, "a*/" pattern would fail to match).
>>
>> The code was probably misread when commit 108da0d (git add: Add the
>> "--ignore-missing" option for the dry run - 2010-07-10) was made
>> because DT_UNKNOWN happens to be zero (NULL) too.
>>
>> Do not pass DT_UNKNOWN/NULL to excluded(), instead pass a pointer to a
>> variable that contains DT_UNKNOWN. The real dtype will be extracted
>> from worktree by excluded(), as expected.
>>
>> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
>> ---
>> I do not add tests for the "a*/" failure above because I plan
>> to fix it. Expect c84de70 will be reverted "soon" (in my timescale)
>> when sparse checkout can pass real dtype.
>>
>> builtin/add.c | 3 ++-
>> dir.c | 2 +-
>> 2 files changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/builtin/add.c b/builtin/add.c
>> index 56a4e0a..1a4672d 100644
>> --- a/builtin/add.c
>> +++ b/builtin/add.c
>> @@ -446,7 +446,8 @@ int cmd_add(int argc, const char **argv, const char *prefix)
>> if (!seen[i] && pathspec[i][0]
>> && !file_exists(pathspec[i])) {
>> if (ignore_missing) {
>> - if (excluded(&dir, pathspec[i], DT_UNKNOWN))
>> + int dtype = DT_UNKNOWN;
>> + if (excluded(&dir, pathspec[i], &dtype))
>> dir_add_ignored(&dir, pathspec[i], strlen(pathspec[i]));
>> } else
>> die("pathspec '%s' did not match any files",
>> diff --git a/dir.c b/dir.c
>> index b2dfb69..c4bed66 100644
>> --- a/dir.c
>> +++ b/dir.c
>> @@ -359,7 +359,7 @@ int excluded_from_list(const char *pathname,
>> int to_exclude = x->to_exclude;
>>
>> if (x->flags & EXC_FLAG_MUSTBEDIR) {
>> - if (!dtype) {
>> + if (dtype != NULL) {
>
> Hmm, are you sure about this part?
Don't write code when you feel asleep. No, that was wrong.
--
Duy
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-11-12 1:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-11 13:03 [PATCH] add: do not rely on dtype being NULL behavior Nguyễn Thái Ngọc Duy
2010-11-11 17:47 ` Junio C Hamano
2010-11-12 1:55 ` Nguyen Thai Ngoc Duy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).