{"thread":{"id":"31697","subject":"[PATCH 0/2] git-add: -s flag (silently ignore files)","startedAt":"2012-10-01T07:14:58Z","lastAt":"2012-10-01T18:32:03Z","messageCount":6,"participants":["Olaf Klischat","Junio C Hamano","Matthieu Moy"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"200245","messageId":"1349075700-26334-1-git-send-email-olaf.klischat@gmail.com","threadId":"31697","inReplyTo":null,"subject":"[PATCH 0/2] git-add: -s flag (silently ignore files)","fromName":"Olaf Klischat","fromEmail":"olaf.klischat@gmail.com","sentAt":"2012-10-01T07:14:58Z","receivedAt":"2012-10-01T07:14:58Z","isPatch":true,"sender":{"key":"olaf.klischat@gmail.com","avatar":"https://gravatar.com/avatar/adbf3715021e1ded8e164c01a7a95f89eb23978e2248a60a5d43489f65151279?d=mp&s=160"},"body":"This adds an -s|--silent-ignore option to git-add, which causes\nignored files that were specified explicitly on the command line to be\nsilently ignored, rather than abandoning the command. I found this\nuseful for scenarios where you want to feed the file list into git add\nvia find or other external commands (`find .... | xargs git add'),\nwhich you wouldn't want to carefully tune so they don't output any\nignored files. git ls-files doesn't have find's filtering\ncapabilities, and using it in place of find would kind of violate \"one\njob one tool\" anyway. I'm not really a git guru, so maybe I'm missing\nsomething, and I'm unsure how useful this new option is for a general\naudience. OTOH the patch is trivial. Check it out.\n\nThe update applies on top of \"master\" (261b5119).\n\nOlaf Klischat (2):\n  git-add: -s flag added (silently ignore files)\n  git-add: -s flag: documentation added\n\n Documentation/git-add.txt |   15 +++++++++++----\n builtin/add.c             |   14 +++++++++++---\n t/t3700-add.sh            |   17 ++++++++++++++++-\n 3 files changed, 38 insertions(+), 8 deletions(-)\n\n-- \n1.7.10.4\n"},{"id":"200247","messageId":"1349075700-26334-2-git-send-email-olaf.klischat@gmail.com","threadId":"31697","inReplyTo":"1349075700-26334-1-git-send-email-olaf.klischat@gmail.com","subject":"[PATCH 1/2] git-add: -s flag added (silently ignore files)","fromName":"Olaf Klischat","fromEmail":"olaf.klischat@gmail.com","sentAt":"2012-10-01T07:14:59Z","receivedAt":"2012-10-01T07:14:59Z","isPatch":true,"sender":{"key":"olaf.klischat@gmail.com","avatar":"https://gravatar.com/avatar/adbf3715021e1ded8e164c01a7a95f89eb23978e2248a60a5d43489f65151279?d=mp&s=160"},"body":"Signed-off-by: Olaf Klischat <olaf.klischat@gmail.com>\n---\n builtin/add.c  |   14 +++++++++++---\n t/t3700-add.sh |   17 ++++++++++++++++-\n 2 files changed, 27 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/add.c b/builtin/add.c\nindex e664100..61bb9ce 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -313,7 +313,7 @@ static const char ignore_error[] =\n N_(\"The following paths are ignored by one of your .gitignore files:\\n\");\n \n static int verbose = 0, show_only = 0, ignored_too = 0, refresh_only = 0;\n-static int ignore_add_errors, addremove, intent_to_add, ignore_missing = 0;\n+static int ignore_add_errors, addremove, intent_to_add, ignore_missing, silent_ignores = 0;\n \n static struct option builtin_add_options[] = {\n \tOPT__DRY_RUN(&show_only, N_(\"dry run\")),\n@@ -329,6 +329,7 @@ static struct option builtin_add_options[] = {\n \tOPT_BOOLEAN( 0 , \"refresh\", &refresh_only, N_(\"don't add, only refresh the index\")),\n \tOPT_BOOLEAN( 0 , \"ignore-errors\", &ignore_add_errors, N_(\"just skip files which cannot be added because of errors\")),\n \tOPT_BOOLEAN( 0 , \"ignore-missing\", &ignore_missing, N_(\"check if - even missing - files are ignored in dry run\")),\n+\tOPT_BOOLEAN('s', \"silent-ignores\", &silent_ignores, N_(\"don't fail when ignored files are specified on the command line (ignore them silently)\")),\n \tOPT_END(),\n };\n \n@@ -339,6 +340,11 @@ static int add_config(const char *var, const char *value, void *cb)\n \t\tignore_add_errors = git_config_bool(var, value);\n \t\treturn 0;\n \t}\n+\tif (!strcmp(var, \"add.silentignores\") ||\n+\t    !strcmp(var, \"add.silent-ignores\")) {\n+\t\tsilent_ignores = git_config_bool(var, value);\n+\t\treturn 0;\n+\t}\n \treturn git_default_config(var, value, cb);\n }\n \n@@ -346,11 +352,11 @@ static int add_files(struct dir_struct *dir, int flags)\n {\n \tint i, exit_status = 0;\n \n-\tif (dir->ignored_nr) {\n+\tif (dir->ignored_nr && !silent_ignores) {\n \t\tfprintf(stderr, _(ignore_error));\n \t\tfor (i = 0; i < dir->ignored_nr; i++)\n \t\t\tfprintf(stderr, \"%s\\n\", dir->ignored[i]->name);\n-\t\tfprintf(stderr, _(\"Use -f if you really want to add them.\\n\"));\n+\t\tfprintf(stderr, _(\"Use -f if you really want to add them, or -s to ignore them silently.\\n\"));\n \t\tdie(_(\"no files added\"));\n \t}\n \n@@ -390,6 +396,8 @@ int cmd_add(int argc, const char **argv, const char *prefix)\n \n \tif (addremove && take_worktree_changes)\n \t\tdie(_(\"-A and -u are mutually incompatible\"));\n+\tif (ignored_too && silent_ignores)\n+\t\tdie(_(\"-f and -s are mutually incompatible\"));\n \tif (!show_only && ignore_missing)\n \t\tdie(_(\"Option --ignore-missing can only be used together with --dry-run\"));\n \tif ((addremove || take_worktree_changes) && !argc) {\ndiff --git a/t/t3700-add.sh b/t/t3700-add.sh\nindex 874b3a6..1e17ae2 100755\n--- a/t/t3700-add.sh\n+++ b/t/t3700-add.sh\n@@ -294,7 +294,7 @@ test_expect_success 'git add --dry-run of an existing file output' \"\n cat >expect.err <<\\EOF\n The following paths are ignored by one of your .gitignore files:\n ignored-file\n-Use -f if you really want to add them.\n+Use -f if you really want to add them, or -s to ignore them silently.\n fatal: no files added\n EOF\n cat >expect.out <<\\EOF\n@@ -310,4 +310,19 @@ test_expect_success 'git add --dry-run --ignore-missing of non-existing file out\n \ttest_i18ncmp expect.err actual.err\n '\n \n+cat >expect.err <<\\EOF\n+EOF\n+cat >expect.out <<\\EOF\n+add 'track-this'\n+EOF\n+\n+test_expect_success 'git add --dry-run --silent-ignore --ignore-missing of non-existing file' '\n+\tgit add --dry-run --silent-ignore --ignore-missing track-this ignored-file >actual.out 2>actual.err\n+'\n+\n+test_expect_success 'git add --dry-run --silent-ignore --ignore-missing of non-existing file output' '\n+\ttest_i18ncmp expect.out actual.out &&\n+\ttest_i18ncmp expect.err actual.err\n+'\n+\n test_done\n-- \n1.7.10.4\n"},{"id":"200246","messageId":"1349075700-26334-3-git-send-email-olaf.klischat@gmail.com","threadId":"31697","inReplyTo":"1349075700-26334-1-git-send-email-olaf.klischat@gmail.com","subject":"[PATCH 2/2] git-add: -s flag: documentation added","fromName":"Olaf Klischat","fromEmail":"olaf.klischat@gmail.com","sentAt":"2012-10-01T07:15:00Z","receivedAt":"2012-10-01T07:15:00Z","isPatch":true,"sender":{"key":"olaf.klischat@gmail.com","avatar":"https://gravatar.com/avatar/adbf3715021e1ded8e164c01a7a95f89eb23978e2248a60a5d43489f65151279?d=mp&s=160"},"body":"Signed-off-by: Olaf Klischat <olaf.klischat@gmail.com>\n---\n Documentation/git-add.txt |   15 +++++++++++----\n 1 file changed, 11 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/git-add.txt b/Documentation/git-add.txt\nindex fd9e36b..a5a1cd1 100644\n--- a/Documentation/git-add.txt\n+++ b/Documentation/git-add.txt\n@@ -38,10 +38,12 @@ files have changes that are staged for the next commit.\n \n The `git add` command will not add ignored files by default.  If any\n ignored files were explicitly specified on the command line, `git add`\n-will fail with a list of ignored files.  Ignored files reached by\n-directory recursion or filename globbing performed by Git (quote your\n-globs before the shell) will be silently ignored.  The 'git add' command can\n-be used to add ignored files with the `-f` (force) option.\n+will fail with a list of ignored files unless the `-s` (silent-ignore)\n+option was given.  Ignored files reached by directory recursion or\n+filename globbing performed by Git (quote your globs before the shell)\n+will always be silently ignored.  The 'git add' command can be used to\n+add ignored files with the `-f` (force) option (which is mutually\n+exclusive with `-s`).\n \n Please see linkgit:git-commit[1] for alternative ways to add content to a\n commit.\n@@ -69,6 +71,11 @@ OPTIONS\n --force::\n \tAllow adding otherwise ignored files.\n \n+-s::\n+--silent-ignore::\n+\tDon't fail if ignored files were specified explicitly; ignore them\n+\tsilently and continue.\n+\n -i::\n --interactive::\n \tAdd modified contents in the working tree interactively to\n-- \n1.7.10.4\n"},{"id":"200276","messageId":"7vipaucbur.fsf@alter.siamese.dyndns.org","threadId":"31697","inReplyTo":"1349075700-26334-2-git-send-email-olaf.klischat@gmail.com","subject":"Re: [PATCH 1/2] git-add: -s flag added (silently ignore files)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-10-01T17:59:24Z","receivedAt":"2012-10-01T17:59:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Olaf Klischat <olaf.klischat@gmail.com> writes:\n\n> Signed-off-by: Olaf Klischat <olaf.klischat@gmail.com>\n> ---\n\nI am personally not sympathetic to the reasoning stated in the\nproposed commit log message above your signed-off-by line; the\nchange is not justified at all.\n\nBut I'll comment on the code changes anyway.\n\n>  builtin/add.c  |   14 +++++++++++---\n>  t/t3700-add.sh |   17 ++++++++++++++++-\n>  2 files changed, 27 insertions(+), 4 deletions(-)\n>\n> diff --git a/builtin/add.c b/builtin/add.c\n> index e664100..61bb9ce 100644\n> --- a/builtin/add.c\n> +++ b/builtin/add.c\n> @@ -313,7 +313,7 @@ static const char ignore_error[] =\n>  N_(\"The following paths are ignored by one of your .gitignore files:\\n\");\n>  \n>  static int verbose = 0, show_only = 0, ignored_too = 0, refresh_only = 0;\n> -static int ignore_add_errors, addremove, intent_to_add, ignore_missing = 0;\n> +static int ignore_add_errors, addremove, intent_to_add, ignore_missing, silent_ignores = 0;\n>  \n>  static struct option builtin_add_options[] = {\n>  \tOPT__DRY_RUN(&show_only, N_(\"dry run\")),\n> @@ -329,6 +329,7 @@ static struct option builtin_add_options[] = {\n>  \tOPT_BOOLEAN( 0 , \"refresh\", &refresh_only, N_(\"don't add, only refresh the index\")),\n>  \tOPT_BOOLEAN( 0 , \"ignore-errors\", &ignore_add_errors, N_(\"just skip files which cannot be added because of errors\")),\n>  \tOPT_BOOLEAN( 0 , \"ignore-missing\", &ignore_missing, N_(\"check if - even missing - files are ignored in dry run\")),\n> +\tOPT_BOOLEAN('s', \"silent-ignores\", &silent_ignores, N_(\"don't fail when ignored files are specified on the command line (ignore them silently)\")),\n\nI'd prefer not to see a new option whose worth hasn't been proven in\nthe field to squat on any short-and-sweet single letter option\nname and would suggest replacing that 's' with 0, at least for now.\n\n> @@ -339,6 +340,11 @@ static int add_config(const char *var, const char *value, void *cb)\n>  \t\tignore_add_errors = git_config_bool(var, value);\n>  \t\treturn 0;\n>  \t}\n> +\tif (!strcmp(var, \"add.silentignores\") ||\n> +\t    !strcmp(var, \"add.silent-ignores\")) {\n\nThe second variant is unwarranted.  We may have a variable or two\nthat are accepted with '-' or '_' in their names, but they are\nbackward compatibility measures, only to cover previous mistakes\nthat named them in these letters in the first place.\n"},{"id":"200278","messageId":"vpqehlif4qd.fsf@grenoble-inp.fr","threadId":"31697","inReplyTo":"7vipaucbur.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 1/2] git-add: -s flag added (silently ignore files)","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2012-10-01T18:04:58Z","receivedAt":"2012-10-01T18:04:58Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n>>  static struct option builtin_add_options[] = {\n>>  \tOPT__DRY_RUN(&show_only, N_(\"dry run\")),\n>> @@ -329,6 +329,7 @@ static struct option builtin_add_options[] = {\n>>  \tOPT_BOOLEAN( 0 , \"refresh\", &refresh_only, N_(\"don't add, only refresh the index\")),\n>>  \tOPT_BOOLEAN( 0 , \"ignore-errors\", &ignore_add_errors, N_(\"just skip files which cannot be added because of errors\")),\n>>  \tOPT_BOOLEAN( 0 , \"ignore-missing\", &ignore_missing, N_(\"check if - even missing - files are ignored in dry run\")),\n>> +\tOPT_BOOLEAN('s', \"silent-ignores\", &silent_ignores, N_(\"don't fail when ignored files are specified on the command line (ignore them silently)\")),\n>\n> I'd prefer not to see a new option whose worth hasn't been proven in\n> the field to squat on any short-and-sweet single letter option\n> name and would suggest replacing that 's' with 0, at least for now.\n\nAnother option would be a -k (--keep-going) that would ignore the files,\nbut not silently. \"git mv\" has such an option already.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"200280","messageId":"7v8vbqcacc.fsf@alter.siamese.dyndns.org","threadId":"31697","inReplyTo":"1349075700-26334-1-git-send-email-olaf.klischat@gmail.com","subject":"Re: [PATCH 0/2] git-add: -s flag (silently ignore files)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-10-01T18:32:03Z","receivedAt":"2012-10-01T18:32:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Olaf Klischat <olaf.klischat@gmail.com> writes:\n\n> ... scenarios where you want to feed the file list into git add\n> via find or other external commands (`find .... | xargs git add'),\n> which you wouldn't want to carefully tune...\n\nCan you explain this kind of thing in the actual commit log message\nwhen you reroll (if you will do so)?\n\nI also cannot help but find that `scenario` an artificially made-up\none.  The description did not feel convincing enough, even if it\nwere in the proposed commit log message, to justify such an option.\n\nA few questions.\n\n - What were the kind of patterns useful in the above `find` in your\n   real life example?\n\n - The use of `find` means giving pathspecs from the command line,\n   e.g. \"git add foo/ \\*.rb\", wouldn't have been sufficient. Are\n   there something we could improve this in more direct way?\n\n - Why was it too cumbersome to add the idiomatic\n\n\t\\( -name '*.o' -o -name '*~' \\) -prune -o\n\n   or something like that in front of whatever patterns were used?\n\n - Perhaps a filter that takes a list of paths and emits only the\n   ignored paths (or only the unignored paths) would be a more\n   generic approach?  You could feed the output from `find` to such\n   a filter, and then drive not just \"git add\" but other commands\n   that take paths if you solved it that way.\n"}]}