From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
"Jonathan Nieder" <jrnieder@gmail.com>,
"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH v2 3/4] commit: turn commit.ignoreIntentToAdd to true by default
Date: Tue, 7 Feb 2012 19:46:43 +0700 [thread overview]
Message-ID: <1328618804-31796-4-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <1328618804-31796-1-git-send-email-pclouds@gmail.com>
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@gmail.com>
---
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
next prev parent reply other threads:[~2012-02-07 12:42 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-07 12:46 [PATCH v2 0/4] Deprecate "not allow as-is commit with i-t-a entries" Nguyễn Thái Ngọc Duy
2012-02-07 12:46 ` [PATCH v2 1/4] cache-tree: update API to take abitrary flags Nguyễn Thái Ngọc Duy
2012-02-07 12:46 ` [PATCH v2 2/4] commit: introduce a config key to allow as-is commit with i-t-a entries Nguyễn Thái Ngọc Duy
2012-02-07 12:46 ` Nguyễn Thái Ngọc Duy [this message]
2012-02-07 12:46 ` [PATCH v2 4/4] commit: remove commit.ignoreIntentToAdd, assume it's always true Nguyễn Thái Ngọc Duy
2012-02-07 16:41 ` [PATCH v2 0/4] Deprecate "not allow as-is commit with i-t-a entries" Junio C Hamano
2012-02-07 19:55 ` Junio C Hamano
2012-02-08 4:03 ` Nguyen Thai Ngoc Duy
2012-02-08 17:34 ` Junio C Hamano
2012-02-09 2:23 ` Nguyen Thai Ngoc Duy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1328618804-31796-4-git-send-email-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jrnieder@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).