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

Re: [PATCH 1/4] refs: pass refname when invoking reflog entry callback

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 28, 2025, 16:07 UTC
Message-ID
<xmqqv7ncwb73.fsf@gitster.g>
In-Reply-To
<20250728-pks-remote-rename-improvements-v1-1-f654f2b5c5ae@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 22 quoted lines
> -static int fsck_handle_reflog_ent(struct object_id *ooid, struct object_id *noid,
> +static int fsck_handle_reflog_ent(const char *refname,
> +				  struct object_id *ooid, struct object_id *noid,
>  				  const char *email UNUSED,
>  				  timestamp_t timestamp, int tz UNUSED,
> -				  const char *message UNUSED, void *cb_data)
> +				  const char *message UNUSED, void *cb_data UNUSED)
>  {
> -	const char *refname = cb_data;
> -
>  	if (verbose)
>  		fprintf_ln(stderr, _("Checking reflog %s->%s"),
>  			   oid_to_hex(ooid), oid_to_hex(noid));
> @@ -525,7 +524,7 @@ static int fsck_handle_reflog(const char *logname, void *cb_data)
>  	strbuf_worktree_ref(cb_data, &refname, logname);
>  	refs_for_each_reflog_ent(get_main_ref_store(the_repository),
>  				 refname.buf, fsck_handle_reflog_ent,
> -				 refname.buf);
> +				 NULL);
>  	strbuf_release(&refname);
>  	return 0;
>  }

Nice. There are a few callsites that passed refname as (a part of) cb_data, like this one ...

Show 29 quoted lines
> diff --git a/refs.c b/refs.c
> index 4bd80287054..fd9a5f36b20 100644
> --- a/refs.c
> +++ b/refs.c
> @@ -1022,7 +1022,6 @@ int is_branch(const char *refname)
>  }
>  
>  struct read_ref_at_cb {
> -	const char *refname;
>  	timestamp_t at_time;
>  	int cnt;
>  	int reccnt;
> @@ -1052,7 +1051,8 @@ static void set_read_ref_cutoffs(struct read_ref_at_cb *cb,
>  		*cb->cutoff_cnt = cb->reccnt;
>  }
>  
> -static int read_ref_at_ent(struct object_id *ooid, struct object_id *noid,
> +static int read_ref_at_ent(const char *refname,
> +			   struct object_id *ooid, struct object_id *noid,
>  			   const char *email UNUSED,
>  			   timestamp_t timestamp, int tz,
>  			   const char *message, void *cb_data)
> @@ -1072,13 +1072,13 @@ static int read_ref_at_ent(struct object_id *ooid, struct object_id *noid,
>  			oidcpy(cb->oid, noid);
>  			if (!oideq(&cb->ooid, noid))
>  				warning(_("log for ref %s has gap after %s"),
> -					cb->refname, show_date(cb->date, cb->tz, DATE_MODE(RFC2822)));
> +					refname, show_date(cb->date, cb->tz, DATE_MODE(RFC2822)));
>  		}
... that makes quite sense.
Previous: Justin ToblerNext: Karthik Nayak
Message 4 of 37 in “builtin/remote: rework how remote refs get renamed”
  1. 0/4 builtin/remote: rework how remote refs get renamedPatrick Steinhardt, Jul 28, 2025
  2. 1/4 refs: pass refname when invoking reflog entry callbackPatrick Steinhardt, Jul 28, 2025
  3. Justin ToblerJul 28, 2025
  4. Junio C HamanoJul 28, 2025
  5. Karthik NayakJul 29, 2025
  6. Patrick SteinhardtJul 31, 2025
  7. 2/4 refs: simplify logic when migrating reflog entriesPatrick Steinhardt, Jul 28, 2025
  8. Justin ToblerJul 28, 2025
  9. Junio C HamanoJul 28, 2025
  10. 3/4 builtin/remote: rework how remote refs get renamedPatrick Steinhardt, Jul 28, 2025
  11. Junio C HamanoJul 28, 2025
  12. Patrick SteinhardtJul 29, 2025
  13. Justin ToblerJul 28, 2025
  14. Junio C HamanoJul 28, 2025
  15. Patrick SteinhardtJul 29, 2025
  16. Jeff KingJul 29, 2025
  17. Patrick SteinhardtJul 29, 2025
  18. Jeff KingAug 2, 2025
  19. 4/4 builtin/remote: only iterate through refs that are to be renamedPatrick Steinhardt, Jul 28, 2025
  20. Junio C HamanoJul 28, 2025
  21. Karthik NayakJul 30, 2025
  22. Patrick SteinhardtJul 31, 2025
  23. Junio C HamanoJul 28, 2025
  24. 0/6 builtin/remote: rework how remote refs get renamedPatrick Steinhardt, Jul 31, 2025
  25. 1/6 refs: pass refname when invoking reflog entry callbackPatrick Steinhardt, Jul 31, 2025
  26. 2/6 refs: simplify logic when migrating reflog entriesPatrick Steinhardt, Jul 31, 2025
  27. 3/6 builtin/remote: fix sign comparison warningsPatrick Steinhardt, Jul 31, 2025
  28. 4/6 builtin/remote: determine whether refs need renaming early onPatrick Steinhardt, Jul 31, 2025
  29. 5/6 builtin/remote: rework how remote refs get renamedPatrick Steinhardt, Jul 31, 2025
  30. Jeff KingAug 2, 2025
  31. Patrick SteinhardtAug 4, 2025
  32. 6/6 builtin/remote: only iterate through refs that are to be renamedPatrick Steinhardt, Jul 31, 2025
  33. Junio C HamanoJul 31, 2025
  34. Patrick SteinhardtAug 1, 2025
  35. Junio C HamanoAug 1, 2025
  36. Patrick SteinhardtAug 4, 2025
  37. Junio C HamanoAug 4, 2025

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.