{"thread":{"id":"38812","subject":"[PATCH RFC 1/3] add: add new --exclude option to git add","startedAt":"2015-03-15T13:49:59Z","lastAt":"2015-03-16T07:11:52Z","messageCount":16,"participants":["Alexander Kuleshov","Philip Oakley","Torsten Bögershausen","Eric Sunshine","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"257719","messageId":"1426427399-22423-1-git-send-email-kuleshovmail@gmail.com","threadId":"38812","inReplyTo":null,"subject":"[PATCH RFC 1/3] add: add new --exclude option to git add","fromName":"Alexander Kuleshov","fromEmail":"kuleshovmail@gmail.com","sentAt":"2015-03-15T13:49:59Z","receivedAt":"2015-03-15T13:49:59Z","isPatch":true,"sender":{"key":"kuleshovmail@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2699235?v=4"},"body":"This patch introduces new --exclude option for the git add\ncommand.\n\nWe already have core.excludesfile configuration variable which indicates\na path to file which contains patterns to exclude. This patch provides\nability to pass --exclude option to the git add command to exclude paths\nfrom command line in addition to which found in the ignore files.\n\nSigned-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>\n---\n builtin/add.c | 20 ++++++++++++++++++++\n 1 file changed, 20 insertions(+)\n\ndiff --git a/builtin/add.c b/builtin/add.c\nindex 3390933..5c602a6 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -244,6 +244,16 @@ static int ignore_removal_cb(const struct option *opt, const char *arg, int unse\n \treturn 0;\n }\n \n+struct string_list exclude_list = STRING_LIST_INIT_NODUP;\n+struct exclude_list *el;\n+\n+static int exclude_cb(const struct option *opt, const char *arg, int unset)\n+{\n+\tstruct string_list *exclude_list = opt->value;\n+\tstring_list_append(exclude_list, arg);\n+\treturn 0;\n+}\n+\n static struct option builtin_add_options[] = {\n \tOPT__DRY_RUN(&show_only, N_(\"dry run\")),\n \tOPT__VERBOSE(&verbose, N_(\"be verbose\")),\n@@ -255,6 +265,9 @@ static struct option builtin_add_options[] = {\n \tOPT_BOOL('u', \"update\", &take_worktree_changes, N_(\"update tracked files\")),\n \tOPT_BOOL('N', \"intent-to-add\", &intent_to_add, N_(\"record only the fact that the path will be added later\")),\n \tOPT_BOOL('A', \"all\", &addremove_explicit, N_(\"add changes from all tracked and untracked files\")),\n+\t{ OPTION_CALLBACK, 0, \"exclude\", &exclude_list, N_(\"pattern\"),\n+\t  N_(\"do no add files matching pattern to index\"),\n+\t  0, exclude_cb },\n \t{ OPTION_CALLBACK, 0, \"ignore-removal\", &addremove_explicit,\n \t  NULL /* takes no arguments */,\n \t  N_(\"ignore paths removed in the working tree (same as --no-all)\"),\n@@ -298,6 +311,7 @@ static int add_files(struct dir_struct *dir, int flags)\n \n int cmd_add(int argc, const char **argv, const char *prefix)\n {\n+\tint i;\n \tint exit_status = 0;\n \tstruct pathspec pathspec;\n \tstruct dir_struct dir;\n@@ -381,6 +395,11 @@ int cmd_add(int argc, const char **argv, const char *prefix)\n \t\tif (!ignored_too) {\n \t\t\tdir.flags |= DIR_COLLECT_IGNORED;\n \t\t\tsetup_standard_excludes(&dir);\n+\n+\t\t\tel = add_exclude_list(&dir, EXC_CMDL, \"--exclude option\");\n+\t\t\tfor (i = 0; i < exclude_list.nr; i++)\n+\t\t\t\tadd_exclude(exclude_list.items[i].string, \"\", 0, el, -(i+1));\n+\n \t\t}\n \n \t\tmemset(&empty_pathspec, 0, sizeof(empty_pathspec));\n@@ -446,5 +465,6 @@ finish:\n \t\t\tdie(_(\"Unable to write new index file\"));\n \t}\n \n+\tstring_list_clear(&exclude_list, 0);\n \treturn exit_status;\n }\n-- \n2.3.3.472.g20ceeac\n"},{"id":"257720","messageId":"1426427425-23309-1-git-send-email-kuleshovmail@gmail.com","threadId":"38812","inReplyTo":"1426427399-22423-1-git-send-email-kuleshovmail@gmail.com","subject":"[PATCH 2/3] Documentation/git-add.txt: describe --exclude option","fromName":"Alexander Kuleshov","fromEmail":"kuleshovmail@gmail.com","sentAt":"2015-03-15T13:50:25Z","receivedAt":"2015-03-15T13:50:25Z","isPatch":true,"sender":{"key":"kuleshovmail@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2699235?v=4"},"body":"Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>\n---\n Documentation/git-add.txt | 6 +++++-\n 1 file changed, 5 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/git-add.txt b/Documentation/git-add.txt\nindex f2eb907..4bc156a 100644\n--- a/Documentation/git-add.txt\n+++ b/Documentation/git-add.txt\n@@ -9,7 +9,7 @@ SYNOPSIS\n --------\n [verse]\n 'git add' [--verbose | -v] [--dry-run | -n] [--force | -f] [--interactive | -i] [--patch | -p]\n-\t  [--edit | -e] [--[no-]all | --[no-]ignore-removal | [--update | -u]]\n+\t  [--edit | -e] [--[no-]all | --[no-]ignore-removal | [--update | -u]] [--exclude=<pattern>]\n \t  [--intent-to-add | -N] [--refresh] [--ignore-errors] [--ignore-missing]\n \t  [--] [<pathspec>...]\n \n@@ -164,6 +164,10 @@ for \"git add --no-all <pathspec>...\", i.e. ignored removed files.\n \tbe ignored, no matter if they are already present in the work\n \ttree or not.\n \n+--exclude=<pattern>::\n+\tDo not add files to the index in addition which are found in\n+\tthe .gitignore.\n+\n \\--::\n \tThis option can be used to separate command-line options from\n \tthe list of files, (useful when filenames might be mistaken\n-- \n2.3.3.472.g20ceeac\n"},{"id":"257721","messageId":"1426427437-23370-1-git-send-email-kuleshovmail@gmail.com","threadId":"38812","inReplyTo":"1426427399-22423-1-git-send-email-kuleshovmail@gmail.com","subject":"[PATCH 3/3] t3700-add: added test for --exclude option","fromName":"Alexander Kuleshov","fromEmail":"kuleshovmail@gmail.com","sentAt":"2015-03-15T13:50:37Z","receivedAt":"2015-03-15T13:50:37Z","isPatch":true,"sender":{"key":"kuleshovmail@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2699235?v=4"},"body":"Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>\n---\n t/t3700-add.sh | 7 +++++++\n 1 file changed, 7 insertions(+)\n\ndiff --git a/t/t3700-add.sh b/t/t3700-add.sh\nindex f7ff1f5..c52a5d0 100755\n--- a/t/t3700-add.sh\n+++ b/t/t3700-add.sh\n@@ -81,6 +81,13 @@ test_expect_success '.gitignore is honored' '\n \t! (git ls-files | grep \"\\\\.ig\")\n '\n \n+test_expect_success 'Test that \"git add --exclude\" works' '\n+\ttouch foo &&\n+\ttouch bar &&\n+\tgit add --exclude=\"bar\" . &&\n+\t! (git ls-files | grep bar)\n+'\n+\n test_expect_success 'error out when attempting to add ignored ones without -f' '\n \ttest_must_fail git add a.?? &&\n \t! (git ls-files | grep \"\\\\.ig\")\n-- \n2.3.3.472.g20ceeac\n"},{"id":"257727","messageId":"CB8D46AE67FC4BD2A53DA46441714E88@PhilipOakley","threadId":"38812","inReplyTo":"1426427399-22423-1-git-send-email-kuleshovmail@gmail.com","subject":"Re: [PATCH RFC 1/3] add: add new --exclude option to git add","fromName":"Philip Oakley","fromEmail":"philipoakley@iee.org","sentAt":null,"receivedAt":"2015-03-15T17:34:52Z","isPatch":true,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"From: \"Alexander Kuleshov\" <kuleshovmail@gmail.com>\n> This patch introduces new --exclude option for the git add\n> command.\n>\n> We already have core.excludesfile configuration variable which \n> indicates\n> a path to file which contains patterns to exclude. This patch provides\n> ability to pass --exclude option to the git add command to exclude \n> paths\n> from command line in addition to which found in the ignore files.\n>\n> Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>\n> ---\n> builtin/add.c | 20 ++++++++++++++++++++\n> 1 file changed, 20 insertions(+)\n>\n> diff --git a/builtin/add.c b/builtin/add.c\n> index 3390933..5c602a6 100644\n> --- a/builtin/add.c\n> +++ b/builtin/add.c\n> @@ -244,6 +244,16 @@ static int ignore_removal_cb(const struct option \n> *opt, const char *arg, int unse\n>  return 0;\n> }\n>\n> +struct string_list exclude_list = STRING_LIST_INIT_NODUP;\n> +struct exclude_list *el;\n> +\n> +static int exclude_cb(const struct option *opt, const char *arg, int \n> unset)\n> +{\n> + struct string_list *exclude_list = opt->value;\n> + string_list_append(exclude_list, arg);\n> + return 0;\n> +}\n> +\n> static struct option builtin_add_options[] = {\n>  OPT__DRY_RUN(&show_only, N_(\"dry run\")),\n>  OPT__VERBOSE(&verbose, N_(\"be verbose\")),\n> @@ -255,6 +265,9 @@ static struct option builtin_add_options[] = {\n>  OPT_BOOL('u', \"update\", &take_worktree_changes, N_(\"update tracked \n> files\")),\n>  OPT_BOOL('N', \"intent-to-add\", &intent_to_add, N_(\"record only the \n> fact that the path will be added later\")),\n>  OPT_BOOL('A', \"all\", &addremove_explicit, N_(\"add changes from all \n> tracked and untracked files\")),\n> + { OPTION_CALLBACK, 0, \"exclude\", &exclude_list, N_(\"pattern\"),\n> +   N_(\"do no add files matching pattern to index\"),\n\ns /no/not/   ??\n\n> +   0, exclude_cb },\n>  { OPTION_CALLBACK, 0, \"ignore-removal\", &addremove_explicit,\n>    NULL /* takes no arguments */,\n>    N_(\"ignore paths removed in the working tree (same as --no-all)\"),\n> @@ -298,6 +311,7 @@ static int add_files(struct dir_struct *dir, int \n> flags)\n>\n> int cmd_add(int argc, const char **argv, const char *prefix)\n> {\n> + int i;\n>  int exit_status = 0;\n>  struct pathspec pathspec;\n>  struct dir_struct dir;\n> @@ -381,6 +395,11 @@ int cmd_add(int argc, const char **argv, const \n> char *prefix)\n>  if (!ignored_too) {\n>  dir.flags |= DIR_COLLECT_IGNORED;\n>  setup_standard_excludes(&dir);\n> +\n> + el = add_exclude_list(&dir, EXC_CMDL, \"--exclude option\");\n> + for (i = 0; i < exclude_list.nr; i++)\n> + add_exclude(exclude_list.items[i].string, \"\", 0, el, -(i+1));\n> +\n>  }\n>\n>  memset(&empty_pathspec, 0, sizeof(empty_pathspec));\n> @@ -446,5 +465,6 @@ finish:\n>  die(_(\"Unable to write new index file\"));\n>  }\n>\n> + string_list_clear(&exclude_list, 0);\n>  return exit_status;\n> }\n> -- \n> 2.3.3.472.g20ceeac\n>\n--\nPhilip \n"},{"id":"257729","messageId":"5505C6BD.5000809@web.de","threadId":"38812","inReplyTo":"1426427399-22423-1-git-send-email-kuleshovmail@gmail.com","subject":"Re: [PATCH RFC 1/3] add: add new --exclude option to git add","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2015-03-15T17:51:57Z","receivedAt":"2015-03-15T17:51:57Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On 2015-03-15 14.49, Alexander Kuleshov wrote:\n\nThanks for working on Git, some minor remarks/suggestions inline.\n> This patch introduces new --exclude option for the git add\n> command.\n\"This patch\" is redundant. Shorter may be:\nIntroduce the --exclude option for git add\n\n> \n> We already have core.excludesfile configuration variable which indicates\n> a path to file which contains patterns to exclude. This patch provides\nsame here: Provide the ability to pass ....\n> ability to pass --exclude option to the git add command to exclude paths\n> from command line in addition to which found in the ignore files.\n\"found\" ?? Would \"specified\" be better?\n> \n> Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>\n> ---\n>  builtin/add.c | 20 ++++++++++++++++++++\n>  1 file changed, 20 insertions(+)\n> \n> diff --git a/builtin/add.c b/builtin/add.c\n> index 3390933..5c602a6 100644\n> --- a/builtin/add.c\n> +++ b/builtin/add.c\n> @@ -244,6 +244,16 @@ static int ignore_removal_cb(const struct option *opt, const char *arg, int unse\n>  \treturn 0;\n>  }\n>  \n> +struct string_list exclude_list = STRING_LIST_INIT_NODUP;\n> +struct exclude_list *el;\n> +\n> +static int exclude_cb(const struct option *opt, const char *arg, int unset)\n> +{\n> +\tstruct string_list *exclude_list = opt->value;\n> +\tstring_list_append(exclude_list, arg);\n> +\treturn 0;\nWhen we always return 0, the function can be void ?\n> +}\n> +\n>  static struct option builtin_add_options[] = {\n>  \tOPT__DRY_RUN(&show_only, N_(\"dry run\")),\n>  \tOPT__VERBOSE(&verbose, N_(\"be verbose\")),\n> @@ -255,6 +265,9 @@ static struct option builtin_add_options[] = {\n>  \tOPT_BOOL('u', \"update\", &take_worktree_changes, N_(\"update tracked files\")),\n>  \tOPT_BOOL('N', \"intent-to-add\", &intent_to_add, N_(\"record only the fact that the path will be added later\")),\n>  \tOPT_BOOL('A', \"all\", &addremove_explicit, N_(\"add changes from all tracked and untracked files\")),\n> +\t{ OPTION_CALLBACK, 0, \"exclude\", &exclude_list, N_(\"pattern\"),\nWhat does pattern mean ?\nIs it the same as a \"pathspec\", used in Documentation/git-add.txt\n> +\t  N_(\"do no add files matching pattern to index\"),\n> +\t  0, exclude_cb },\n>  \t{ OPTION_CALLBACK, 0, \"ignore-removal\", &addremove_explicit,\n>  \t  NULL /* takes no arguments */,\n>  \t  N_(\"ignore paths removed in the working tree (same as --no-all)\"),\n> @@ -298,6 +311,7 @@ static int add_files(struct dir_struct *dir, int flags)\n>  \n>  int cmd_add(int argc, const char **argv, const char *prefix)\n>  {\n> +\tint i;\nDo we need \"i\" here ?\n>  \tint exit_status = 0;\n>  \tstruct pathspec pathspec;\n>  \tstruct dir_struct dir;\n> @@ -381,6 +395,11 @@ int cmd_add(int argc, const char **argv, const char *prefix)\n>  \t\tif (!ignored_too) {\nor could it be declared here  ?\n>  \t\t\tdir.flags |= DIR_COLLECT_IGNORED;\n>  \t\t\tsetup_standard_excludes(&dir);\n> +\n> +\t\t\tel = add_exclude_list(&dir, EXC_CMDL, \"--exclude option\");\n> +\t\t\tfor (i = 0; i < exclude_list.nr; i++)\n> +\t\t\t\tadd_exclude(exclude_list.items[i].string, \"\", 0, el, -(i+1));\n> +\n>  \t\t}\n>  \n>  \t\tmemset(&empty_pathspec, 0, sizeof(empty_pathspec));\n> @@ -446,5 +465,6 @@ finish:\n>  \t\t\tdie(_(\"Unable to write new index file\"));\n>  \t}\n>  \n> +\tstring_list_clear(&exclude_list, 0);\n>  \treturn exit_status;\n>  }\n> \n"},{"id":"257730","messageId":"CANCZXo5hi2C0oPe2TvY6MwaQJdaZhb1BgM+Sa_yi0nzaX6tT9g@mail.gmail.com","threadId":"38812","inReplyTo":"5505C6BD.5000809@web.de","subject":"Re: [PATCH RFC 1/3] add: add new --exclude option to git add","fromName":"Alexander Kuleshov","fromEmail":"kuleshovmail@gmail.com","sentAt":"2015-03-15T18:00:41Z","receivedAt":"2015-03-15T18:00:41Z","isPatch":true,"sender":{"key":"kuleshovmail@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2699235?v=4"},"body":"Hello All,\n\n>> s /no/not/   ??\n\nThank you Philip.\n\n2015-03-15 23:51 GMT+06:00 Torsten Bögershausen <tboegi@web.de>:\n> On 2015-03-15 14.49, Alexander Kuleshov wrote:\n>\n> Thanks for working on Git, some minor remarks/suggestions inline.\n>> This patch introduces new --exclude option for the git add\n>> command.\n> \"This patch\" is redundant. Shorter may be:\n> Introduce the --exclude option for git add\n>\n>>....\n>>\n\nThank you Torsten for you feedback. I will make all fixes and resend patch.\n\nOne little question, how to better resend it? Just send v2 for the 1/3\nor resend all with v2? Or maybe will be better to make one patch from\nthese 3 pathes?\n\nThank you.\n"},{"id":"257731","messageId":"5505C8DA.2050500@web.de","threadId":"38812","inReplyTo":"1426427437-23370-1-git-send-email-kuleshovmail@gmail.com","subject":"Re: [PATCH 3/3] t3700-add: added test for --exclude option","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2015-03-15T18:00:58Z","receivedAt":"2015-03-15T18:00:58Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"> +test_expect_success 'Test that \"git add --exclude\" works' '\n> +\ttouch foo &&\n> +\ttouch bar &&\ncan be written shorter as\n        >foo &&\n\t>bar &&\n> +\tgit add --exclude=\"bar\" . &&\nSide question:\nDo we need \"\" here ?\nOr should we test files with white space as well, like this:\n        >foo &&\n\t>bar &&\n\t>\"b a z\" &&\n    \tgit add --exclude=\"bar\" --exclude=\"b a z\" . &&\n\techo bar >expect &&\n\tgit ls-files >actual &&\n\ttest_cmp expect actual\n(Which doesn't use ! grep, but test_cmp, which will give more information when\nthe test case does not pass)\n"},{"id":"257732","messageId":"5505C961.7050008@web.de","threadId":"38812","inReplyTo":"5505C6BD.5000809@web.de","subject":"Re: [PATCH RFC 1/3] add: add new --exclude option to git add","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2015-03-15T18:03:13Z","receivedAt":"2015-03-15T18:03:13Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On 2015-03-15 18.51, Torsten Bögershausen wrote:\n>>  \tOPT_BOOL('A', \"all\", &addremove_explicit, N_(\"add changes from all tracked and untracked files\")),\n>> +\t{ OPTION_CALLBACK, 0, \"exclude\", &exclude_list, N_(\"pattern\"),\n> What does pattern mean ?\nI was too fast, take that back:\nDocumentation/gitignore.txt uses pattern as well.\nSorry for the noise.\n"},{"id":"257734","messageId":"CAPig+cR52GKNZkgsytUrb0m3wwY2T68cxjNB_OV+uLxvQUh=VA@mail.gmail.com","threadId":"38812","inReplyTo":"1426427399-22423-1-git-send-email-kuleshovmail@gmail.com","subject":"Re: [PATCH RFC 1/3] add: add new --exclude option to git add","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2015-03-15T18:12:22Z","receivedAt":"2015-03-15T18:12:22Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"In addition to points raised by Philip and Torsten...\n\nOn Sun, Mar 15, 2015 at 9:49 AM, Alexander Kuleshov\n<kuleshovmail@gmail.com> wrote:\n> add: add new --exclude option to git add\n\nNo need for redundant \"to git add\", since you already have the \"add:\" prefix.\n\n> This patch introduces new --exclude option for the git add\n> command.\n\nThis line merely repeats the Subject: line, thus can be dropped.\n\n> We already have core.excludesfile configuration variable which indicates\n> a path to file which contains patterns to exclude. This patch provides\n> ability to pass --exclude option to the git add command to exclude paths\n> from command line in addition to which found in the ignore files.\n\nThe commit message is missing the important justification for why this\nnew option is desirable, and why only git-add needs it.\n\n> Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>\n> ---\n> diff --git a/builtin/add.c b/builtin/add.c\n> index 3390933..5c602a6 100644\n> --- a/builtin/add.c\n> +++ b/builtin/add.c\n> @@ -244,6 +244,16 @@ static int ignore_removal_cb(const struct option *opt, const char *arg, int unse\n>         return 0;\n>  }\n>\n> +struct string_list exclude_list = STRING_LIST_INIT_NODUP;\n\nShouldn't this be declared static?\n\n> +struct exclude_list *el;\n\nWhy is this declared globally when it's only needed locally by cmd_add()?\n\n> +static int exclude_cb(const struct option *opt, const char *arg, int unset)\n> +{\n> +       struct string_list *exclude_list = opt->value;\n> +       string_list_append(exclude_list, arg);\n> +       return 0;\n> +}\n> +\n>  static struct option builtin_add_options[] = {\n>         OPT__DRY_RUN(&show_only, N_(\"dry run\")),\n>         OPT__VERBOSE(&verbose, N_(\"be verbose\")),\n> @@ -255,6 +265,9 @@ static struct option builtin_add_options[] = {\n>         OPT_BOOL('u', \"update\", &take_worktree_changes, N_(\"update tracked files\")),\n>         OPT_BOOL('N', \"intent-to-add\", &intent_to_add, N_(\"record only the fact that the path will be added later\")),\n>         OPT_BOOL('A', \"all\", &addremove_explicit, N_(\"add changes from all tracked and untracked files\")),\n> +       { OPTION_CALLBACK, 0, \"exclude\", &exclude_list, N_(\"pattern\"),\n> +         N_(\"do no add files matching pattern to index\"),\n> +         0, exclude_cb },\n\nCan this just be OPT_STRING_LIST instead of OPTION_CALLBACK?\n\n>         { OPTION_CALLBACK, 0, \"ignore-removal\", &addremove_explicit,\n>           NULL /* takes no arguments */,\n>           N_(\"ignore paths removed in the working tree (same as --no-all)\"),\n> @@ -298,6 +311,7 @@ static int add_files(struct dir_struct *dir, int flags)\n>\n>  int cmd_add(int argc, const char **argv, const char *prefix)\n>  {\n> +       int i;\n>         int exit_status = 0;\n>         struct pathspec pathspec;\n>         struct dir_struct dir;\n> @@ -381,6 +395,11 @@ int cmd_add(int argc, const char **argv, const char *prefix)\n>                 if (!ignored_too) {\n>                         dir.flags |= DIR_COLLECT_IGNORED;\n>                         setup_standard_excludes(&dir);\n> +\n> +                       el = add_exclude_list(&dir, EXC_CMDL, \"--exclude option\");\n> +                       for (i = 0; i < exclude_list.nr; i++)\n> +                               add_exclude(exclude_list.items[i].string, \"\", 0, el, -(i+1));\n> +\n>                 }\n>\n>                 memset(&empty_pathspec, 0, sizeof(empty_pathspec));\n> @@ -446,5 +465,6 @@ finish:\n>                         die(_(\"Unable to write new index file\"));\n>         }\n>\n> +       string_list_clear(&exclude_list, 0);\n>         return exit_status;\n>  }\n> --\n> 2.3.3.472.g20ceeac\n"},{"id":"257736","messageId":"CAPig+cRP-63zZTBXMMje6QGmkftNThDNQU_P_3Od4SbwdV-JUQ@mail.gmail.com","threadId":"38812","inReplyTo":"1426427425-23309-1-git-send-email-kuleshovmail@gmail.com","subject":"Re: [PATCH 2/3] Documentation/git-add.txt: describe --exclude option","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2015-03-15T18:14:42Z","receivedAt":"2015-03-15T18:14:42Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sun, Mar 15, 2015 at 9:50 AM, Alexander Kuleshov\n<kuleshovmail@gmail.com> wrote:\n> Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>\n> ---\n> diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt\n> index f2eb907..4bc156a 100644\n> --- a/Documentation/git-add.txt\n> +++ b/Documentation/git-add.txt\n> @@ -9,7 +9,7 @@ SYNOPSIS\n>  --------\n>  [verse]\n>  'git add' [--verbose | -v] [--dry-run | -n] [--force | -f] [--interactive | -i] [--patch | -p]\n> -         [--edit | -e] [--[no-]all | --[no-]ignore-removal | [--update | -u]]\n> +         [--edit | -e] [--[no-]all | --[no-]ignore-removal | [--update | -u]] [--exclude=<pattern>]\n>           [--intent-to-add | -N] [--refresh] [--ignore-errors] [--ignore-missing]\n>           [--] [<pathspec>...]\n>\n> @@ -164,6 +164,10 @@ for \"git add --no-all <pathspec>...\", i.e. ignored removed files.\n>         be ignored, no matter if they are already present in the work\n>         tree or not.\n>\n> +--exclude=<pattern>::\n> +       Do not add files to the index in addition which are found in\n> +       the .gitignore.\n\nThis is difficult to understand. Perhaps something like:\n\n    Also ignore files matching <pattern>, a .gitignore-like\n    pattern.\n\nThis option can be specified multiple times, can't it? The\ndocumentation should say so.\n\n> +\n>  \\--::\n>         This option can be used to separate command-line options from\n>         the list of files, (useful when filenames might be mistaken\n> --\n> 2.3.3.472.g20ceeac\n"},{"id":"257737","messageId":"CAPig+cRA9YqysB3Wakhu_a9hFnY189=4=Em2thY_rrFU552Nwg@mail.gmail.com","threadId":"38812","inReplyTo":"1426427437-23370-1-git-send-email-kuleshovmail@gmail.com","subject":"Re: [PATCH 3/3] t3700-add: added test for --exclude option","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2015-03-15T18:18:15Z","receivedAt":"2015-03-15T18:18:15Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sun, Mar 15, 2015 at 9:50 AM, Alexander Kuleshov\n<kuleshovmail@gmail.com> wrote:\n> t3700-add: added test for --exclude option\n\nWrite in imperative mood: s/added/add/\n\n> Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>\n> ---\n> diff --git a/t/t3700-add.sh b/t/t3700-add.sh\n> index f7ff1f5..c52a5d0 100755\n> --- a/t/t3700-add.sh\n> +++ b/t/t3700-add.sh\n> @@ -81,6 +81,13 @@ test_expect_success '.gitignore is honored' '\n>         ! (git ls-files | grep \"\\\\.ig\")\n>  '\n>\n> +test_expect_success 'Test that \"git add --exclude\" works' '\n> +       touch foo &&\n> +       touch bar &&\n\nExpanding slightly on what Torsten said: Use 'touch' when the\ntimestamp of the file is significant to the test; otherwise, just use\n\">foo\".\n\n> +       git add --exclude=\"bar\" . &&\n> +       ! (git ls-files | grep bar)\n\nFor completeness, don't you also want to test that \"foo\" _does_ appear\nin the git-ls-files output?\n\n> +'\n> +\n>  test_expect_success 'error out when attempting to add ignored ones without -f' '\n>         test_must_fail git add a.?? &&\n>         ! (git ls-files | grep \"\\\\.ig\")\n> --\n> 2.3.3.472.g20ceeac\n"},{"id":"257744","messageId":"xmqqtwxmt43h.fsf@gitster.dls.corp.google.com","threadId":"38812","inReplyTo":"CAPig+cR52GKNZkgsytUrb0m3wwY2T68cxjNB_OV+uLxvQUh=VA@mail.gmail.com","subject":"Re: [PATCH RFC 1/3] add: add new --exclude option to git add","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-03-15T20:09:38Z","receivedAt":"2015-03-15T20:09:38Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eric Sunshine <sunshine@sunshineco.com> writes:\n\n> The commit message is missing the important justification for why this\n> new option is desirable, and why only git-add needs it.\n\nI think that is a very good point.  I actually do not see why this\noption is ever needed, in a modern world that has the negative\npathspec magic.\n\nIs there a reason why this is undesiable\n\n    $ git add -- \\*.c ':!secret.c'\n\nand has to be spelled as\n\n    $ git add --exclude=secret.c -- \\*.c\n\nI do not see why...\n"},{"id":"257749","messageId":"D9562ECC995343B3A51D449DC2B46CBC@PhilipOakley","threadId":"38812","inReplyTo":"xmqqtwxmt43h.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH RFC 1/3] add: add new --exclude option to git add","fromName":"Philip Oakley","fromEmail":"philipoakley@iee.org","sentAt":null,"receivedAt":"2015-03-15T20:45:48Z","isPatch":true,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"From: \"Junio C Hamano\" <gitster@pobox.com>\n> Eric Sunshine <sunshine@sunshineco.com> writes:\n>\n>> The commit message is missing the important justification for why \n>> this\n>> new option is desirable, and why only git-add needs it.\n>\n> I think that is a very good point.  I actually do not see why this\n> option is ever needed, in a modern world that has the negative\n> pathspec magic.\n\nIsn't the problem one of \"how are users to discover such magic\". The \nfact we call it 'magic' (a sleight of hand...) may be why Alexander felt \nthe need for the extra option.\n\nMaybe He/We would be better off adjusting the documentation such that \nthese 'magic' capabilities are brought out of their hiding places into \nregular view - e.g. a paragraph within the 'git add' documentation \n(and/or other commands) showing how such excludes are easily done with a \nfew simple keystrokes....\n\n'git help revisions' doesn't appear to cover it. I'm not sure we even \nmention \"negative pathspec\" in the documentation (apart from rel notes \n1.9.0 & 2.3.0).\n\nMaybe Alexander could change itch to: make the \"magic negative pathspec\" \ncapability more visible?\n\n>\n> Is there a reason why this is undesiable\n>\n>    $ git add -- \\*.c ':!secret.c'\n>\n> and has to be spelled as\n>\n>    $ git add --exclude=secret.c -- \\*.c\n>\n> I do not see why...\n> --\nPhilip \n"},{"id":"257753","messageId":"xmqq4mpmszf2.fsf@gitster.dls.corp.google.com","threadId":"38812","inReplyTo":"D9562ECC995343B3A51D449DC2B46CBC@PhilipOakley","subject":"Re: [PATCH RFC 1/3] add: add new --exclude option to git add","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-03-15T21:50:41Z","receivedAt":"2015-03-15T21:50:41Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Philip Oakley\" <philipoakley@iee.org> writes:\n\n> Maybe He/We would be better off adjusting the documentation such that\n> these 'magic' capabilities are brought out of their hiding places into\n> regular view - e.g. a paragraph within the 'git add' documentation\n> (and/or other commands) showing how such excludes are easily done with\n> a few simple keystrokes....\n\nI agree documenting is good, but I do not think it belongs to \"git\nadd\".  For example, shouldn't \"git log -- \\*.c ':!secret.c'\" work\nthe same way?\n\n> 'git help revisions' doesn't appear to cover it.\n\nOf course not, because \"revisions\" would cover revisions, and\npathspecs are different animals ;-) Again, I agree there should be a\nsection somewhere close to the central place that talks about\npathspecs in general and then talk about pathspec magic there.\n\nThere are some references in git(1) but they talk about ways to\nimplicitly enable the magic to _all_ pathspecs, before introducing\nthe readers to what the magics are and how they can use them.\n\nPerhaps in git(1), before we introduce \"GIT COMMANDS\", we may want\nto have a new section that talks about the general structure of the\nGit command line, laying out the general rules such as\n\n * dashed options come first\n * revisions and ranges come second\n * pathspecs come last\n\nThe first one is described in detail in gitcli(7) and how revisions\nare spelled is given in gitrevisions(7).  How pathspecs are spelled\nand used may want to be its own gitpathspecs(7), or if there are not\ntoo many rules, can be spelled out there inline.  Either way, we\nwould want a brief section in git(1) to serve as a jumping board for\nthe former two, at least. Also descriptions for --literal-pathspecs\nand friends would want to refer to either the section or have a\ndirect reference to gitpathspecs(7) if we are going to write it a\nnew file.\n"},{"id":"257769","messageId":"55067A7A.80803@web.de","threadId":"38812","inReplyTo":"CANCZXo5hi2C0oPe2TvY6MwaQJdaZhb1BgM+Sa_yi0nzaX6tT9g@mail.gmail.com","subject":"Re: [PATCH RFC 1/3] add: add new --exclude option to git add","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2015-03-16T06:38:50Z","receivedAt":"2015-03-16T06:38:50Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"\n> One little question, how to better resend it? Just send v2 for the 1/3\n> or resend all with v2? Or maybe will be better to make one patch from\n> these 3 pathes?\n>\n> Thank you.\nMy personal suggestion would be:\n\nPlease wait 24 hours to collect feedback from the different time-zones\nin the world, where we have Git developers  :-)\n\nUntil the reviews has settled, you can send small updated pieces or \npiecelets/snipplets\nof the code which is discussed.\n\nWhen there is a kind of agreement, send a complete serious, with V3/V4...\n"},{"id":"257770","messageId":"CANCZXo7WzDZ1OnFqNwMe+c1vdjCMg4_4KwwW4FRpEPr7FTF3sQ@mail.gmail.com","threadId":"38812","inReplyTo":"xmqq4mpmszf2.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH RFC 1/3] add: add new --exclude option to git add","fromName":"Alexander Kuleshov","fromEmail":"kuleshovmail@gmail.com","sentAt":"2015-03-16T07:11:52Z","receivedAt":"2015-03-16T07:11:52Z","isPatch":true,"sender":{"key":"kuleshovmail@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2699235?v=4"},"body":">> Isn't the problem one of \"how are users to discover such magic\".\n\nYes it was main reason.\n"}]}