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

[PATCH 2/3] for_each_recent_reflog_ent(): simplify opening of a reflog file

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 8, 2013, 21:53 UTC
Message-ID
<1362779624-15513-3-git-send-email-gitster@pobox.com>
In-Reply-To
<1362779624-15513-1-git-send-email-gitster@pobox.com>
There is no reason to use a temporary variable logfile.
---
 refs.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/refs.c b/refs.c
index 9f702a7..e302521 100644
--- a/refs.c
+++ b/refs.c
@@ -2320,13 +2320,11 @@ static int show_one_reflog_ent(struct strbuf *sb, each_reflog_ent_fn fn, void *c
 
 int for_each_recent_reflog_ent(const char *refname, each_reflog_ent_fn fn, long ofs, void *cb_data)
 {
-	const char *logfile;
 	FILE *logfp;
 	struct strbuf sb = STRBUF_INIT;
 	int ret = 0;
 
-	logfile = git_path("logs/%s", refname);
-	logfp = fopen(logfile, "r");
+	logfp = fopen(git_path("logs/%s", refname), "r");
 	if (!logfp)
 		return -1;
 
-- 
1.8.2-rc3-189-g94c4d42
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 4 in “Enumerating reflog entries in a wrong order”
  1. 0/3 Enumerating reflog entries in a wrong orderJunio C Hamano, Mar 8, 2013
  2. 1/3 for_each_reflog_ent(): extract a helper to process a single entryJunio C Hamano, Mar 8, 2013
  3. 2/3 for_each_recent_reflog_ent(): simplify opening of a reflog fileJunio C Hamano, Mar 8, 2013
  4. 3/3 reflog: add for_each_reflog_ent_reverse() APIJunio C Hamano, Mar 8, 2013

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.