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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is step 2 from commit.ignoreIntentToAdd deprecation plan. To
recap:

2. A few releases after step 1 is out in the field, turn
commit.ignoreIntentToAdd default value to true (affecting mostly new
users).

Those who decided to stick to "false" from step 1 are warned the "false"
support will soon be gone and encouraged to move to "true" (or simply
remove the config variable).

Those who set the config to "true" is advised to remove it to keep
config file clean.

Those who encountered the safety check and did not bother to set this
config var is left out in the cold.

3. A few more releases after step 2, commit.ignoreIntentToAdd is
removed. There's no way to bring back the safety check.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx>
---
 Documentation/config.txt |   11 ++++-------
 builtin/commit.c         |   19 ++++++++++++++++---
 t/t2203-add-intent.sh    |    4 ++--
 3 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 6839e44..fa56753 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -839,13 +839,10 @@ commit.ignoreIntentToAdd::
 	these entries.  Setting this to `true` makes `git commit`
 	pretend as if these entries do not exist in the index.
 +
-The default for this variable is `false`, but it will change to `true`
-in future releases of git. To ease the transition, you may want to set
-it to `true` now and get used to the new behaviour early, or you may
-want to set it to `false` to keep the old behaviour a bit longer. We
-however expect to support setting this to `false` (to keep the current
-behaviour) only for a limited time after the default is changed to
-`true`.
+The default for this variable is `true`. You are discouraged to set it
+to `false` to keep the old behaviour a bit longer because support
+setting this to `false` will be removed in future releases without
+warning.
 
 credential.helper::
 	Specify an external helper to be called when a username or
diff --git a/builtin/commit.c b/builtin/commit.c
index da67653..cd28081 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -423,15 +423,16 @@ 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) {
 				error(_("you intended to add \"%s\" but did not add it; not committing\n"
-					"hint: to commit all changes to tracked files, use \"commit -a\"\n"
-					"hint: to commit anyway without adding, set commit.ignoreIntentToAdd to true"),
+					"this behavior is deprecated, please set commit.ignoreIntentToAdd\n"
+					"to true or remove the configuration variable. See the configuration\n"
+					"variable documentation for more information."),
 				      active_cache[i]->name);
 				exit(128); /* die() */
 			}
@@ -1424,6 +1425,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 {
@@ -1583,5 +1587,14 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 	if (!quiet)
 		print_summary(prefix, sha1, !current_head);
 
+	if (set_commit_ignoreintenttoadd) {
+		if (cache_tree_flags & WRITE_TREE_IGNORE_INTENT_TO_ADD)
+			warning(_("commit.ignoreIntentToAdd = true is not needed anymore.\n"
+				  "Please remove it."));
+		else
+			warning(_("commit.ignoreIntentToAdd = false is deprecated.\n"
+				  "Please see the commit.ignoreIntentToAdd documentation for\n"
+				  "more information and remove the configuration variable."));
+	}
 	return 0;
 }
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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]