Skip to content

Commit 0188f6b

Browse files
pcloudsgitster
authored andcommitted
add: do not rely on dtype being NULL behavior
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 60aa9cf commit 0188f6b

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

builtin/add.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,8 @@ int cmd_add(int argc, const char **argv, const char *prefix)
446446
if (!seen[i] && pathspec[i][0]
447447
&& !file_exists(pathspec[i])) {
448448
if (ignore_missing) {
449-
if (excluded(&dir, pathspec[i], DT_UNKNOWN))
449+
int dtype = DT_UNKNOWN;
450+
if (excluded(&dir, pathspec[i], &dtype))
450451
dir_add_ignored(&dir, pathspec[i], strlen(pathspec[i]));
451452
} else
452453
die("pathspec '%s' did not match any files",

0 commit comments

Comments
 (0)