Merge branch 'ps/remote-rename-fix'

"git remote rename origin upstream" failed to move origin/HEAD to
upstream/HEAD when origin/HEAD is unborn and performed other
renames extremely inefficiently, which has been corrected.

* ps/remote-rename-fix:
  builtin/remote: only iterate through refs that are to be renamed
  builtin/remote: rework how remote refs get renamed
  builtin/remote: determine whether refs need renaming early on
  builtin/remote: fix sign comparison warnings
  refs: simplify logic when migrating reflog entries
  refs: pass refname when invoking reflog entry callback
This commit is contained in:
Junio C Hamano
2025-08-21 13:46:58 -07:00
19 changed files with 372 additions and 200 deletions

13
refs.h
View File

@@ -428,6 +428,8 @@ int refs_for_each_namespaced_ref(struct ref_store *refs,
/* can be used to learn about broken ref and symref */
int refs_for_each_rawref(struct ref_store *refs, each_ref_fn fn, void *cb_data);
int refs_for_each_rawref_in(struct ref_store *refs, const char *prefix,
each_ref_fn fn, void *cb_data);
/*
* Iterates over all refs including root refs, i.e. pseudorefs and HEAD.
@@ -558,10 +560,13 @@ int refs_delete_reflog(struct ref_store *refs, const char *refname);
* The cb_data is a caller-supplied pointer given to the iterator
* functions.
*/
typedef int each_reflog_ent_fn(
struct object_id *old_oid, struct object_id *new_oid,
const char *committer, timestamp_t timestamp,
int tz, const char *msg, void *cb_data);
typedef int each_reflog_ent_fn(const char *refname,
struct object_id *old_oid,
struct object_id *new_oid,
const char *committer,
timestamp_t timestamp,
int tz, const char *msg,
void *cb_data);
/* Iterate over reflog entries in the log for `refname`. */