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

[PATCH v3 1/4] read-cache: reindent

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 31, 2026, 12:56 UTC
Message-ID
<20260731125605.3638938-2-gitster@pobox.com>
In-Reply-To
<20260731125605.3638938-1-gitster@pobox.com>

I do not know how this happened without anybody noticing, but a few months ago we added a16c4a245a (read-cache: submodule add need --force given ignore=all configuration, 2026-02-06), and almost all lines the patch added were incorrectly indented.

Reindent these lines so that they play better with surrounding lines in the same file.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 read-cache.c | 70 +++++++++++++++++++++++++++-------------------------
 1 file changed, 36 insertions(+), 34 deletions(-)
diff --git a/read-cache.c b/read-cache.c
index 38b55323dd..58c378414a 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -3910,32 +3910,33 @@ static int fix_unmerged_status(struct diff_filepair *p,
 }
 
 static int skip_submodule(const char *path,
-						struct repository *repo,
-						struct pathspec *pathspec,
-						int ignored_too)
-{
-    struct stat st;
-    const struct submodule *sub;
-    int pathspec_matches = 0;
-    int ps_i;
-    char *norm_pathspec = NULL;
-
-    /* Only consider if path is a directory */
-    if (lstat(path, &st) || !S_ISDIR(st.st_mode))
+			  struct repository *repo,
+			  struct pathspec *pathspec,
+			  int ignored_too)
+{
+	struct stat st;
+	const struct submodule *sub;
+	int pathspec_matches = 0;
+	int ps_i;
+	char *norm_pathspec = NULL;
+
+	/* Only consider if path is a directory */
+	if (lstat(path, &st) || !S_ISDIR(st.st_mode))
 		return 0;
 
-    /* Check if it's a submodule with ignore=all */
-    sub = submodule_from_path(repo, null_oid(the_hash_algo), path);
-    if (!sub || !sub->name || !sub->ignore || strcmp(sub->ignore, "all"))
+	/* Check if it's a submodule with ignore=all */
+	sub = submodule_from_path(repo, null_oid(the_hash_algo), path);
+	if (!sub || !sub->name || !sub->ignore || strcmp(sub->ignore, "all"))
 		return 0;
 
-    trace_printf("ignore=all: %s\n", path);
-    trace_printf("pathspec %s\n", (pathspec && pathspec->nr)
-									? "has pathspec"
-									: "no pathspec");
+	trace_printf("ignore=all: %s\n", path);
+	trace_printf("pathspec %s\n",
+		     ((pathspec && pathspec->nr)
+		      ? "has pathspec"
+		      : "no pathspec"));
 
-    /* Check if submodule path is explicitly mentioned in pathspec */
-    if (pathspec) {
+	/* Check if submodule path is explicitly mentioned in pathspec */
+	if (pathspec) {
 		for (ps_i = 0; ps_i < pathspec->nr; ps_i++) {
 			const char *m = pathspec->items[ps_i].match;
 			if (!m)
@@ -3949,28 +3950,29 @@ static int skip_submodule(const char *path,
 			}
 			FREE_AND_NULL(norm_pathspec);
 		}
-    }
+	}
 
-    /* If explicitly matched and forced, allow adding */
-    if (pathspec_matches) {
+	/* If explicitly matched and forced, allow adding */
+	if (pathspec_matches) {
 		if (ignored_too && ignored_too > 0) {
 			trace_printf("Add submodule due to --force: %s\n", path);
 			return 0;
 		} else {
 			advise_if_enabled(ADVICE_ADD_IGNORED_FILE,
-				_("Skipping submodule due to ignore=all: %s\n"
-					"Use --force if you really want to add the submodule."), path);
+				  _("Skipping submodule due to ignore=all: %s\n"
+				    "Use --force if you really want to "
+				    "add the submodule."), path);
 			return 1;
 		}
-    }
+	}
 
-    /* No explicit pathspec match -> skip silently */
-    trace_printf("Pathspec to submodule does not match explicitly: %s\n", path);
-    return 1;
+	/* No explicit pathspec match -> skip silently */
+	trace_printf("Pathspec to submodule does not match explicitly: %s\n", path);
+	return 1;
 }
 
 static void update_callback(struct diff_queue_struct *q,
-							struct diff_options *opt UNUSED, void *cbdata)
+			    struct diff_options *opt UNUSED, void *cbdata)
 {
 	int i;
 	struct update_callback_data *data = cbdata;
@@ -3980,7 +3982,7 @@ static void update_callback(struct diff_queue_struct *q,
 		const char *path = p->one->path;
 
 		if (!data->include_sparse &&
-			!path_in_sparse_checkout(path, data->index))
+		    !path_in_sparse_checkout(path, data->index))
 			continue;
 
 		switch (fix_unmerged_status(p, data)) {
@@ -3989,8 +3991,8 @@ static void update_callback(struct diff_queue_struct *q,
 		case DIFF_STATUS_MODIFIED:
 		case DIFF_STATUS_TYPE_CHANGED:
 			if (skip_submodule(path, data->repo,
-								data->pathspec,
-								data->ignored_too))
+					   data->pathspec,
+					   data->ignored_too))
 				continue;
 
 			if (add_file_to_index(data->index, path, data->flags)) {
-- 
2.55.0-599-g5cacd2ad51
Previous: Junio C HamanoNext: Junio C Hamano
Message 24 of 30 in “git add --resolved”
  1. 0/4 git add --resolvedJunio C Hamano, Jul 28, 2026
  2. 1/4 merge-ll: consolidate conflict marker scanning logicJunio C Hamano, Jul 28, 2026
  3. 2/4 read-cache: add remove_file_from_index_with_flags()Junio C Hamano, Jul 28, 2026
  4. 3/4 add: introduce '--resolved' optionJunio C Hamano, Jul 28, 2026
  5. Michael MontalboJul 29, 2026
  6. Junio C HamanoJul 29, 2026
  7. Junio C HamanoJul 29, 2026
  8. Junio C HamanoAug 2, 2026
  9. Junio C HamanoJul 29, 2026
  10. Michael MontalboAug 2, 2026
  11. Junio C HamanoAug 2, 2026
  12. Michael MontalboAug 3, 2026
  13. 4/4 read-cache: reindentJunio C Hamano, Jul 28, 2026
  14. 0/4 git add --resolvedJunio C Hamano, Jul 29, 2026
  15. 1/4 read-cache: reindentJunio C Hamano, Jul 29, 2026
  16. 2/4 merge-ll: consolidate conflict marker scanning logicJunio C Hamano, Jul 29, 2026
  17. 3/4 read-cache: add remove_file_from_index_with_flags()Junio C Hamano, Jul 29, 2026
  18. 4/4 add: introduce '--resolved' optionJunio C Hamano, Jul 29, 2026
  19. Junio C HamanoJul 29, 2026
  20. Michael MontalboJul 29, 2026
  21. Junio C HamanoJul 30, 2026
  22. Michael MontalboAug 2, 2026
  23. 0/4 git add --resolvedJunio C Hamano, Jul 31, 2026
  24. 1/4 read-cache: reindentJunio C Hamano, Jul 31, 2026
  25. 2/4 merge-ll: consolidate conflict marker scanning logicJunio C Hamano, Jul 31, 2026
  26. 3/4 read-cache: add remove_file_from_index_with_flags()Junio C Hamano, Jul 31, 2026
  27. 4/4 add: introduce '--resolved' optionJunio C Hamano, Jul 31, 2026
  28. Jeff KingAug 1, 2026
  29. Junio C HamanoAug 1, 2026
  30. Junio C HamanoAug 1, 2026

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.