git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/4] commit: turn commit.ignoreIntentToAdd to true by default

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Feb 6, 2012, 10:57 UTC
Message-ID
<1328525855-2547-4-git-send-email-pclouds@gmail.com>
In-Reply-To
<1328525855-2547-1-git-send-email-pclouds@gmail.com>

From now on, those who has not set commit.ignoreIntentToAdd can commit as-is even if there are intent-to-add entries. Users are advised/annoyed to switch to new behavior.

Support for "commit.ignoreIntentToAdd = true" will be dropped in future. The placeholder "FIXME" needs to be replaced when it's decided what release will drop config support.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 Documentation/config.txt |    5 ++---
 builtin/commit.c         |   13 ++++++++-----
 t/t2203-add-intent.sh    |    4 ++--
 3 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 6ec81a8..f9a05ac 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -837,9 +837,8 @@ commit.ignoreIntentToAdd::
 	in index. Set to `false` to disallow commit in this acase, or `true`
 	to allow it.
 +
-By default, `git commit` refuses to commit as-is when you have intent-to-add
-entries. This will change in 1.8.0, where `git commit` allows it. If you
-prefer current behavior, please set it to `false`.
+By default, `git commit` allows to commit as-is when you have intent-to-add
+entries. Support for this configuration variable will be dropped in FIXME.
 
 credential.helper::
 	Specify an external helper to be called when a username or
diff --git a/builtin/commit.c b/builtin/commit.c
index af3250c..eb0ca49 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -423,17 +423,17 @@ static char *prepare_index(int argc, const char **argv, const char *prefix,
 	if (!pathspec || !*pathspec) {
 		fd = hold_locked_index(&index_lock, 1);
 		refresh_cache_or_die(refresh_flags);
-		if (!set_commit_ignoreintenttoadd) {
+		if (!(cache_tree_flags & WRITE_TREE_IGNORE_INTENT_TO_ADD)) {
 			int i;
 			for (i = 0; i < active_nr; i++)
 				if (active_cache[i]->ce_flags & CE_INTENT_TO_ADD)
 					break;
 			if (i < active_nr)
 				warning(_("You are committing as-is with intent-to-add entries as the result of\n"
-					  "\"git add -N\". Git currently forbids this case. This will change in\n"
-					  "1.8.0 where intent-to-add entries are simply ignored when committing\n"
-					  "as-is. Please look up document and set commit.ignoreIntentToAdd\n"
-					  "properly to stop this warning."));
+					  "\"git add -N\". Git currently forbids this case. But this is deprecated\n"
+					  "support for this behavior will be dropped in FIXME.\n"
+					  "Please look up document and set commit.ignoreIntentToAdd to true\n"
+					  "or remove it."));
 		}
 		if (active_cache_changed) {
 			update_main_cache_tree(cache_tree_flags | WRITE_TREE_SILENT);
@@ -1423,6 +1423,9 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 	git_config(git_commit_config, &s);
 	determine_whence(&s);
 
+	if (!set_commit_ignoreintenttoadd)
+		cache_tree_flags |= WRITE_TREE_IGNORE_INTENT_TO_ADD;
+
 	if (get_sha1("HEAD", sha1))
 		current_head = NULL;
 	else {
diff --git a/t/t2203-add-intent.sh b/t/t2203-add-intent.sh
index 88a508e..09b8bbf 100755
--- a/t/t2203-add-intent.sh
+++ b/t/t2203-add-intent.sh
@@ -41,11 +41,11 @@ test_expect_success 'cannot commit with i-t-a entry' '
 	echo frotz >nitfol &&
 	git add rezrov &&
 	git add -N nitfol &&
-	test_must_fail git commit -minitial
+	git commit -minitial
 '
 
 test_expect_success 'can commit tree with i-t-a entry' '
-	git reset --hard &&
+	git reset --hard HEAD^ &&
 	echo xyzzy >rezrov &&
 	echo frotz >nitfol &&
 	git add rezrov &&
-- 
1.7.8.36.g69ee2
Previous: Junio C HamanoNext: Junio C Hamano
Message 16 of 20 in “Deprecate "not allow as-is commit with i-t-a entries"”
  1. 0/4 Deprecate "not allow as-is commit with i-t-a entries"Nguyễn Thái Ngọc Duy, Feb 6, 2012
  2. 1/4 cache-tree: update API to take abitrary flagsNguyễn Thái Ngọc Duy, Feb 6, 2012
  3. Junio C HamanoFeb 6, 2012
  4. 2/4 commit: introduce a config key to allow as-is commit with i-t-a entriesNguyễn Thái Ngọc Duy, Feb 6, 2012
  5. Junio C HamanoFeb 6, 2012
  6. Nguyen Thai Ngoc DuyFeb 7, 2012
  7. Jonathan NiederFeb 7, 2012
  8. Junio C HamanoFeb 6, 2012
  9. Jonathan NiederFeb 6, 2012
  10. Junio C HamanoFeb 6, 2012
  11. Nguyen Thai Ngoc DuyFeb 7, 2012
  12. Junio C HamanoFeb 7, 2012
  13. Junio C HamanoFeb 7, 2012
  14. Nguyen Thai Ngoc DuyFeb 7, 2012
  15. Junio C HamanoFeb 7, 2012
  16. 3/4 commit: turn commit.ignoreIntentToAdd to true by defaultNguyễn Thái Ngọc Duy, Feb 6, 2012
  17. Junio C HamanoFeb 6, 2012
  18. Nguyen Thai Ngoc DuyFeb 7, 2012
  19. 4/4 commit: remove commit.ignoreIntentToAdd, assume it's always trueNguyễn Thái Ngọc Duy, Feb 6, 2012
  20. Junio C HamanoFeb 6, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.