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

[PATCH 2/5] commit-graph: don't peek into `struct lock_file`

From
MÅMartin Ågren <martin.agren@gmail.com>
Date
Jan 5, 2021, 19:23 UTC
Message-ID
<7a91469c7c791d5faeabc601775a3b535cbfc26e.1609874026.git.martin.agren@gmail.com>
In-Reply-To
<cover.1609874026.git.martin.agren@gmail.com>

Similar to the previous commit, avoid peeking into the `struct lock_file`. Use the lock file API instead.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
---
 commit-graph.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/commit-graph.c b/commit-graph.c
index 06f8dc1d89..031641014f 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -1694,8 +1694,8 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
 	} else {
 		hold_lock_file_for_update_mode(&lk, ctx->graph_name,
 					       LOCK_DIE_ON_ERROR, 0444);
-		fd = lk.tempfile->fd;
-		f = hashfd(lk.tempfile->fd, lk.tempfile->filename.buf);
+		fd = get_lock_file_fd(&lk);
+		f = hashfd(fd, get_lock_file_path(&lk));
 	}
 
 	chunks[0].id = GRAPH_CHUNKID_OIDFANOUT;
@@ -1833,7 +1833,7 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
 		result = rename(ctx->graph_name, final_graph_name);
 
 		for (i = 0; i < ctx->num_commit_graphs_after; i++)
-			fprintf(lk.tempfile->fp, "%s\n", ctx->commit_graph_hash_after[i]);
+			fprintf(get_lock_file_fp(&lk), "%s\n", ctx->commit_graph_hash_after[i]);
 
 		if (result) {
 			error(_("failed to rename temporary commit-graph file"));
-- 
2.30.0
Previous: Martin ÅgrenNext: Martin Ågren
Message 4 of 13 in “avoid peeking into `struct lock_file`”
  1. 0/5 avoid peeking into `struct lock_file`Martin Ågren, Jan 5, 2021
  2. 4/5 refs/files-backend: don't peek into `struct lock_file`Martin Ågren, Jan 5, 2021
  3. 3/5 midx: don't peek into `struct lock_file`Martin Ågren, Jan 5, 2021
  4. 2/5 commit-graph: don't peek into `struct lock_file`Martin Ågren, Jan 5, 2021
  5. 1/5 builtin/gc: don't peek into `struct lock_file`Martin Ågren, Jan 5, 2021
  6. 5/5 read-cache: try not to peek into `struct {lock_,temp}file`Martin Ågren, Jan 5, 2021
  7. Derrick StoleeJan 6, 2021
  8. Junio C HamanoJan 6, 2021
  9. Junio C HamanoJan 6, 2021
  10. Derrick StoleeJan 7, 2021
  11. Martin ÅgrenJan 7, 2021
  12. Junio C HamanoJan 7, 2021
  13. Martin ÅgrenJan 7, 2021

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.