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

[PATCH/RFC 4/4] commit: reinstate commit behavior before 3f6d56d via a config option

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Jun 6, 2016, 11:16 UTC
Message-ID
<20160606111643.7122-5-pclouds@gmail.com>
In-Reply-To
<20160606111643.7122-1-pclouds@gmail.com>

There are two groups of users with regards to "git add -N". One uses i-t-a as a reminder that certain untracked files must be added before the next commit. Erroring when i-t-a entries are still present (i.e. real content not added) out gives the user a chance to add real content.

The other group that sees i-t-a entries as a way to make Git aware of some untracked paths so that "git diff" and "git status" show them correctly. If they decide that some content should be staged for the next commit, they "git add" again for real. If content in these paths is never added, the paths are simply ignored.

3f6d56d (commit: ignore intent-to-add entries instead of refusing - 2012-02-07) changes the behavior from the former to the latter. This patch brings bach the former behavior if core.errorCommitIta is true.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 cache-tree.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/cache-tree.c b/cache-tree.c
index ddf0cc9..b87bd3c 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -155,20 +155,28 @@ static int verify_cache(struct cache_entry **cache,
 {
 	int i, funny;
 	int silent = flags & WRITE_TREE_SILENT;
+	int core_error_commit_ita = 0;
+
+	git_config_get_bool("core.errorcommitita", &core_error_commit_ita);
 
 	/* Verify that the tree is merged */
 	funny = 0;
 	for (i = 0; i < entries; i++) {
 		const struct cache_entry *ce = cache[i];
-		if (ce_stage(ce)) {
+		if (ce_stage(ce) ||
+		    (core_error_commit_ita && ce_intent_to_add(ce))) {
 			if (silent)
 				return -1;
 			if (10 < ++funny) {
 				fprintf(stderr, "...\n");
 				break;
 			}
-			fprintf(stderr, "%s: unmerged (%s)\n",
-				ce->name, sha1_to_hex(ce->sha1));
+			if (ce_stage(ce))
+				fprintf(stderr, "%s: unmerged (%s)\n",
+					ce->name, sha1_to_hex(ce->sha1));
+			else
+				fprintf(stderr, "%s: not added yet\n",
+					ce->name);
 		}
 	}
 	if (funny)
-- 
2.8.2.524.g6ff3d78
Previous: Junio C Hamano
Message 15 of 15 in “i-t-a entries again...”
  1. 0/4 i-t-a entries again...Nguyễn Thái Ngọc Duy, Jun 6, 2016
  2. 1/4 diff.h: extend "flags" field to 64 bits because we're out of bitsNguyễn Thái Ngọc Duy, Jun 6, 2016
  3. Junio C HamanoJun 6, 2016
  4. Duy NguyenJun 7, 2016
  5. stefan.naewe@atlas-elektronik.comJun 7, 2016
  6. 2/4 Resurrect "diff-lib.c: adjust position of i-t-a entries in diff"Nguyễn Thái Ngọc Duy, Jun 6, 2016
  7. Junio C HamanoJun 6, 2016
  8. Duy NguyenJun 7, 2016
  9. Johannes SchindelinJun 9, 2016
  10. Duy NguyenSep 27, 2016
  11. Duy NguyenSep 27, 2016
  12. 3/4 commit: don't count i-t-a entries when checking if the new commit is emptyNguyễn Thái Ngọc Duy, Jun 6, 2016
  13. Junio C HamanoJun 6, 2016
  14. Junio C HamanoJun 6, 2016
  15. 4/4 commit: reinstate commit behavior before 3f6d56d via a config optionNguyễn Thái Ngọc Duy, Jun 6, 2016

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.