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

[PATCH] archive: deduplicate verbose printing

From
René Scharfe <l.s.r@web.de>
Date
Oct 11, 2022, 09:29 UTC
Message-ID
<af5611aa-8662-7508-4f00-7fcf4e9cbcc6@web.de>

94bc671a1f (Add directory pattern matching to attributes, 2012-12-08) moved the code for adding the trailing slash to names of directories and submodules up. This left both branches of the if statement starting with the same conditional fprintf call. Deduplicate it.

Signed-off-by: René Scharfe <l.s.r@web.de>
---
 archive.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/archive.c b/archive.c
index 61a79e4a22..cc1087262f 100644
--- a/archive.c
+++ b/archive.c
@@ -166,18 +166,16 @@ static int write_archive_entry(const struct object_id *oid, const char *base,
 		args->convert = check_attr_export_subst(check);
 	}

+	if (args->verbose)
+		fprintf(stderr, "%.*s\n", (int)path.len, path.buf);
+
 	if (S_ISDIR(mode) || S_ISGITLINK(mode)) {
-		if (args->verbose)
-			fprintf(stderr, "%.*s\n", (int)path.len, path.buf);
 		err = write_entry(args, oid, path.buf, path.len, mode, NULL, 0);
 		if (err)
 			return err;
 		return (S_ISDIR(mode) ? READ_TREE_RECURSIVE : 0);
 	}

-	if (args->verbose)
-		fprintf(stderr, "%.*s\n", (int)path.len, path.buf);
-
 	/* Stream it? */
 	if (S_ISREG(mode) && !args->convert &&
 	    oid_object_info(args->repo, oid, &size) == OBJ_BLOB &&
--
2.38.0
Next: Ævar Arnfjörð Bjarmason
Message 1 of 5 in “archive: deduplicate verbose printing”
  1. archive: deduplicate verbose printingRené Scharfe, Oct 11, 2022
  2. Ævar Arnfjörð BjarmasonOct 11, 2022
  3. René ScharfeOct 13, 2022
  4. Eric SunshineOct 13, 2022
  5. Junio C HamanoOct 13, 2022

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.