Re: [PATCH] add: do not rely on dtype being NULL behavior

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2010/11/12 Junio C Hamano <gitster@xxxxxxxxx>:
> Nguyán ThÃi Ngác Duy Â<pclouds@xxxxxxxxx> 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@xxxxxxxxx>
>> ---
>> Â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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]