{"thread":{"id":"29374","subject":"[PATCH 0/2] nd/commit-ignore-i-t-a replacement","startedAt":"2012-01-16T02:36:45Z","lastAt":"2012-01-17T02:47:20Z","messageCount":7,"participants":["Nguyễn Thái Ngọc Duy","Pete Wyckoff","Junio C Hamano","Nguyen Thai Ngoc Duy","Jonathan Nieder"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"182590","messageId":"1326681407-6344-1-git-send-email-pclouds@gmail.com","threadId":"29374","inReplyTo":null,"subject":"[PATCH 0/2] nd/commit-ignore-i-t-a replacement","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-01-16T02:36:45Z","receivedAt":"2012-01-16T02:36:45Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"This replaces current topic branch in pu with a more sensible\napproach using config key. write-tree also learns about this.\n\nNguyễn Thái Ngọc Duy (2):\n  cache-tree: update API to take abitrary flags\n  commit, write-tree: allow to ignore CE_INTENT_TO_ADD while writing\n    trees\n\n Documentation/config.txt         |    5 +++++\n Documentation/git-add.txt        |   12 ++++++++++--\n Documentation/git-write-tree.txt |    8 +++++++-\n builtin/commit.c                 |   13 ++++++++++---\n builtin/write-tree.c             |    2 ++\n cache-tree.c                     |   35 +++++++++++++++++------------------\n cache-tree.h                     |    5 ++++-\n merge-recursive.c                |    2 +-\n t/t2203-add-intent.sh            |   30 ++++++++++++++++++++++++++++++\n test-dump-cache-tree.c           |    2 +-\n 10 files changed, 87 insertions(+), 27 deletions(-)\n\n-- \n1.7.3.1.256.g2539c.dirty\n"},{"id":"182592","messageId":"1326681407-6344-2-git-send-email-pclouds@gmail.com","threadId":"29374","inReplyTo":"1326681407-6344-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 1/2] cache-tree: update API to take abitrary flags","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-01-16T02:36:46Z","receivedAt":"2012-01-16T02:36:46Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/commit.c       |    4 ++--\n cache-tree.c           |   27 ++++++++++++---------------\n cache-tree.h           |    4 +++-\n merge-recursive.c      |    2 +-\n test-dump-cache-tree.c |    2 +-\n 5 files changed, 19 insertions(+), 20 deletions(-)\n\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex eba1377..bf42bb3 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -400,7 +400,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix,\n \t\tfd = hold_locked_index(&index_lock, 1);\n \t\tadd_files_to_cache(also ? prefix : NULL, pathspec, 0);\n \t\trefresh_cache_or_die(refresh_flags);\n-\t\tupdate_main_cache_tree(1);\n+\t\tupdate_main_cache_tree(WRITE_TREE_SILENT);\n \t\tif (write_cache(fd, active_cache, active_nr) ||\n \t\t    close_lock_file(&index_lock))\n \t\t\tdie(_(\"unable to write new_index file\"));\n@@ -421,7 +421,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix,\n \t\tfd = hold_locked_index(&index_lock, 1);\n \t\trefresh_cache_or_die(refresh_flags);\n \t\tif (active_cache_changed) {\n-\t\t\tupdate_main_cache_tree(1);\n+\t\t\tupdate_main_cache_tree(WRITE_TREE_SILENT);\n \t\t\tif (write_cache(fd, active_cache, active_nr) ||\n \t\t\t    commit_locked_index(&index_lock))\n \t\t\t\tdie(_(\"unable to write new_index file\"));\ndiff --git a/cache-tree.c b/cache-tree.c\nindex 8de3959..16355d6 100644\n--- a/cache-tree.c\n+++ b/cache-tree.c\n@@ -150,9 +150,10 @@ void cache_tree_invalidate_path(struct cache_tree *it, const char *path)\n }\n \n static int verify_cache(struct cache_entry **cache,\n-\t\t\tint entries, int silent)\n+\t\t\tint entries, int flags)\n {\n \tint i, funny;\n+\tint silent = flags & WRITE_TREE_SILENT;\n \n \t/* Verify that the tree is merged */\n \tfunny = 0;\n@@ -241,10 +242,11 @@ static int update_one(struct cache_tree *it,\n \t\t      int entries,\n \t\t      const char *base,\n \t\t      int baselen,\n-\t\t      int missing_ok,\n-\t\t      int dryrun)\n+\t\t      int flags)\n {\n \tstruct strbuf buffer;\n+\tint missing_ok = flags & WRITE_TREE_MISSING_OK;\n+\tint dryrun = flags & WRITE_TREE_DRY_RUN;\n \tint i;\n \n \tif (0 <= it->entry_count && has_sha1_file(it->sha1))\n@@ -288,8 +290,7 @@ static int update_one(struct cache_tree *it,\n \t\t\t\t    cache + i, entries - i,\n \t\t\t\t    path,\n \t\t\t\t    baselen + sublen + 1,\n-\t\t\t\t    missing_ok,\n-\t\t\t\t    dryrun);\n+\t\t\t\t    flags);\n \t\tif (subcnt < 0)\n \t\t\treturn subcnt;\n \t\ti += subcnt - 1;\n@@ -371,15 +372,13 @@ static int update_one(struct cache_tree *it,\n int cache_tree_update(struct cache_tree *it,\n \t\t      struct cache_entry **cache,\n \t\t      int entries,\n-\t\t      int missing_ok,\n-\t\t      int dryrun,\n-\t\t      int silent)\n+\t\t      int flags)\n {\n \tint i;\n-\ti = verify_cache(cache, entries, silent);\n+\ti = verify_cache(cache, entries, flags);\n \tif (i)\n \t\treturn i;\n-\ti = update_one(it, cache, entries, \"\", 0, missing_ok, dryrun);\n+\ti = update_one(it, cache, entries, \"\", 0, flags);\n \tif (i < 0)\n \t\treturn i;\n \treturn 0;\n@@ -572,11 +571,9 @@ int write_cache_as_tree(unsigned char *sha1, int flags, const char *prefix)\n \n \twas_valid = cache_tree_fully_valid(active_cache_tree);\n \tif (!was_valid) {\n-\t\tint missing_ok = flags & WRITE_TREE_MISSING_OK;\n-\n \t\tif (cache_tree_update(active_cache_tree,\n \t\t\t\t      active_cache, active_nr,\n-\t\t\t\t      missing_ok, 0, 0) < 0)\n+\t\t\t\t      flags) < 0)\n \t\t\treturn WRITE_TREE_UNMERGED_INDEX;\n \t\tif (0 <= newfd) {\n \t\t\tif (!write_cache(newfd, active_cache, active_nr) &&\n@@ -672,10 +669,10 @@ int cache_tree_matches_traversal(struct cache_tree *root,\n \treturn 0;\n }\n \n-int update_main_cache_tree (int silent)\n+int update_main_cache_tree (int flags)\n {\n \tif (!the_index.cache_tree)\n \t\tthe_index.cache_tree = cache_tree();\n \treturn cache_tree_update(the_index.cache_tree,\n-\t\t\t\t the_index.cache, the_index.cache_nr, 0, 0, silent);\n+\t\t\t\t the_index.cache, the_index.cache_nr, flags);\n }\ndiff --git a/cache-tree.h b/cache-tree.h\nindex 0ec0b2a..d8cb2e9 100644\n--- a/cache-tree.h\n+++ b/cache-tree.h\n@@ -29,13 +29,15 @@ void cache_tree_write(struct strbuf *, struct cache_tree *root);\n struct cache_tree *cache_tree_read(const char *buffer, unsigned long size);\n \n int cache_tree_fully_valid(struct cache_tree *);\n-int cache_tree_update(struct cache_tree *, struct cache_entry **, int, int, int, int);\n+int cache_tree_update(struct cache_tree *, struct cache_entry **, int, int);\n \n int update_main_cache_tree(int);\n \n /* bitmasks to write_cache_as_tree flags */\n #define WRITE_TREE_MISSING_OK 1\n #define WRITE_TREE_IGNORE_CACHE_TREE 2\n+#define WRITE_TREE_DRY_RUN 4\n+#define WRITE_TREE_SILENT 8\n \n /* error return codes */\n #define WRITE_TREE_UNREADABLE_INDEX (-1)\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex d83cd6c..6479a60 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -264,7 +264,7 @@ struct tree *write_tree_from_memory(struct merge_options *o)\n \n \tif (!cache_tree_fully_valid(active_cache_tree) &&\n \t    cache_tree_update(active_cache_tree,\n-\t\t\t      active_cache, active_nr, 0, 0, 0) < 0)\n+\t\t\t      active_cache, active_nr, 0) < 0)\n \t\tdie(\"error building trees\");\n \n \tresult = lookup_tree(active_cache_tree->sha1);\ndiff --git a/test-dump-cache-tree.c b/test-dump-cache-tree.c\nindex e6c2923..a6ffdf3 100644\n--- a/test-dump-cache-tree.c\n+++ b/test-dump-cache-tree.c\n@@ -59,6 +59,6 @@ int main(int ac, char **av)\n \tstruct cache_tree *another = cache_tree();\n \tif (read_cache() < 0)\n \t\tdie(\"unable to read index file\");\n-\tcache_tree_update(another, active_cache, active_nr, 0, 1, 0);\n+\tcache_tree_update(another, active_cache, active_nr, WRITE_TREE_DRY_RUN);\n \treturn dump_cache_tree(active_cache_tree, another, \"\");\n }\n-- \n1.7.3.1.256.g2539c.dirty\n"},{"id":"182591","messageId":"1326681407-6344-3-git-send-email-pclouds@gmail.com","threadId":"29374","inReplyTo":"1326681407-6344-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 2/2] commit, write-tree: allow to ignore CE_INTENT_TO_ADD while writing trees","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-01-16T02:36:47Z","receivedAt":"2012-01-16T02:36:47Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Normally cache-tree will not produce trees from an index that has\nCE_INTENT_TO_ADD entries. This is a safe measure to avoid\nmis-interpreting user's intention regarding this flag.\n\nThere are situations however where users want to create trees/commits\nregardless i-t-a entries. Allow such cases with commit.ignoreIntentToAdd\nfor git-commit and --ignore-intent-to-add for git-write-tree.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n Documentation/config.txt         |    5 +++++\n Documentation/git-add.txt        |   12 ++++++++++--\n Documentation/git-write-tree.txt |    8 +++++++-\n builtin/commit.c                 |   13 ++++++++++---\n builtin/write-tree.c             |    2 ++\n cache-tree.c                     |    8 +++++---\n cache-tree.h                     |    1 +\n t/t2203-add-intent.sh            |   30 ++++++++++++++++++++++++++++++\n 8 files changed, 70 insertions(+), 9 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex abeb82b..10c3767 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -831,6 +831,11 @@ commit.template::\n \t\"{tilde}/\" is expanded to the value of `$HOME` and \"{tilde}user/\" to the\n \tspecified user's home directory.\n \n+commit.ignoreIntentToAdd::\n+\tAllow to commit the index as-is even if there are\n+\tintent-to-add entries (see option `-N` in linkgit:git-add[1])\n+\tin index.\n+\n credential.helper::\n \tSpecify an external helper to be called when a username or\n \tpassword credential is needed; the helper may consult external\ndiff --git a/Documentation/git-add.txt b/Documentation/git-add.txt\nindex 9c1d395..ec548ea 100644\n--- a/Documentation/git-add.txt\n+++ b/Documentation/git-add.txt\n@@ -123,8 +123,16 @@ subdirectories.\n \tRecord only the fact that the path will be added later. An entry\n \tfor the path is placed in the index with no content. This is\n \tuseful for, among other things, showing the unstaged content of\n-\tsuch files with `git diff` and committing them with `git commit\n-\t-a`.\n+\tsuch files with `git diff`.\n++\n+Paths added with this option have intent-to-add flag in index. The\n+flag is removed once real content is added or updated. By default you\n+cannot commit the index as-is from until this flag is removed from all\n+entries (i.e. all entries have real content). See commit.ignoreIntentToAdd\n+regardless the flag.\n++\n+Committing with `git commit -a` or with selected paths works\n+regardless the config key and the flag.\n \n --refresh::\n \tDon't add the file(s), but only refresh their stat()\ndiff --git a/Documentation/git-write-tree.txt b/Documentation/git-write-tree.txt\nindex f22041a..d511d3a 100644\n--- a/Documentation/git-write-tree.txt\n+++ b/Documentation/git-write-tree.txt\n@@ -9,7 +9,7 @@ git-write-tree - Create a tree object from the current index\n SYNOPSIS\n --------\n [verse]\n-'git write-tree' [--missing-ok] [--prefix=<prefix>/]\n+'git write-tree' [--missing-ok] [--ignore-intent-to-add] [--prefix=<prefix>/]\n \n DESCRIPTION\n -----------\n@@ -32,6 +32,12 @@ OPTIONS\n \tdirectory exist in the object database.  This option disables this\n \tcheck.\n \n+--ignore-intent-to-add::\n+\tNormally 'git write-tree' will refuse to proceed if there are any\n+\tintent-to-add entries (see `-N` option in linkgit:git-add[1]).\n+\tThis option continues to create object tree as if there are no\n+\tintent-to-add entries in index.\n+\n --prefix=<prefix>/::\n \tWrites a tree object that represents a subdirectory\n \t`<prefix>`.  This can be used to write the tree object\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex bf42bb3..097699e 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -86,6 +86,7 @@ static int all, also, interactive, patch_interactive, only, amend, signoff;\n static int edit_flag = -1; /* unspecified */\n static int quiet, verbose, no_verify, allow_empty, dry_run, renew_authorship;\n static int no_post_rewrite, allow_empty_message;\n+static int cache_tree_flags;\n static char *untracked_files_arg, *force_date, *ignore_submodule_arg;\n static char *sign_commit;\n \n@@ -400,7 +401,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix,\n \t\tfd = hold_locked_index(&index_lock, 1);\n \t\tadd_files_to_cache(also ? prefix : NULL, pathspec, 0);\n \t\trefresh_cache_or_die(refresh_flags);\n-\t\tupdate_main_cache_tree(WRITE_TREE_SILENT);\n+\t\tupdate_main_cache_tree(cache_tree_flags | WRITE_TREE_SILENT);\n \t\tif (write_cache(fd, active_cache, active_nr) ||\n \t\t    close_lock_file(&index_lock))\n \t\t\tdie(_(\"unable to write new_index file\"));\n@@ -421,7 +422,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix,\n \t\tfd = hold_locked_index(&index_lock, 1);\n \t\trefresh_cache_or_die(refresh_flags);\n \t\tif (active_cache_changed) {\n-\t\t\tupdate_main_cache_tree(WRITE_TREE_SILENT);\n+\t\t\tupdate_main_cache_tree(cache_tree_flags | WRITE_TREE_SILENT);\n \t\t\tif (write_cache(fd, active_cache, active_nr) ||\n \t\t\t    commit_locked_index(&index_lock))\n \t\t\t\tdie(_(\"unable to write new_index file\"));\n@@ -870,7 +871,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,\n \t */\n \tdiscard_cache();\n \tread_cache_from(index_file);\n-\tif (update_main_cache_tree(0)) {\n+\tif (update_main_cache_tree(cache_tree_flags)) {\n \t\terror(_(\"Error building trees\"));\n \t\treturn 0;\n \t}\n@@ -1338,6 +1339,12 @@ static int git_commit_config(const char *k, const char *v, void *cb)\n \t\tinclude_status = git_config_bool(k, v);\n \t\treturn 0;\n \t}\n+\tif (!strcmp(k, \"commit.ignoreintenttoadd\")) {\n+\t\tif (git_config_bool(k, v))\n+\t\t\tcache_tree_flags |= WRITE_TREE_IGNORE_INTENT_TO_ADD;\n+\t\telse\n+\t\t\tcache_tree_flags &= ~WRITE_TREE_IGNORE_INTENT_TO_ADD;\n+\t}\n \n \tstatus = git_gpg_config(k, v, NULL);\n \tif (status)\ndiff --git a/builtin/write-tree.c b/builtin/write-tree.c\nindex b223af4..07797bb 100644\n--- a/builtin/write-tree.c\n+++ b/builtin/write-tree.c\n@@ -23,6 +23,8 @@ int cmd_write_tree(int argc, const char **argv, const char *unused_prefix)\n \tstruct option write_tree_options[] = {\n \t\tOPT_BIT(0, \"missing-ok\", &flags, \"allow missing objects\",\n \t\t\tWRITE_TREE_MISSING_OK),\n+\t\tOPT_BIT(0, \"ignore-intent-to-add\", &flags, \"ignore i-t-a entries in index\",\n+\t\t\tWRITE_TREE_IGNORE_INTENT_TO_ADD ),\n \t\t{ OPTION_STRING, 0, \"prefix\", &prefix, \"<prefix>/\",\n \t\t  \"write tree object for a subdirectory <prefix>\" ,\n \t\t  PARSE_OPT_LITERAL_ARGHELP },\ndiff --git a/cache-tree.c b/cache-tree.c\nindex 16355d6..d0be159 100644\n--- a/cache-tree.c\n+++ b/cache-tree.c\n@@ -159,7 +159,9 @@ static int verify_cache(struct cache_entry **cache,\n \tfunny = 0;\n \tfor (i = 0; i < entries; i++) {\n \t\tstruct cache_entry *ce = cache[i];\n-\t\tif (ce_stage(ce) || (ce->ce_flags & CE_INTENT_TO_ADD)) {\n+\t\tif (ce_stage(ce) ||\n+\t\t    ((flags & WRITE_TREE_IGNORE_INTENT_TO_ADD) == 0 &&\n+\t\t     (ce->ce_flags & CE_INTENT_TO_ADD))) {\n \t\t\tif (silent)\n \t\t\t\treturn -1;\n \t\t\tif (10 < ++funny) {\n@@ -339,8 +341,8 @@ static int update_one(struct cache_tree *it,\n \t\t\t\tmode, sha1_to_hex(sha1), entlen+baselen, path);\n \t\t}\n \n-\t\tif (ce->ce_flags & CE_REMOVE)\n-\t\t\tcontinue; /* entry being removed */\n+\t\tif (ce->ce_flags & (CE_REMOVE | CE_INTENT_TO_ADD))\n+\t\t\tcontinue; /* entry being removed or placeholder */\n \n \t\tstrbuf_grow(&buffer, entlen + 100);\n \t\tstrbuf_addf(&buffer, \"%o %.*s%c\", mode, entlen, path + baselen, '\\0');\ndiff --git a/cache-tree.h b/cache-tree.h\nindex d8cb2e9..af3b917 100644\n--- a/cache-tree.h\n+++ b/cache-tree.h\n@@ -38,6 +38,7 @@ int update_main_cache_tree(int);\n #define WRITE_TREE_IGNORE_CACHE_TREE 2\n #define WRITE_TREE_DRY_RUN 4\n #define WRITE_TREE_SILENT 8\n+#define WRITE_TREE_IGNORE_INTENT_TO_ADD 16\n \n /* error return codes */\n #define WRITE_TREE_UNREADABLE_INDEX (-1)\ndiff --git a/t/t2203-add-intent.sh b/t/t2203-add-intent.sh\nindex 58a3299..7b447d3 100755\n--- a/t/t2203-add-intent.sh\n+++ b/t/t2203-add-intent.sh\n@@ -44,6 +44,36 @@ test_expect_success 'cannot commit with i-t-a entry' '\n \ttest_must_fail git commit\n '\n \n+test_expect_success 'can write-tree with i-t-a entry' '\n+\tgit reset --hard &&\n+\techo xyzzy >rezrov &&\n+\techo frotz >nitfol &&\n+\tgit add rezrov &&\n+\tgit add -N nitfol &&\n+\tgit write-tree --ignore-intent-to-add >actual &&\n+\techo 150389afa1ccf46e4104667c741cd0e598269511 >expected &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'can commit tree with i-t-a entry' '\n+\tgit reset --hard &&\n+\techo xyzzy >rezrov &&\n+\techo frotz >nitfol &&\n+\tgit add rezrov &&\n+\tgit add -N nitfol &&\n+\tgit config commit.ignoreIntentToAdd true &&\n+\tgit commit -m initial &&\n+\tgit ls-tree -r HEAD >actual &&\n+\tcat >expected <<EOF &&\n+100644 blob ce013625030ba8dba906f756967f9e9ca394464a\telif\n+100644 blob ce013625030ba8dba906f756967f9e9ca394464a\tfile\n+100644 blob cf7711b63209d0dbc2d030f7fe3513745a9880e4\trezrov\n+EOF\n+\ttest_cmp expected actual &&\n+\tgit config commit.ignoreIntentToAdd false &&\n+\tgit reset HEAD^\n+'\n+\n test_expect_success 'can commit with an unrelated i-t-a entry in index' '\n \tgit reset --hard &&\n \techo xyzzy >rezrov &&\n-- \n1.7.3.1.256.g2539c.dirty\n"},{"id":"182615","messageId":"20120116164640.GA3590@padd.com","threadId":"29374","inReplyTo":"1326681407-6344-3-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH 2/2] commit, write-tree: allow to ignore CE_INTENT_TO_ADD while writing trees","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2012-01-16T16:46:40Z","receivedAt":"2012-01-16T16:46:40Z","isPatch":true,"sender":{"key":"pw@padd.com","avatar":null},"body":"pclouds@gmail.com wrote on Mon, 16 Jan 2012 09:36 +0700:\n> Normally cache-tree will not produce trees from an index that has\n> CE_INTENT_TO_ADD entries. This is a safe measure to avoid\n> mis-interpreting user's intention regarding this flag.\n> \n> There are situations however where users want to create trees/commits\n> regardless i-t-a entries. Allow such cases with commit.ignoreIntentToAdd\n> for git-commit and --ignore-intent-to-add for git-write-tree.\n\nRecently I tried to use \"--intent-to-add\" on a new file, but when\ncommitting was annoyed by the confusing error, and that I was\nforced to do something with that new file.\n\nWith commit.ignoreIntentToAdd I can happily commit while leaving\nthe new file for later.  It stays in the index and is easy to see\nin \"git status\".\n\nI don't understand the need for an option in write-tree; just the\nconfiguration variable is required.\n\nHere's some changes to the docs you might squash in.  It took me\na while to figure out what this variable was about, and I tried\nto explain it more clearly for a non-developer audience.\n\n\t\t-- Pete\n\n--------8<------------\nFrom 2471de7083ca3198f59a4734c0d11e9446874de1 Mon Sep 17 00:00:00 2001\nFrom: Pete Wyckoff <pw@padd.com>\nDate: Mon, 16 Jan 2012 11:44:26 -0500\nSubject: [PATCH] documentation for commit.ignoreIntentToAdd\n\n---\n Documentation/config.txt  |   13 ++++++++-----\n Documentation/git-add.txt |   15 ++++++++-------\n 2 files changed, 16 insertions(+), 12 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 7ba8777..a2cbb50 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -821,6 +821,14 @@ color.ui::\n \t`never` if you prefer git commands not to use color unless enabled\n \texplicitly with some other configuration or the `--color` option.\n \n+commit.ignoreIntentToAdd::\n+\tWhen 'git add' is invoked with `-N`, an \"intent-to-add\" entry is\n+\tmade in the index.  At commit time, these entries must be removed\n+\tfrom the index (\"git reset ...\") or added (\"git add ...\").  This\n+\tboolean variable makes it possible to commit while leaving the\n+\t\"intent-to-add\" entries still in the index.  See the description\n+\tof the `-N` option in linkgit:git-add[1] for details.\n+\n commit.status::\n \tA boolean to enable/disable inclusion of status information in the\n \tcommit message template when using an editor to prepare the commit\n@@ -831,11 +839,6 @@ commit.template::\n \t\"{tilde}/\" is expanded to the value of `$HOME` and \"{tilde}user/\" to the\n \tspecified user's home directory.\n \n-commit.ignoreIntentToAdd::\n-\tAllow to commit the index as-is even if there are\n-\tintent-to-add entries (see option `-N` in linkgit:git-add[1])\n-\tin index.\n-\n credential.helper::\n \tSpecify an external helper to be called when a username or\n \tpassword credential is needed; the helper may consult external\ndiff --git a/Documentation/git-add.txt b/Documentation/git-add.txt\nindex ec548ea..1c2ac44 100644\n--- a/Documentation/git-add.txt\n+++ b/Documentation/git-add.txt\n@@ -125,14 +125,15 @@ subdirectories.\n \tuseful for, among other things, showing the unstaged content of\n \tsuch files with `git diff`.\n +\n-Paths added with this option have intent-to-add flag in index. The\n-flag is removed once real content is added or updated. By default you\n-cannot commit the index as-is from until this flag is removed from all\n-entries (i.e. all entries have real content). See commit.ignoreIntentToAdd\n-regardless the flag.\n+When committing, these paths must be either added to the index (without\n+the `-N` flag) or removed (with \"git reset\").  However, a configuration\n+variable `commit.ignoreIntentToAdd` can be set to allow commits to\n+proceed, while the intent-to-add paths remain in the index.\n +\n-Committing with `git commit -a` or with selected paths works\n-regardless the config key and the flag.\n+Regardless of the configuration variable, invoking `git commit -a` will\n+commit all files including the ones marked with intent-to-add.\n+Specifying a <filepattern> can be used to commit files other than the\n+ones marked with intent-to-add.\n \n --refresh::\n \tDon't add the file(s), but only refresh their stat()\n-- \n1.7.9.rc0.18.gdae96\n"},{"id":"182652","messageId":"7vaa5nutbp.fsf@alter.siamese.dyndns.org","threadId":"29374","inReplyTo":"1326681407-6344-3-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH 2/2] commit, write-tree: allow to ignore CE_INTENT_TO_ADD while writing trees","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-01-16T23:21:46Z","receivedAt":"2012-01-16T23:21:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:\n\n> Normally cache-tree will not produce trees from an index that has\n> CE_INTENT_TO_ADD entries. This is a safe measure to avoid\n> mis-interpreting user's intention regarding this flag.\n\ns/safe/safety/;\n\n> There are situations however where users want to create trees/commits\n> regardless i-t-a entries.\n\nA new command line option \"--no-check-intent-to-add\" to \"commit\" without\nany configuration bit may be a useful addition as a first cut, and in\norder to help users to which \"there are situations\" is more than 50% of\nthe time, a configuration that can be overriden by \"--check-intent-to-add\"\nmay be a usability improvement over that first cut, but if this is really\nabout \"there are situations\", then a configuration that cannot be\noverriden by command line option feels a wrong way to go about it.\n\nIs this really about \"there are situations\" to begin with? I am suspecting\nthat this patch is either:\n\n (1) making it easier to use a wrong workflow, by promoting a way to\n     bypass a useful safety measure;\n\n (2) fixing an earlier UI mistake (iow, the interpretation #2 in the old\n     discussion is always the right one and the existing safety measure is\n     misguided) in such a way that allows you to work around an objection\n     from a bonehead maintainer who refuses to admit that earlier mistake;\n     and/or\n\n (3) splitting the Git userbase into two and making the resulting system\n     harder to teach.\n\nIf it is (2), and I suspect it may be the case, we might want to rather\nhonestly describe that the future direction is to fix it, and describe the\nconfiguration option as \"an early opt-in\" switch, together with the usual\nthree-step deprecation and migration schedule to make the new behaviour\nthe default in a future version. From the timeline point of view, it\nprobably can coincide with the change to always start an editor when\nrecording a merge commit.\n\nIn any case, for this change to help people who add more than one paths\nwith \"add -N\" and want to include only a subset of them in the commit, we\nmay want to explicitly teach them to add what they want to before\ncommitting with the new command line option in the documentation.\n"},{"id":"182658","messageId":"CACsJy8B_qGphVz8PFhPNLsOe-Ve7xb+biNP8Ok7dXiygu3KoSg@mail.gmail.com","threadId":"29374","inReplyTo":"7vaa5nutbp.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 2/2] commit, write-tree: allow to ignore CE_INTENT_TO_ADD while writing trees","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-01-17T01:50:46Z","receivedAt":"2012-01-17T01:50:46Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"2012/1/17 Junio C Hamano <gitster@pobox.com>:\n> A new command line option \"--no-check-intent-to-add\" to \"commit\" without\n> any configuration bit may be a useful addition as a first cut, and in\n> order to help users to which \"there are situations\" is more than 50% of\n> the time, a configuration that can be overriden by \"--check-intent-to-add\"\n> may be a usability improvement over that first cut, but if this is really\n> about \"there are situations\", then a configuration that cannot be\n> overriden by command line option feels a wrong way to go about it.\n\n\"git -c key=value commit\" may help.\n\n> Is this really about \"there are situations\" to begin with? I am suspecting\n> that this patch is either:\n>\n>  (1) making it easier to use a wrong workflow, by promoting a way to\n>     bypass a useful safety measure;\n>\n>  (2) fixing an earlier UI mistake (iow, the interpretation #2 in the old\n>     discussion is always the right one and the existing safety measure is\n>     misguided) in such a way that allows you to work around an objection\n>     from a bonehead maintainer who refuses to admit that earlier mistake;\n>     and/or\n>\n>  (3) splitting the Git userbase into two and making the resulting system\n>     harder to teach.\n\nThis patch is towards (3). I agree that \"add -N\" can be confusing to\nnew users because it does not actually add anything. Those who do not\nread manual carefully and commit without checking the result may fall\ninto that trap. So a user is expected to \"level up\" a bit and\nhopefully by the time he/she feels the need to get around the safety\ncheck and discover this flag, they should be ready to go without the\nsafety check.\n\nAlthough I would not oppose deprecating the old behavior if you go with (2) ;)\n\n> In any case, for this change to help people who add more than one paths\n> with \"add -N\" and want to include only a subset of them in the commit, we\n> may want to explicitly teach them to add what they want to before\n> committing with the new command line option in the documentation.\n\nyeah, keep telling people \"this does not add any thing, you need to\ngit-add again without -N\" after running \"add -N\" using advice\nframework when this config is on?\n-- \nDuy\n"},{"id":"182660","messageId":"20120117024720.GA32602@burratino","threadId":"29374","inReplyTo":"CACsJy8B_qGphVz8PFhPNLsOe-Ve7xb+biNP8Ok7dXiygu3KoSg@mail.gmail.com","subject":"Re: [PATCH 2/2] commit, write-tree: allow to ignore CE_INTENT_TO_ADD while writing trees","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-01-17T02:47:20Z","receivedAt":"2012-01-17T02:47:20Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Nguyen Thai Ngoc Duy wrote:\n\n> Although I would not oppose deprecating the old behavior if you go with (2) ;)\n\nMy reaction on reading the patch and clarifying followup was similar\nto Junio's.  I don't think a configuration item makes sense unless we\nare planning to flip the default in the future, and it would probably\nbe clearer to document it that way.\n\nBy the way, thanks very much for working on this.  I wish I had more\ntime to offer more than comments.\n\nSincerely,\nJonathan\n"}]}