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

[PATCH 3/4] pack-write: drop always-NULL parameter

From
Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>
Date
Jun 14, 2022, 21:27 UTC
Message-ID
<b67e110bf60e820874de94c64ee8c32d69413877.1655242070.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.1261.git.1655242070.gitgitgadget@gmail.com>
From: Derrick Stolee <derrickstolee@github.com>

write_mtimes_file() takes an mtimes parameter as its first option, but the only caller passes a NULL constant. Drop this parameter to simplify logic. This can be reverted if that parameter is needed in the future.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
---
 pack-write.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/pack-write.c b/pack-write.c
index 23c0342018f..00787e306db 100644
--- a/pack-write.c
+++ b/pack-write.c
@@ -310,26 +310,21 @@ static void write_mtimes_trailer(struct hashfile *f, const unsigned char *hash)
 	hashwrite(f, hash, the_hash_algo->rawsz);
 }
 
-static const char *write_mtimes_file(const char *mtimes_name,
-				     struct packing_data *to_pack,
+static const char *write_mtimes_file(struct packing_data *to_pack,
 				     struct pack_idx_entry **objects,
 				     uint32_t nr_objects,
 				     const unsigned char *hash)
 {
+	struct strbuf tmp_file = STRBUF_INIT;
+	const char *mtimes_name;
 	struct hashfile *f;
 	int fd;
 
 	if (!to_pack)
 		BUG("cannot call write_mtimes_file with NULL packing_data");
 
-	if (!mtimes_name) {
-		struct strbuf tmp_file = STRBUF_INIT;
-		fd = odb_mkstemp(&tmp_file, "pack/tmp_mtimes_XXXXXX");
-		mtimes_name = strbuf_detach(&tmp_file, NULL);
-	} else {
-		unlink(mtimes_name);
-		fd = xopen(mtimes_name, O_CREAT|O_EXCL|O_WRONLY, 0600);
-	}
+	fd = odb_mkstemp(&tmp_file, "pack/tmp_mtimes_XXXXXX");
+	mtimes_name = strbuf_detach(&tmp_file, NULL);
 	f = hashfd(fd, mtimes_name);
 
 	write_mtimes_header(f);
@@ -561,7 +556,7 @@ void stage_tmp_packfiles(struct strbuf *name_buffer,
 				      pack_idx_opts->flags);
 
 	if (pack_idx_opts->flags & WRITE_MTIMES) {
-		mtimes_tmp_name = write_mtimes_file(NULL, to_pack, written_list,
+		mtimes_tmp_name = write_mtimes_file(to_pack, written_list,
 						    nr_written,
 						    hash);
 	}
-- 
gitgitgadget
Previous: Derrick StoleeNext: Derrick Stolee via GitGitGadget
Message 8 of 15 in “Reactions to v2.37.0-rc0 test coverage report”
  1. 0/4 Reactions to v2.37.0-rc0 test coverage reportDerrick Stolee via GitGitGadget, Jun 14, 2022
  2. 1/4 t2107: test 'git update-index --verbose'Derrick Stolee via GitGitGadget, Jun 14, 2022
  3. Eric SunshineJun 15, 2022
  4. Derrick StoleeJun 16, 2022
  5. 2/4 t5329: test 'git gc --cruft' without '--prune=now'Derrick Stolee via GitGitGadget, Jun 14, 2022
  6. Taylor BlauJun 14, 2022
  7. Derrick StoleeJun 15, 2022
  8. 3/4 pack-write: drop always-NULL parameterDerrick Stolee via GitGitGadget, Jun 14, 2022
  9. 4/4 cache-tree: remove cache_tree_find_path()Derrick Stolee via GitGitGadget, Jun 14, 2022
  10. 0/4 Reactions to v2.37.0-rc0 test coverage reportDerrick Stolee via GitGitGadget, Jun 16, 2022
  11. 1/4 t2107: test 'git update-index --verbose'Derrick Stolee via GitGitGadget, Jun 16, 2022
  12. 2/4 t5329: test 'git gc --cruft' without '--prune=now'Derrick Stolee via GitGitGadget, Jun 16, 2022
  13. 3/4 pack-write: drop always-NULL parameterDerrick Stolee via GitGitGadget, Jun 16, 2022
  14. 4/4 cache-tree: remove cache_tree_find_path()Derrick Stolee via GitGitGadget, Jun 16, 2022
  15. Junio C HamanoJun 16, 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.