git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] refs.h: make all flags arguments unsigned
@ 2022-01-31 20:15 Han-Wen Nienhuys via GitGitGadget
  2022-02-01  2:02 ` Junio C Hamano
  2022-02-01 12:46 ` [PATCH v2] " Han-Wen Nienhuys via GitGitGadget
  0 siblings, 2 replies; 17+ messages in thread
From: Han-Wen Nienhuys via GitGitGadget @ 2022-01-31 20:15 UTC (permalink / raw)
  To: git; +Cc: Han-Wen Nienhuys, Han-Wen Nienhuys

From: Han-Wen Nienhuys <hanwen@google.com>

As discussed in
https://lore.kernel.org/git/xmqqbkzrkevo.fsf@gitster.g/ , we don't
want to treat the sign bit specially, so make all flags in refs.h
unsigned.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
---
    refs.h: make all flags arguments unsigned
    
    As discussed in https://lore.kernel.org/git/xmqqbkzrkevo.fsf@gitster.g/
    , we don't want to treat the sign bit specially, so make all flags in
    refs.h unsigned.
    
    Signed-off-by: Han-Wen Nienhuys hanwen@google.com

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1210%2Fhanwen%2Funsigned-flags-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1210/hanwen/unsigned-flags-v1
Pull-Request: https://github.com/git/git/pull/1210

 bisect.c                    |  4 +--
 builtin/bisect--helper.c    |  7 ++---
 builtin/branch.c            |  4 +--
 builtin/checkout.c          |  9 ++++---
 builtin/describe.c          |  3 ++-
 builtin/fetch.c             | 10 +++----
 builtin/fsck.c              |  4 +--
 builtin/gc.c                |  5 ++--
 builtin/name-rev.c          |  3 ++-
 builtin/pack-objects.c      | 11 ++++----
 builtin/rebase.c            |  5 ++--
 builtin/receive-pack.c      |  4 +--
 builtin/reflog.c            |  5 ++--
 builtin/remote.c            | 13 ++++++----
 builtin/repack.c            |  4 +--
 builtin/replace.c           |  4 +--
 builtin/rev-parse.c         |  6 +++--
 builtin/show-branch.c       |  6 ++---
 builtin/show-ref.c          |  4 +--
 builtin/stash.c             |  2 +-
 builtin/submodule--helper.c |  4 +--
 builtin/symbolic-ref.c      |  2 +-
 bundle.c                    |  2 +-
 commit-graph.c              |  5 ++--
 config.c                    |  2 +-
 delta-islands.c             |  2 +-
 fetch-pack.c                |  7 ++---
 help.c                      |  2 +-
 http-backend.c              |  4 +--
 log-tree.c                  |  4 +--
 ls-refs.c                   |  4 +--
 midx.c                      |  5 ++--
 negotiator/default.c        |  2 +-
 negotiator/skipping.c       |  2 +-
 notes.c                     |  5 ++--
 object-name.c               |  2 +-
 reachable.c                 |  2 +-
 ref-filter.c                |  3 ++-
 refs.c                      | 52 ++++++++++++++++++-------------------
 refs.h                      | 38 ++++++++++++---------------
 refs/files-backend.c        | 17 ++++++------
 remote.c                    | 10 +++----
 replace-object.c            |  7 +++--
 revision.c                  |  8 +++---
 server-info.c               |  2 +-
 shallow.c                   |  4 +--
 submodule.c                 |  4 +--
 t/helper/test-ref-store.c   |  4 +--
 transport-helper.c          |  2 +-
 transport.c                 |  2 +-
 upload-pack.c               |  8 +++---
 walker.c                    |  2 +-
 worktree.c                  |  6 ++---
 53 files changed, 171 insertions(+), 167 deletions(-)

diff --git a/bisect.c b/bisect.c
index 888949fba6b..264d60d8e3d 100644
--- a/bisect.c
+++ b/bisect.c
@@ -441,7 +441,7 @@ void find_bisection(struct commit_list **commit_list, int *reaches,
 }
 
 static int register_ref(const char *refname, const struct object_id *oid,
-			int flags, void *cb_data)
+			unsigned int flags, void *cb_data)
 {
 	struct strbuf good_prefix = STRBUF_INIT;
 	strbuf_addstr(&good_prefix, term_good);
@@ -1146,7 +1146,7 @@ int estimate_bisect_steps(int all)
 }
 
 static int mark_for_removal(const char *refname, const struct object_id *oid,
-			    int flag, void *cb_data)
+			    unsigned int flag, void *cb_data)
 {
 	struct string_list *refs = cb_data;
 	char *ref = xstrfmt("refs/bisect%s", refname);
diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c
index 28a2e6a5750..976196eb57c 100644
--- a/builtin/bisect--helper.c
+++ b/builtin/bisect--helper.c
@@ -330,7 +330,7 @@ static int check_and_set_terms(struct bisect_terms *terms, const char *cmd)
 }
 
 static int mark_good(const char *refname, const struct object_id *oid,
-		     int flag, void *cb_data)
+		     unsigned int flag, void *cb_data)
 {
 	int *m_good = (int *)cb_data;
 	*m_good = 0;
@@ -477,7 +477,7 @@ finish:
 }
 
 static int add_bisect_ref(const char *refname, const struct object_id *oid,
-			  int flags, void *cb)
+			  unsigned int flags, void *cb)
 {
 	struct add_bisect_ref_data *data = cb;
 
@@ -617,7 +617,8 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, const char **a
 	int no_checkout = 0;
 	int first_parent_only = 0;
 	int i, has_double_dash = 0, must_write_terms = 0, bad_seen = 0;
-	int flags, pathspec_pos;
+	int pathspec_pos;
+	unsigned int flags;
 	enum bisect_error res = BISECT_OK;
 	struct string_list revs = STRING_LIST_INIT_DUP;
 	struct string_list states = STRING_LIST_INIT_DUP;
diff --git a/builtin/branch.c b/builtin/branch.c
index 4ce2a247542..542eb2e4d50 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -234,7 +234,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
 
 	for (i = 0; i < argc; i++, strbuf_reset(&bname)) {
 		char *target = NULL;
-		int flags = 0;
+		unsigned int flags = 0;
 
 		strbuf_branchname(&bname, argv[i], allowed_interpret);
 		free(name);
@@ -469,7 +469,7 @@ static void print_ref_list(struct ref_filter *filter, struct ref_sorting *sortin
 
 static void print_current_branch_name(void)
 {
-	int flags;
+	unsigned int flags;
 	const char *refname = resolve_ref_unsafe("HEAD", 0, NULL, &flags);
 	const char *shortname;
 	if (!refname)
diff --git a/builtin/checkout.c b/builtin/checkout.c
index cc804ba8e1e..c6a2db4964d 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -968,7 +968,7 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
 
 static int add_pending_uninteresting_ref(const char *refname,
 					 const struct object_id *oid,
-					 int flags, void *cb_data)
+					 unsigned int flags, void *cb_data)
 {
 	add_pending_oid(cb_data, refname, oid, UNINTERESTING);
 	return 0;
@@ -1077,7 +1077,8 @@ static int switch_branches(const struct checkout_opts *opts,
 	int ret = 0;
 	struct branch_info old_branch_info = { 0 };
 	struct object_id rev;
-	int flag, writeout_error = 0;
+	int writeout_error = 0;
+	unsigned int flag;
 	int do_merge = 1;
 
 	trace2_cmd_mode("branch");
@@ -1503,7 +1504,7 @@ static int checkout_branch(struct checkout_opts *opts,
 
 	if (new_branch_info->path && !opts->force_detach && !opts->new_branch &&
 	    !opts->ignore_other_worktrees) {
-		int flag;
+		unsigned int flag;
 		char *head_ref = resolve_refdup("HEAD", 0, NULL, &flag);
 		if (head_ref &&
 		    (!(flag & REF_ISSYMREF) || strcmp(head_ref, new_branch_info->path)))
@@ -1513,7 +1514,7 @@ static int checkout_branch(struct checkout_opts *opts,
 
 	if (!new_branch_info->commit && opts->new_branch) {
 		struct object_id rev;
-		int flag;
+		unsigned int flag;
 
 		if (!read_ref_full("HEAD", 0, &rev, &flag) &&
 		    (flag & REF_ISSYMREF) && is_null_oid(&rev))
diff --git a/builtin/describe.c b/builtin/describe.c
index 42159cd26bd..5fa5b0bb424 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -140,7 +140,8 @@ static void add_to_known_names(const char *path,
 	}
 }
 
-static int get_name(const char *path, const struct object_id *oid, int flag, void *cb_data)
+static int get_name(const char *path, const struct object_id *oid,
+		    unsigned int flag, void *cb_data)
 {
 	int is_tag = 0;
 	struct object_id peeled;
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 5f06b21f8e9..08a240f2d33 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -323,9 +323,8 @@ static struct refname_hash_entry *refname_hash_add(struct hashmap *map,
 	return ent;
 }
 
-static int add_one_refname(const char *refname,
-			   const struct object_id *oid,
-			   int flag, void *cbdata)
+static int add_one_refname(const char *refname, const struct object_id *oid,
+			   unsigned int flag, void *cbdata)
 {
 	struct hashmap *refname_map = cbdata;
 
@@ -1429,9 +1428,8 @@ static void set_option(struct transport *transport, const char *name, const char
 			name, transport->url);
 }
 
-
-static int add_oid(const char *refname, const struct object_id *oid, int flags,
-		   void *cb_data)
+static int add_oid(const char *refname, const struct object_id *oid,
+		   unsigned int flags, void *cb_data)
 {
 	struct oid_array *oids = cb_data;
 
diff --git a/builtin/fsck.c b/builtin/fsck.c
index 9e54892311d..8e3f773e3dd 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -502,7 +502,7 @@ static int fsck_handle_reflog_ent(struct object_id *ooid, struct object_id *noid
 }
 
 static int fsck_handle_reflog(const char *logname, const struct object_id *oid,
-			      int flag, void *cb_data)
+			      unsigned int flag, void *cb_data)
 {
 	struct strbuf refname = STRBUF_INIT;
 
@@ -513,7 +513,7 @@ static int fsck_handle_reflog(const char *logname, const struct object_id *oid,
 }
 
 static int fsck_handle_ref(const char *refname, const struct object_id *oid,
-			   int flag, void *cb_data)
+			   unsigned int flag, void *cb_data)
 {
 	struct object *obj;
 
diff --git a/builtin/gc.c b/builtin/gc.c
index 8e60ef1eaba..2eae43a6bb1 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -768,9 +768,8 @@ struct cg_auto_data {
 	int limit;
 };
 
-static int dfs_on_ref(const char *refname,
-		      const struct object_id *oid, int flags,
-		      void *cb_data)
+static int dfs_on_ref(const char *refname, const struct object_id *oid,
+		      unsigned int flags, void *cb_data)
 {
 	struct cg_auto_data *data = (struct cg_auto_data *)cb_data;
 	int result = 0;
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index 27f60153a6c..465652d5e37 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -305,7 +305,8 @@ static int cmp_by_tag_and_age(const void *a_, const void *b_)
 	return a->taggerdate != b->taggerdate;
 }
 
-static int name_ref(const char *path, const struct object_id *oid, int flags, void *cb_data)
+static int name_ref(const char *path, const struct object_id *oid,
+		    unsigned int flags, void *cb_data)
 {
 	struct object *o = parse_object(the_repository, oid);
 	struct name_ref_data *data = cb_data;
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index ba2006f2212..16c47bb09ab 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -758,8 +758,8 @@ static enum write_one_status write_one(struct hashfile *f,
 	return WRITE_ONE_WRITTEN;
 }
 
-static int mark_tagged(const char *path, const struct object_id *oid, int flag,
-		       void *cb_data)
+static int mark_tagged(const char *path, const struct object_id *oid,
+		       unsigned int flag, void *cb_data)
 {
 	struct object_id peeled;
 	struct object_entry *entry = packlist_find(&to_pack, oid);
@@ -3012,7 +3012,8 @@ static void add_tag_chain(const struct object_id *oid)
 	}
 }
 
-static int add_ref_tag(const char *tag, const struct object_id *oid, int flag, void *cb_data)
+static int add_ref_tag(const char *tag, const struct object_id *oid,
+		       unsigned int flag, void *cb_data)
 {
 	struct object_id peeled;
 
@@ -3684,8 +3685,8 @@ static void record_recent_commit(struct commit *commit, void *data)
 }
 
 static int mark_bitmap_preferred_tip(const char *refname,
-				     const struct object_id *oid, int flags,
-				     void *_data)
+				     const struct object_id *oid,
+				     unsigned int flags, void *_data)
 {
 	struct object_id peeled;
 	struct object *object;
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 36490d06c8a..d92bd3b7175 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -999,7 +999,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 {
 	struct rebase_options options = REBASE_OPTIONS_INIT;
 	const char *branch_name;
-	int ret, flags, total_argc, in_progress = 0;
+	int ret, total_argc, in_progress = 0;
+	unsigned int flags;
 	int keep_base = 0;
 	int ok_to_skip_pre_rebase = 0;
 	struct strbuf msg = STRBUF_INIT;
@@ -1668,7 +1669,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 	if (can_fast_forward(options.onto, options.upstream, options.restrict_revision,
 		    &options.orig_head, &merge_base) &&
 	    allow_preemptive_ff) {
-		int flag;
+		unsigned int flag;
 
 		if (!(options.flags & REBASE_FORCE)) {
 			/* Lazily switch to the target branch if needed... */
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 9f4a0b816cf..82e4aae8113 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -291,7 +291,7 @@ static void show_ref(const char *path, const struct object_id *oid)
 }
 
 static int show_ref_cb(const char *path_full, const struct object_id *oid,
-		       int flag, void *data)
+		       unsigned int flag, void *data)
 {
 	struct oidset *seen = data;
 	const char *path = strip_namespace(path_full);
@@ -1701,7 +1701,7 @@ static void check_aliased_update(struct command *cmd, struct string_list *list)
 {
 	struct strbuf buf = STRBUF_INIT;
 	const char *dst_name;
-	int flag;
+	unsigned int flag;
 
 	strbuf_addf(&buf, "%s%s", get_git_namespace(), cmd->ref_name);
 	dst_name = resolve_ref_unsafe(buf.buf, 0, NULL, &flag);
diff --git a/builtin/reflog.c b/builtin/reflog.c
index a4b1dd27e13..47464a7a7b9 100644
--- a/builtin/reflog.c
+++ b/builtin/reflog.c
@@ -343,7 +343,7 @@ static int should_expire_reflog_ent_verbose(struct object_id *ooid,
 }
 
 static int push_tip_to_list(const char *refname, const struct object_id *oid,
-			    int flags, void *cb_data)
+			    unsigned int flags, void *cb_data)
 {
 	struct commit_list **list = cb_data;
 	struct commit *tip_commit;
@@ -424,7 +424,8 @@ static void reflog_expiry_cleanup(void *cb_data)
 	}
 }
 
-static int collect_reflog(const char *ref, const struct object_id *oid, int unused, void *cb_data)
+static int collect_reflog(const char *ref, const struct object_id *oid,
+			  unsigned int unused, void *cb_data)
 {
 	struct worktree_reflogs *cb = cb_data;
 	struct worktree *worktree = cb->worktree;
diff --git a/builtin/remote.c b/builtin/remote.c
index 299c466116d..4881d58c336 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -533,7 +533,8 @@ struct branches_for_remote {
 };
 
 static int add_branch_for_removal(const char *refname,
-	const struct object_id *oid, int flags, void *cb_data)
+				  const struct object_id *oid,
+				  unsigned int flags, void *cb_data)
 {
 	struct branches_for_remote *branches = cb_data;
 	struct refspec_item refspec;
@@ -574,12 +575,13 @@ struct rename_info {
 };
 
 static int read_remote_branches(const char *refname,
-	const struct object_id *oid, int flags, void *cb_data)
+				const struct object_id *oid, unsigned int flags,
+				void *cb_data)
 {
 	struct rename_info *rename = cb_data;
 	struct strbuf buf = STRBUF_INIT;
 	struct string_list_item *item;
-	int flag;
+	unsigned int flag;
 	const char *symref;
 
 	strbuf_addf(&buf, "refs/remotes/%s/", rename->old_name);
@@ -766,7 +768,7 @@ static int mv(int argc, const char **argv)
 	for_each_ref(read_remote_branches, &rename);
 	for (i = 0; i < remote_branches.nr; i++) {
 		struct string_list_item *item = remote_branches.items + i;
-		int flag = 0;
+		unsigned int flag = 0;
 
 		read_ref_full(item->string, RESOLVE_REF_READING, NULL, &flag);
 		if (!(flag & REF_ISSYMREF))
@@ -923,7 +925,8 @@ static void free_remote_ref_states(struct ref_states *states)
 }
 
 static int append_ref_to_tracked_list(const char *refname,
-	const struct object_id *oid, int flags, void *cb_data)
+				      const struct object_id *oid,
+				      unsigned int flags, void *cb_data)
 {
 	struct ref_states *states = cb_data;
 	struct refspec_item refspec;
diff --git a/builtin/repack.c b/builtin/repack.c
index da1e364a756..ff6ddc0f357 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -464,8 +464,8 @@ struct midx_snapshot_ref_data {
 };
 
 static int midx_snapshot_ref_one(const char *refname,
-				 const struct object_id *oid,
-				 int flag, void *_data)
+				 const struct object_id *oid, unsigned int flag,
+				 void *_data)
 {
 	struct midx_snapshot_ref_data *data = _data;
 	struct object_id peeled;
diff --git a/builtin/replace.c b/builtin/replace.c
index 6ff1734d587..2fa39e73f0e 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -40,8 +40,8 @@ struct show_data {
 };
 
 static int show_reference(struct repository *r, const char *refname,
-			  const struct object_id *oid,
-			  int flag, void *cb_data)
+			  const struct object_id *oid, unsigned int flag,
+			  void *cb_data)
 {
 	struct show_data *data = cb_data;
 
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 8480a59f573..b842c958f20 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -195,7 +195,8 @@ static int show_default(void)
 	return 0;
 }
 
-static int show_reference(const char *refname, const struct object_id *oid, int flag, void *cb_data)
+static int show_reference(const char *refname, const struct object_id *oid,
+			  unsigned int flag, void *cb_data)
 {
 	if (ref_excluded(ref_excludes, refname))
 		return 0;
@@ -203,7 +204,8 @@ static int show_reference(const char *refname, const struct object_id *oid, int
 	return 0;
 }
 
-static int anti_reference(const char *refname, const struct object_id *oid, int flag, void *cb_data)
+static int anti_reference(const char *refname, const struct object_id *oid,
+			  unsigned int flag, void *cb_data)
 {
 	show_rev(REVERSED, oid, refname);
 	return 0;
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index e12c5e80e3e..625ba0c28ce 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -403,7 +403,7 @@ static int append_ref(const char *refname, const struct object_id *oid,
 }
 
 static int append_head_ref(const char *refname, const struct object_id *oid,
-			   int flag, void *cb_data)
+			   unsigned int flag, void *cb_data)
 {
 	struct object_id tmp;
 	int ofs = 11;
@@ -418,7 +418,7 @@ static int append_head_ref(const char *refname, const struct object_id *oid,
 }
 
 static int append_remote_ref(const char *refname, const struct object_id *oid,
-			     int flag, void *cb_data)
+			     unsigned int flag, void *cb_data)
 {
 	struct object_id tmp;
 	int ofs = 13;
@@ -444,7 +444,7 @@ static const char *match_ref_pattern = NULL;
 static int match_ref_slash = 0;
 
 static int append_matching_ref(const char *refname, const struct object_id *oid,
-			       int flag, void *cb_data)
+			       unsigned int flag, void *cb_data)
 {
 	/* we want to allow pattern hold/<asterisk> to show all
 	 * branches under refs/heads/hold/, and v0.99.9? to show
diff --git a/builtin/show-ref.c b/builtin/show-ref.c
index 7f8a5332f83..09b708daf5b 100644
--- a/builtin/show-ref.c
+++ b/builtin/show-ref.c
@@ -47,7 +47,7 @@ static void show_one(const char *refname, const struct object_id *oid)
 }
 
 static int show_ref(const char *refname, const struct object_id *oid,
-		    int flag, void *cbdata)
+		    unsigned int flag, void *cbdata)
 {
 	if (show_head && !strcmp(refname, "HEAD"))
 		goto match;
@@ -86,7 +86,7 @@ match:
 }
 
 static int add_existing(const char *refname, const struct object_id *oid,
-			int flag, void *cbdata)
+			unsigned int flag, void *cbdata)
 {
 	struct string_list *list = (struct string_list *)cbdata;
 	string_list_insert(list, refname);
diff --git a/builtin/stash.c b/builtin/stash.c
index 86cd0b456e7..c02e014acb7 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -1296,7 +1296,7 @@ static int do_create_stash(const struct pathspec *ps, struct strbuf *stash_msg_b
 			   int quiet)
 {
 	int ret = 0;
-	int flags = 0;
+	unsigned int flags = 0;
 	int untracked_commit_option = 0;
 	const char *head_short_sha1 = NULL;
 	const char *branch_ref = NULL;
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index c5d3fc3817f..3ffee0699a6 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -738,8 +738,8 @@ static void print_status(unsigned int flags, char state, const char *path,
 }
 
 static int handle_submodule_head_ref(const char *refname,
-				     const struct object_id *oid, int flags,
-				     void *cb_data)
+				     const struct object_id *oid,
+				     unsigned int flags, void *cb_data)
 {
 	struct object_id *output = cb_data;
 	if (oid)
diff --git a/builtin/symbolic-ref.c b/builtin/symbolic-ref.c
index e547a08d6c7..1ad2997e979 100644
--- a/builtin/symbolic-ref.c
+++ b/builtin/symbolic-ref.c
@@ -12,7 +12,7 @@ static const char * const git_symbolic_ref_usage[] = {
 
 static int check_symref(const char *HEAD, int quiet, int shorten, int print)
 {
-	int flag;
+	unsigned int flag;
 	const char *refname = resolve_ref_unsafe(HEAD, 0, NULL, &flag);
 
 	if (!refname)
diff --git a/bundle.c b/bundle.c
index a0bb687b0f4..da4442d4f1a 100644
--- a/bundle.c
+++ b/bundle.c
@@ -371,7 +371,7 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
 		struct object_id oid;
 		char *ref;
 		const char *display_ref;
-		int flag;
+		unsigned int flag;
 
 		if (e->item->flags & UNINTERESTING)
 			continue;
diff --git a/commit-graph.c b/commit-graph.c
index 265c010122e..1a7d1bb154d 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -1636,9 +1636,8 @@ struct refs_cb_data {
 	struct progress *progress;
 };
 
-static int add_ref_to_set(const char *refname,
-			  const struct object_id *oid,
-			  int flags, void *cb_data)
+static int add_ref_to_set(const char *refname, const struct object_id *oid,
+			  unsigned int flags, void *cb_data)
 {
 	struct object_id peeled;
 	struct refs_cb_data *data = (struct refs_cb_data *)cb_data;
diff --git a/config.c b/config.c
index 2bffa8d4a01..a4f9cf339f7 100644
--- a/config.c
+++ b/config.c
@@ -276,7 +276,7 @@ done:
 
 static int include_by_branch(const char *cond, size_t cond_len)
 {
-	int flags;
+	unsigned int flags;
 	int ret;
 	struct strbuf pattern = STRBUF_INIT;
 	const char *refname = !the_repository->gitdir ?
diff --git a/delta-islands.c b/delta-islands.c
index aa98b2e5414..dba5454ba01 100644
--- a/delta-islands.c
+++ b/delta-islands.c
@@ -365,7 +365,7 @@ static void add_ref_to_island(const char *island_name, const struct object_id *o
 }
 
 static int find_island_for_ref(const char *refname, const struct object_id *oid,
-			       int flags, void *data)
+			       unsigned int flags, void *data)
 {
 	/*
 	 * We should advertise 'ARRAY_SIZE(matches) - 2' as the max,
diff --git a/fetch-pack.c b/fetch-pack.c
index dd6ec449f2d..3fb3e0cbd18 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -164,8 +164,9 @@ static int rev_list_insert_ref(struct fetch_negotiator *negotiator,
 	return 0;
 }
 
-static int rev_list_insert_ref_oid(const char *refname, const struct object_id *oid,
-				   int flag, void *cb_data)
+static int rev_list_insert_ref_oid(const char *refname,
+				   const struct object_id *oid,
+				   unsigned int flag, void *cb_data)
 {
 	return rev_list_insert_ref(cb_data, oid);
 }
@@ -548,7 +549,7 @@ static int mark_complete(const struct object_id *oid)
 }
 
 static int mark_complete_oid(const char *refname, const struct object_id *oid,
-			     int flag, void *cb_data)
+			     unsigned int flag, void *cb_data)
 {
 	return mark_complete(oid);
 }
diff --git a/help.c b/help.c
index 71444906ddf..38e3def7cb6 100644
--- a/help.c
+++ b/help.c
@@ -728,7 +728,7 @@ struct similar_ref_cb {
 };
 
 static int append_similar_ref(const char *refname, const struct object_id *oid,
-			      int flags, void *cb_data)
+			      unsigned int flags, void *cb_data)
 {
 	struct similar_ref_cb *cb = (struct similar_ref_cb *)(cb_data);
 	char *branch = strrchr(refname, '/') + 1;
diff --git a/http-backend.c b/http-backend.c
index 807fb8839e7..c8757e601d1 100644
--- a/http-backend.c
+++ b/http-backend.c
@@ -504,7 +504,7 @@ static void run_service(const char **argv, int buffer_input)
 }
 
 static int show_text_ref(const char *name, const struct object_id *oid,
-			 int flag, void *cb_data)
+			 unsigned int flag, void *cb_data)
 {
 	const char *name_nons = strip_namespace(name);
 	struct strbuf *buf = cb_data;
@@ -559,7 +559,7 @@ static void get_info_refs(struct strbuf *hdr, char *arg)
 }
 
 static int show_head_ref(const char *refname, const struct object_id *oid,
-			 int flag, void *cb_data)
+			 unsigned int flag, void *cb_data)
 {
 	struct strbuf *buf = cb_data;
 
diff --git a/log-tree.c b/log-tree.c
index d3e7a40b648..189fff841de 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -131,7 +131,7 @@ static int ref_filter_match(const char *refname,
 }
 
 static int add_ref_decoration(const char *refname, const struct object_id *oid,
-			      int flags, void *cb_data)
+			      unsigned int flags, void *cb_data)
 {
 	struct object *obj;
 	enum object_type objtype;
@@ -241,7 +241,7 @@ static const struct name_decoration *current_pointed_by_HEAD(const struct name_d
 {
 	const struct name_decoration *list, *head = NULL;
 	const char *branch_name = NULL;
-	int rru_flags;
+	unsigned int rru_flags;
 
 	/* First find HEAD */
 	for (list = decoration; list; list = list->next)
diff --git a/ls-refs.c b/ls-refs.c
index 54078323dcb..eaa43748ba5 100644
--- a/ls-refs.c
+++ b/ls-refs.c
@@ -76,7 +76,7 @@ struct ls_refs_data {
 };
 
 static int send_ref(const char *refname, const struct object_id *oid,
-		    int flag, void *cb_data)
+		    unsigned int flag, void *cb_data)
 {
 	struct ls_refs_data *data = cb_data;
 	const char *refname_nons = strip_namespace(refname);
@@ -122,7 +122,7 @@ static void send_possibly_unborn_head(struct ls_refs_data *data)
 {
 	struct strbuf namespaced = STRBUF_INIT;
 	struct object_id oid;
-	int flag;
+	unsigned int flag;
 	int oid_is_null;
 
 	strbuf_addf(&namespaced, "%sHEAD", get_git_namespace());
diff --git a/midx.c b/midx.c
index 837b46b2af5..3d3136089f9 100644
--- a/midx.c
+++ b/midx.c
@@ -922,9 +922,8 @@ static void prepare_midx_packing_data(struct packing_data *pdata,
 	}
 }
 
-static int add_ref_to_pending(const char *refname,
-			      const struct object_id *oid,
-			      int flag, void *cb_data)
+static int add_ref_to_pending(const char *refname, const struct object_id *oid,
+			      unsigned int flag, void *cb_data)
 {
 	struct rev_info *revs = (struct rev_info*)cb_data;
 	struct object *object;
diff --git a/negotiator/default.c b/negotiator/default.c
index 434189ae5dc..3f911f6b633 100644
--- a/negotiator/default.c
+++ b/negotiator/default.c
@@ -36,7 +36,7 @@ static void rev_list_push(struct negotiation_state *ns,
 }
 
 static int clear_marks(const char *refname, const struct object_id *oid,
-		       int flag, void *cb_data)
+		       unsigned int flag, void *cb_data)
 {
 	struct object *o = deref_tag(the_repository, parse_object(the_repository, oid), refname, 0);
 
diff --git a/negotiator/skipping.c b/negotiator/skipping.c
index 1236e792248..0e6f72987c1 100644
--- a/negotiator/skipping.c
+++ b/negotiator/skipping.c
@@ -72,7 +72,7 @@ static struct entry *rev_list_push(struct data *data, struct commit *commit, int
 }
 
 static int clear_marks(const char *refname, const struct object_id *oid,
-		       int flag, void *cb_data)
+		       unsigned int flag, void *cb_data)
 {
 	struct object *o = deref_tag(the_repository, parse_object(the_repository, oid), refname, 0);
 
diff --git a/notes.c b/notes.c
index f87dac40684..17b4d0edb83 100644
--- a/notes.c
+++ b/notes.c
@@ -924,8 +924,9 @@ out:
 	return ret;
 }
 
-static int string_list_add_one_ref(const char *refname, const struct object_id *oid,
-				   int flag, void *cb)
+static int string_list_add_one_ref(const char *refname,
+				   const struct object_id *oid,
+				   unsigned int flag, void *cb)
 {
 	struct string_list *refs = cb;
 	if (!unsorted_string_list_has_string(refs, refname))
diff --git a/object-name.c b/object-name.c
index fdff4601b2c..b14ec59cce8 100644
--- a/object-name.c
+++ b/object-name.c
@@ -1208,7 +1208,7 @@ struct handle_one_ref_cb {
 };
 
 static int handle_one_ref(const char *path, const struct object_id *oid,
-			  int flag, void *cb_data)
+			  unsigned int flag, void *cb_data)
 {
 	struct handle_one_ref_cb *cb = cb_data;
 	struct commit_list **list = cb->list;
diff --git a/reachable.c b/reachable.c
index 84e3d0d75ed..74e8ee81bbe 100644
--- a/reachable.c
+++ b/reachable.c
@@ -27,7 +27,7 @@ static void update_progress(struct connectivity_progress *cp)
 }
 
 static int add_one_ref(const char *path, const struct object_id *oid,
-		       int flag, void *cb_data)
+		       unsigned int flag, void *cb_data)
 {
 	struct rev_info *revs = (struct rev_info *)cb_data;
 	struct object *object;
diff --git a/ref-filter.c b/ref-filter.c
index f7a2f17bfd9..f51779bd725 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -2233,7 +2233,8 @@ struct ref_filter_cbdata {
  * A call-back given to for_each_ref().  Filter refs and keep them for
  * later object processing.
  */
-static int ref_filter_handler(const char *refname, const struct object_id *oid, int flag, void *cb_data)
+static int ref_filter_handler(const char *refname, const struct object_id *oid,
+			      unsigned int flag, void *cb_data)
 {
 	struct ref_filter_cbdata *ref_cbdata = cb_data;
 	struct ref_filter *filter = ref_cbdata->filter;
diff --git a/refs.c b/refs.c
index addb26293b4..5f29775def1 100644
--- a/refs.c
+++ b/refs.c
@@ -74,7 +74,7 @@ static unsigned char refname_disposition[256] = {
  * as an error, try to come up with a usable replacement for the input
  * refname in it.
  */
-static int check_refname_component(const char *refname, int *flags,
+static int check_refname_component(const char *refname, unsigned int *flags,
 				   struct strbuf *sanitized)
 {
 	const char *cp;
@@ -158,7 +158,7 @@ out:
 	return cp - refname;
 }
 
-static int check_or_sanitize_refname(const char *refname, int flags,
+static int check_or_sanitize_refname(const char *refname, unsigned int flags,
 				     struct strbuf *sanitized)
 {
 	int component_len, component_count = 0;
@@ -202,7 +202,7 @@ static int check_or_sanitize_refname(const char *refname, int flags,
 	return 0;
 }
 
-int check_refname_format(const char *refname, int flags)
+int check_refname_format(const char *refname, unsigned int flags)
 {
 	return check_or_sanitize_refname(refname, flags, NULL);
 }
@@ -264,9 +264,9 @@ int ref_resolves_to_object(const char *refname,
 	return 1;
 }
 
-char *refs_resolve_refdup(struct ref_store *refs,
-			  const char *refname, int resolve_flags,
-			  struct object_id *oid, int *flags)
+char *refs_resolve_refdup(struct ref_store *refs, const char *refname,
+			  int resolve_flags, struct object_id *oid,
+			  unsigned int *flags)
 {
 	const char *result;
 	int ignore_errno;
@@ -276,8 +276,8 @@ char *refs_resolve_refdup(struct ref_store *refs,
 	return xstrdup_or_null(result);
 }
 
-char *resolve_refdup(const char *refname, int resolve_flags,
-		     struct object_id *oid, int *flags)
+char *resolve_refdup(const char *refname, unsigned int resolve_flags,
+		     struct object_id *oid, unsigned int *flags)
 {
 	return refs_resolve_refdup(get_main_ref_store(the_repository),
 				   refname, resolve_flags,
@@ -292,7 +292,8 @@ struct ref_filter {
 	void *cb_data;
 };
 
-int read_ref_full(const char *refname, int resolve_flags, struct object_id *oid, int *flags)
+int read_ref_full(const char *refname, unsigned int resolve_flags,
+		  struct object_id *oid, unsigned int *flags)
 {
 	int ignore_errno;
 	struct ref_store *refs = get_main_ref_store(the_repository);
@@ -321,7 +322,7 @@ int ref_exists(const char *refname)
 }
 
 static int filter_refs(const char *refname, const struct object_id *oid,
-			   int flags, void *data)
+		       unsigned int flags, void *data)
 {
 	struct ref_filter *filter = (struct ref_filter *)data;
 
@@ -360,8 +361,9 @@ struct warn_if_dangling_data {
 	const char *msg_fmt;
 };
 
-static int warn_if_dangling_symref(const char *refname, const struct object_id *oid,
-				   int flags, void *cb_data)
+static int warn_if_dangling_symref(const char *refname,
+				   const struct object_id *oid,
+				   unsigned int flags, void *cb_data)
 {
 	struct warn_if_dangling_data *d = cb_data;
 	const char *resolves_to;
@@ -439,7 +441,7 @@ int head_ref_namespaced(each_ref_fn fn, void *cb_data)
 	struct strbuf buf = STRBUF_INIT;
 	int ret = 0;
 	struct object_id oid;
-	int flag;
+	unsigned int flag;
 
 	strbuf_addf(&buf, "%sHEAD", get_git_namespace());
 	if (!read_ref_full(buf.buf, RESOLVE_REF_READING, &oid, &flag))
@@ -654,7 +656,7 @@ int expand_ref(struct repository *repo, const char *str, int len,
 	for (p = ref_rev_parse_rules; *p; p++) {
 		struct object_id oid_from_ref;
 		struct object_id *this_result;
-		int flag;
+		unsigned int flag;
 		struct ref_store *refs = get_main_ref_store(repo);
 		int ignore_errno;
 
@@ -1389,7 +1391,7 @@ const char *find_descendant_ref(const char *dirname,
 int refs_head_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
 {
 	struct object_id oid;
-	int flag;
+	unsigned int flag;
 	int ignore_errno;
 
 	if (refs_resolve_ref_unsafe(refs, "HEAD", RESOLVE_REF_READING,
@@ -1467,11 +1469,9 @@ struct do_for_each_ref_help {
 	void *cb_data;
 };
 
-static int do_for_each_ref_helper(struct repository *r,
-				  const char *refname,
+static int do_for_each_ref_helper(struct repository *r, const char *refname,
 				  const struct object_id *oid,
-				  int flags,
-				  void *cb_data)
+				  unsigned int flags, void *cb_data)
 {
 	struct do_for_each_ref_help *hp = cb_data;
 
@@ -1678,15 +1678,13 @@ int refs_read_raw_ref(struct ref_store *ref_store, const char *refname,
 					   type, failure_errno);
 }
 
-const char *refs_resolve_ref_unsafe(struct ref_store *refs,
-				    const char *refname,
-				    int resolve_flags,
-				    struct object_id *oid,
-				    int *flags, int *failure_errno)
+const char *refs_resolve_ref_unsafe(struct ref_store *refs, const char *refname,
+				    int resolve_flags, struct object_id *oid,
+				    unsigned int *flags, int *failure_errno)
 {
 	static struct strbuf sb_refname = STRBUF_INIT;
 	struct object_id unused_oid;
-	int unused_flags;
+	unsigned int unused_flags;
 	int symref_count;
 
 	assert(failure_errno);
@@ -1782,7 +1780,7 @@ int refs_init_db(struct strbuf *err)
 }
 
 const char *resolve_ref_unsafe(const char *refname, int resolve_flags,
-			       struct object_id *oid, int *flags)
+			       struct object_id *oid, unsigned int *flags)
 {
 	int ignore_errno;
 
@@ -1794,7 +1792,7 @@ int resolve_gitlink_ref(const char *submodule, const char *refname,
 			struct object_id *oid)
 {
 	struct ref_store *refs;
-	int flags;
+	unsigned int flags;
 	int ignore_errno;
 
 	refs = get_submodule_ref_store(submodule);
diff --git a/refs.h b/refs.h
index 8f91a7f9ff2..c5462b75807 100644
--- a/refs.h
+++ b/refs.h
@@ -68,23 +68,21 @@ struct worktree;
 #define RESOLVE_REF_NO_RECURSE 0x02
 #define RESOLVE_REF_ALLOW_BAD_NAME 0x04
 
-const char *refs_resolve_ref_unsafe(struct ref_store *refs,
-				    const char *refname,
-				    int resolve_flags,
-				    struct object_id *oid,
-				    int *flags, int *failure_errno);
+const char *refs_resolve_ref_unsafe(struct ref_store *refs, const char *refname,
+				    int resolve_flags, struct object_id *oid,
+				    unsigned int *flags, int *failure_errno);
 
 const char *resolve_ref_unsafe(const char *refname, int resolve_flags,
-			       struct object_id *oid, int *flags);
+			       struct object_id *oid, unsigned int *flags);
 
-char *refs_resolve_refdup(struct ref_store *refs,
-			  const char *refname, int resolve_flags,
-			  struct object_id *oid, int *flags);
-char *resolve_refdup(const char *refname, int resolve_flags,
-		     struct object_id *oid, int *flags);
+char *refs_resolve_refdup(struct ref_store *refs, const char *refname,
+			  int resolve_flags, struct object_id *oid,
+			  unsigned int *flags);
+char *resolve_refdup(const char *refname, unsigned int resolve_flags,
+		     struct object_id *oid, unsigned int *flags);
 
-int read_ref_full(const char *refname, int resolve_flags,
-		  struct object_id *oid, int *flags);
+int read_ref_full(const char *refname, unsigned int resolve_flags,
+		  struct object_id *oid, unsigned int *flags);
 int read_ref(const char *refname, struct object_id *oid);
 
 /*
@@ -298,17 +296,15 @@ struct ref_transaction;
  * arguments is only guaranteed to be valid for the duration of a
  * single callback invocation.
  */
-typedef int each_ref_fn(const char *refname,
-			const struct object_id *oid, int flags, void *cb_data);
+typedef int each_ref_fn(const char *refname, const struct object_id *oid,
+			unsigned int flags, void *cb_data);
 
 /*
  * The same as each_ref_fn, but also with a repository argument that
  * contains the repository associated with the callback.
  */
-typedef int each_repo_ref_fn(struct repository *r,
-			     const char *refname,
-			     const struct object_id *oid,
-			     int flags,
+typedef int each_repo_ref_fn(struct repository *r, const char *refname,
+			     const struct object_id *oid, unsigned int flags,
 			     void *cb_data);
 
 /*
@@ -532,7 +528,7 @@ int for_each_reflog(each_ref_fn fn, void *cb_data);
  * allow a single "*" wildcard character in the refspec. No leading or
  * repeated slashes are accepted.
  */
-int check_refname_format(const char *refname, int flags);
+int check_refname_format(const char *refname, unsigned int flags);
 
 /*
  * Apply the rules from check_refname_format, but mutate the result until it
@@ -896,7 +892,7 @@ struct ref_store *get_main_ref_store(struct repository *r);
  *
  * ----
  * static int handle_remote_ref(const char *refname,
- * 		const unsigned char *sha1, int flags, void *cb_data)
+ * 		const unsigned char *sha1, unsigned int flags, void *cb_data)
  * {
  * 	struct strbuf *output = cb_data;
  * 	strbuf_addf(output, "%s\n", refname);
diff --git a/refs/files-backend.c b/refs/files-backend.c
index 43a3b882d7c..181998a65bf 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -261,7 +261,7 @@ static void loose_fill_ref_dir(struct ref_store *ref_store,
 	while ((de = readdir(d)) != NULL) {
 		struct object_id oid;
 		struct stat st;
-		int flag;
+		unsigned int flag;
 
 		if (de->d_name[0] == '.')
 			continue;
@@ -1391,7 +1391,8 @@ static int files_copy_or_rename_ref(struct ref_store *ref_store,
 	struct files_ref_store *refs =
 		files_downcast(ref_store, REF_STORE_WRITE, "rename_ref");
 	struct object_id orig_oid;
-	int flag = 0, logmoved = 0;
+	int logmoved = 0;
+	unsigned int flag = 0;
 	struct ref_lock *lock;
 	struct stat loginfo;
 	struct strbuf sb_oldref = STRBUF_INIT;
@@ -1826,7 +1827,7 @@ static int commit_ref_update(struct files_ref_store *refs,
 		 * check with HEAD only which should cover 99% of all usage
 		 * scenarios (even 100% of the default ones).
 		 */
-		int head_flag;
+		unsigned int head_flag;
 		const char *head_ref;
 		int ignore_errno;
 
@@ -2159,7 +2160,7 @@ static int files_reflog_iterator_advance(struct ref_iterator *ref_iterator)
 	int ignore_errno;
 
 	while ((ok = dir_iterator_advance(diter)) == ITER_OK) {
-		int flags;
+		unsigned int flags;
 
 		if (!S_ISREG(diter->st.st_mode))
 			continue;
@@ -2669,7 +2670,7 @@ static int files_transaction_prepare(struct ref_store *ref_store,
 	int ret = 0;
 	struct string_list affected_refnames = STRING_LIST_INIT_NODUP;
 	char *head_ref = NULL;
-	int head_type;
+	unsigned int head_type;
 	struct files_transaction_backend_data *backend_data;
 	struct ref_transaction *packed_transaction = NULL;
 
@@ -2982,8 +2983,8 @@ static int files_transaction_abort(struct ref_store *ref_store,
 	return 0;
 }
 
-static int ref_present(const char *refname,
-		       const struct object_id *oid, int flags, void *cb_data)
+static int ref_present(const char *refname, const struct object_id *oid,
+		       unsigned int flags, void *cb_data)
 {
 	struct string_list *affected_refnames = cb_data;
 
@@ -3209,7 +3210,7 @@ static int files_reflog_expire(struct ref_store *ref_store,
 		if ((expire_flags & EXPIRE_REFLOGS_UPDATE_REF) &&
 		    !is_null_oid(&cb.last_kept_oid)) {
 			int ignore_errno;
-			int type;
+			unsigned int type;
 			const char *ref;
 
 			ref = refs_resolve_ref_unsafe(&refs->base, refname,
diff --git a/remote.c b/remote.c
index a6d8ec6c1ac..9fc370b7543 100644
--- a/remote.c
+++ b/remote.c
@@ -500,7 +500,7 @@ static void alias_all_urls(struct remote_state *remote_state)
 
 static void read_config(struct repository *repo)
 {
-	int flag;
+	unsigned int flag;
 
 	if (repo->remote_state->initialized)
 		return;
@@ -1272,7 +1272,7 @@ static int match_explicit(struct ref *src, struct ref *dst,
 		return -1;
 
 	if (!dst_value) {
-		int flag;
+		unsigned int flag;
 
 		dst_value = resolve_ref_unsafe(matched_src->name,
 					       RESOLVE_REF_READING,
@@ -1948,7 +1948,7 @@ const char *branch_get_push(struct branch *branch, struct strbuf *err)
 
 static int ignore_symref_update(const char *refname)
 {
-	int flag;
+	unsigned int flag;
 
 	if (!resolve_ref_unsafe(refname, 0, NULL, &flag))
 		return 0; /* non-existing refs are OK */
@@ -2288,7 +2288,7 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb,
 }
 
 static int one_local_ref(const char *refname, const struct object_id *oid,
-			 int flag, void *cb_data)
+			 unsigned int flag, void *cb_data)
 {
 	struct ref ***local_tail = cb_data;
 	struct ref *ref;
@@ -2369,7 +2369,7 @@ struct stale_heads_info {
 };
 
 static int get_stale_heads_cb(const char *refname, const struct object_id *oid,
-			      int flags, void *cb_data)
+			      unsigned int flags, void *cb_data)
 {
 	struct stale_heads_info *info = cb_data;
 	struct string_list matches = STRING_LIST_INIT_DUP;
diff --git a/replace-object.c b/replace-object.c
index 7bd9aba6ee6..1a9ed348661 100644
--- a/replace-object.c
+++ b/replace-object.c
@@ -6,10 +6,9 @@
 #include "repository.h"
 #include "commit.h"
 
-static int register_replace_ref(struct repository *r,
-				const char *refname,
-				const struct object_id *oid,
-				int flag, void *cb_data)
+static int register_replace_ref(struct repository *r, const char *refname,
+				const struct object_id *oid, unsigned int flag,
+				void *cb_data)
 {
 	/* Get sha1 from refname */
 	const char *slash = strrchr(refname, '/');
diff --git a/revision.c b/revision.c
index ad4286fbdde..37bdd43f9ee 100644
--- a/revision.c
+++ b/revision.c
@@ -1527,7 +1527,7 @@ int ref_excluded(struct string_list *ref_excludes, const char *path)
 }
 
 static int handle_one_ref(const char *path, const struct object_id *oid,
-			  int flag, void *cb_data)
+			  unsigned int flag, void *cb_data)
 {
 	struct all_refs_cb *cb = cb_data;
 	struct object *object;
@@ -1611,8 +1611,8 @@ static int handle_one_reflog_ent(struct object_id *ooid, struct object_id *noid,
 }
 
 static int handle_one_reflog(const char *refname_in_wt,
-			     const struct object_id *oid,
-			     int flag, void *cb_data)
+			     const struct object_id *oid, unsigned int flag,
+			     void *cb_data)
 {
 	struct all_refs_cb *cb = cb_data;
 	struct strbuf refname = STRBUF_INIT;
@@ -2678,7 +2678,7 @@ static int handle_revision_pseudo_opt(struct rev_info *revs,
 
 static void NORETURN diagnose_missing_default(const char *def)
 {
-	int flags;
+	unsigned int flags;
 	const char *refname;
 
 	refname = resolve_ref_unsafe(def, 0, NULL, &flags);
diff --git a/server-info.c b/server-info.c
index 7701d7c20a1..78119897d30 100644
--- a/server-info.c
+++ b/server-info.c
@@ -147,7 +147,7 @@ out:
 }
 
 static int add_info_ref(const char *path, const struct object_id *oid,
-			int flag, void *cb_data)
+			unsigned int flag, void *cb_data)
 {
 	struct update_info_ctx *uic = cb_data;
 	struct object *o = parse_object(the_repository, oid);
diff --git a/shallow.c b/shallow.c
index 9ed18eb8849..eebb66961a8 100644
--- a/shallow.c
+++ b/shallow.c
@@ -596,7 +596,7 @@ static void paint_down(struct paint_info *info, const struct object_id *oid,
 }
 
 static int mark_uninteresting(const char *refname, const struct object_id *oid,
-			      int flags, void *cb_data)
+			      unsigned int flags, void *cb_data)
 {
 	struct commit *commit = lookup_commit_reference_gently(the_repository,
 							       oid, 1);
@@ -707,7 +707,7 @@ struct commit_array {
 };
 
 static int add_ref(const char *refname, const struct object_id *oid,
-		   int flags, void *cb_data)
+		   unsigned int flags, void *cb_data)
 {
 	struct commit_array *ca = cb_data;
 	ALLOC_GROW(ca->commits, ca->nr + 1, ca->alloc);
diff --git a/submodule.c b/submodule.c
index c6890705241..47227b3cae4 100644
--- a/submodule.c
+++ b/submodule.c
@@ -909,7 +909,7 @@ static void free_submodules_oids(struct string_list *submodules)
 }
 
 static int has_remote(const char *refname, const struct object_id *oid,
-		      int flags, void *cb_data)
+		      unsigned int flags, void *cb_data)
 {
 	return 1;
 }
@@ -1216,7 +1216,7 @@ int push_unpushed_submodules(struct repository *r,
 }
 
 static int append_oid_to_array(const char *ref, const struct object_id *oid,
-			       int flags, void *data)
+			       unsigned int flags, void *data)
 {
 	struct oid_array *array = data;
 	oid_array_append(array, oid);
diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c
index 3e4ddaee705..5054600e3a9 100644
--- a/t/helper/test-ref-store.c
+++ b/t/helper/test-ref-store.c
@@ -160,7 +160,7 @@ static int cmd_rename_ref(struct ref_store *refs, const char **argv)
 }
 
 static int each_ref(const char *refname, const struct object_id *oid,
-		    int flags, void *cb_data)
+		    unsigned int flags, void *cb_data)
 {
 	printf("%s %s 0x%x\n", oid_to_hex(oid), refname, flags);
 	return 0;
@@ -178,7 +178,7 @@ static int cmd_resolve_ref(struct ref_store *refs, const char **argv)
 	struct object_id oid = *null_oid();
 	const char *refname = notnull(*argv++, "refname");
 	int resolve_flags = arg_flags(*argv++, "resolve-flags", empty_flags);
-	int flags;
+	unsigned int flags;
 	const char *ref;
 	int ignore_errno;
 
diff --git a/transport-helper.c b/transport-helper.c
index a0297b0986c..c207103aaff 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -1090,7 +1090,7 @@ static int push_refs_with_export(struct transport *transport,
 			if (strcmp(ref->name, ref->peer_ref->name)) {
 				if (!ref->deletion) {
 					const char *name;
-					int flag;
+					unsigned int flag;
 
 					/* Follow symbolic refs (mainly for HEAD). */
 					name = resolve_ref_unsafe(ref->peer_ref->name,
diff --git a/transport.c b/transport.c
index 2a3e3241545..5b6d5d29388 100644
--- a/transport.c
+++ b/transport.c
@@ -80,7 +80,7 @@ static void set_upstreams(struct transport *transport, struct ref *refs,
 		const char *localname;
 		const char *tmp;
 		const char *remotename;
-		int flag = 0;
+		unsigned int flag = 0;
 		/*
 		 * Check suitability for tracking. Must be successful /
 		 * already up-to-date ref create/modify (not delete).
diff --git a/upload-pack.c b/upload-pack.c
index 8acc98741bb..cb652db4f78 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -822,7 +822,7 @@ static void send_unshallow(struct upload_pack_data *data)
 }
 
 static int check_ref(const char *refname_full, const struct object_id *oid,
-		     int flag, void *cb_data);
+		     unsigned int flag, void *cb_data);
 static void deepen(struct upload_pack_data *data, int depth)
 {
 	if (depth == INFINITE_DEPTH && !is_repository_shallow(the_repository)) {
@@ -1169,7 +1169,7 @@ static int mark_our_ref(const char *refname, const char *refname_full,
 }
 
 static int check_ref(const char *refname_full, const struct object_id *oid,
-		     int flag, void *cb_data)
+		     unsigned int flag, void *cb_data)
 {
 	const char *refname = strip_namespace(refname_full);
 
@@ -1193,7 +1193,7 @@ static void format_session_id(struct strbuf *buf, struct upload_pack_data *d) {
 }
 
 static int send_ref(const char *refname, const struct object_id *oid,
-		    int flag, void *cb_data)
+		    unsigned int flag, void *cb_data)
 {
 	static const char *capabilities = "multi_ack thin-pack side-band"
 		" side-band-64k ofs-delta shallow deepen-since deepen-not"
@@ -1236,7 +1236,7 @@ static int send_ref(const char *refname, const struct object_id *oid,
 }
 
 static int find_symref(const char *refname, const struct object_id *oid,
-		       int flag, void *cb_data)
+		       unsigned int flag, void *cb_data)
 {
 	const char *symref_target;
 	struct string_list_item *item;
diff --git a/walker.c b/walker.c
index c5e29219795..c1b82504f51 100644
--- a/walker.c
+++ b/walker.c
@@ -216,7 +216,7 @@ static int interpret_target(struct walker *walker, char *target, struct object_i
 }
 
 static int mark_complete(const char *path, const struct object_id *oid,
-			 int flag, void *cb_data)
+			 unsigned int flag, void *cb_data)
 {
 	struct commit *commit = lookup_commit_reference_gently(the_repository,
 							       oid, 1);
diff --git a/worktree.c b/worktree.c
index 6f598dcfcdf..0fecabed3b4 100644
--- a/worktree.c
+++ b/worktree.c
@@ -26,7 +26,7 @@ void free_worktrees(struct worktree **worktrees)
  */
 static void add_head_info(struct worktree *wt)
 {
-	int flags;
+	unsigned int flags;
 	const char *target;
 	int ignore_errno;
 
@@ -415,7 +415,7 @@ const struct worktree *find_shared_symref(struct worktree **worktrees,
 		struct worktree *wt = worktrees[i];
 		const char *symref_target;
 		struct ref_store *refs;
-		int flags;
+		unsigned int flags;
 		int ignore_errno;
 
 		if (wt->is_bare)
@@ -562,7 +562,7 @@ int other_head_refs(each_ref_fn fn, void *cb_data)
 	for (p = worktrees; *p; p++) {
 		struct worktree *wt = *p;
 		struct object_id oid;
-		int flag;
+		unsigned int flag;
 		int ignore_errno;
 
 		if (wt->is_current)

base-commit: 5d01301f2b865aa8dba1654d3f447ce9d21db0b5
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH] refs.h: make all flags arguments unsigned
  2022-01-31 20:15 [PATCH] refs.h: make all flags arguments unsigned Han-Wen Nienhuys via GitGitGadget
@ 2022-02-01  2:02 ` Junio C Hamano
  2022-02-01 11:47   ` Han-Wen Nienhuys
  2022-02-01 12:46 ` [PATCH v2] " Han-Wen Nienhuys via GitGitGadget
  1 sibling, 1 reply; 17+ messages in thread
From: Junio C Hamano @ 2022-02-01  2:02 UTC (permalink / raw)
  To: Han-Wen Nienhuys via GitGitGadget; +Cc: git, Han-Wen Nienhuys, Han-Wen Nienhuys

"Han-Wen Nienhuys via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Han-Wen Nienhuys <hanwen@google.com>
>
> As discussed in
> https://lore.kernel.org/git/xmqqbkzrkevo.fsf@gitster.g/ , we don't
> want to treat the sign bit specially, so make all flags in refs.h
> unsigned.

It may be true that we do not want to, but are we sure there is no
code that already uses some cleverness to make the topmost bit
special by e.g. doing ugly things like "if (flags < 0)" ;-)?

IOW, what we want or do not want does not matter as much as what the
code paths that use these declarations want to do (and we need to fix
them before we can do this conversion).

I haven't had energy to vet the entire codebase for all flag words
and that is why I've never produced a patch like this one myself.

Thanks for carefully vetting after creating this (presumably
mechanically prepared) patch---producing is the easy part, but
making sure it does not break unexpectedly is much harder.

Somebody other than the author needs to double check the result,
though.

Thanks.

>  bisect.c                    |  4 +--
>  builtin/bisect--helper.c    |  7 ++---
>  builtin/branch.c            |  4 +--
>  builtin/checkout.c          |  9 ++++---
>  builtin/describe.c          |  3 ++-
>  builtin/fetch.c             | 10 +++----
>  builtin/fsck.c              |  4 +--
>  builtin/gc.c                |  5 ++--
>  builtin/name-rev.c          |  3 ++-
>  builtin/pack-objects.c      | 11 ++++----
>  builtin/rebase.c            |  5 ++--
>  builtin/receive-pack.c      |  4 +--
>  builtin/reflog.c            |  5 ++--
>  builtin/remote.c            | 13 ++++++----
>  builtin/repack.c            |  4 +--
>  builtin/replace.c           |  4 +--
>  builtin/rev-parse.c         |  6 +++--
>  builtin/show-branch.c       |  6 ++---
>  builtin/show-ref.c          |  4 +--
>  builtin/stash.c             |  2 +-
>  builtin/submodule--helper.c |  4 +--
>  builtin/symbolic-ref.c      |  2 +-
>  bundle.c                    |  2 +-
>  commit-graph.c              |  5 ++--
>  config.c                    |  2 +-
>  delta-islands.c             |  2 +-
>  fetch-pack.c                |  7 ++---
>  help.c                      |  2 +-
>  http-backend.c              |  4 +--
>  log-tree.c                  |  4 +--
>  ls-refs.c                   |  4 +--
>  midx.c                      |  5 ++--
>  negotiator/default.c        |  2 +-
>  negotiator/skipping.c       |  2 +-
>  notes.c                     |  5 ++--
>  object-name.c               |  2 +-
>  reachable.c                 |  2 +-
>  ref-filter.c                |  3 ++-
>  refs.c                      | 52 ++++++++++++++++++-------------------
>  refs.h                      | 38 ++++++++++++---------------
>  refs/files-backend.c        | 17 ++++++------
>  remote.c                    | 10 +++----
>  replace-object.c            |  7 +++--
>  revision.c                  |  8 +++---
>  server-info.c               |  2 +-
>  shallow.c                   |  4 +--
>  submodule.c                 |  4 +--
>  t/helper/test-ref-store.c   |  4 +--
>  transport-helper.c          |  2 +-
>  transport.c                 |  2 +-
>  upload-pack.c               |  8 +++---
>  walker.c                    |  2 +-
>  worktree.c                  |  6 ++---
>  53 files changed, 171 insertions(+), 167 deletions(-)

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] refs.h: make all flags arguments unsigned
  2022-02-01  2:02 ` Junio C Hamano
@ 2022-02-01 11:47   ` Han-Wen Nienhuys
  2022-02-01 18:41     ` Junio C Hamano
  0 siblings, 1 reply; 17+ messages in thread
From: Han-Wen Nienhuys @ 2022-02-01 11:47 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Han-Wen Nienhuys via GitGitGadget, git, Han-Wen Nienhuys

On Tue, Feb 1, 2022 at 3:02 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> "Han-Wen Nienhuys via GitGitGadget" <gitgitgadget@gmail.com> writes:
>
> > From: Han-Wen Nienhuys <hanwen@google.com>
> >
> > As discussed in
> > https://lore.kernel.org/git/xmqqbkzrkevo.fsf@gitster.g/ , we don't
> > want to treat the sign bit specially, so make all flags in refs.h
> > unsigned.
>
> It may be true that we do not want to, but are we sure there is no
> code that already uses some cleverness to make the topmost bit
> special by e.g. doing ugly things like "if (flags < 0)" ;-)?

In refs.h, we don't have any bitmasks that accept 32 different bit
values, so it's hard to see how we would stumble into a case like
that.

> I haven't had energy to vet the entire codebase for all flag words
> and that is why I've never produced a patch like this one myself.
>
> Thanks for carefully vetting after creating this (presumably
> mechanically prepared) patch---producing is the easy part, but
> making sure it does not break unexpectedly is much harder.

I went over the changes once more, uniformizing the naming. I didn't
see any shenanigans.

-- 
Han-Wen Nienhuys - Google Munich
I work 80%. Don't expect answers from me on Fridays.
--

Google Germany GmbH, Erika-Mann-Strasse 33, 80636 Munich

Registergericht und -nummer: Hamburg, HRB 86891

Sitz der Gesellschaft: Hamburg

Geschäftsführer: Paul Manicle, Halimah DeLaine Prado

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v2] refs.h: make all flags arguments unsigned
  2022-01-31 20:15 [PATCH] refs.h: make all flags arguments unsigned Han-Wen Nienhuys via GitGitGadget
  2022-02-01  2:02 ` Junio C Hamano
@ 2022-02-01 12:46 ` Han-Wen Nienhuys via GitGitGadget
  2022-02-01 20:20   ` Ævar Arnfjörð Bjarmason
  2022-02-03 14:26   ` [PATCH v3 0/2] " Han-Wen Nienhuys via GitGitGadget
  1 sibling, 2 replies; 17+ messages in thread
From: Han-Wen Nienhuys via GitGitGadget @ 2022-02-01 12:46 UTC (permalink / raw)
  To: git; +Cc: Han-Wen Nienhuys, Han-Wen Nienhuys, Han-Wen Nienhuys

From: Han-Wen Nienhuys <hanwen@google.com>

As discussed in
https://lore.kernel.org/git/xmqqbkzrkevo.fsf@gitster.g/ , we don't
want to treat the sign bit specially, so make all flags in refs.h
unsigned.

For uniformity, rename all variables to `flags` or `unused_flags`,
from `flag`. In a couple of shadowing cases, use `ref_flags` for
clarity.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
---
    refs.h: make all flags arguments unsigned
    
    v2:
    
     * vet call sites.
     * uniform naming.
     * make resolve_flags unsigned too
    
    Signed-off-by: Han-Wen Nienhuys hanwen@google.com

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1210%2Fhanwen%2Funsigned-flags-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1210/hanwen/unsigned-flags-v2
Pull-Request: https://github.com/git/git/pull/1210

Range-diff vs v1:

 1:  c1dc792bd0d ! 1:  216006057b7 refs.h: make all flags arguments unsigned
     @@ Commit message
          want to treat the sign bit specially, so make all flags in refs.h
          unsigned.
      
     +    For uniformity, rename all variables to `flags` or `unused_flags`,
     +    from `flag`. In a couple of shadowing cases, use `ref_flags` for
     +    clarity.
     +
          Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
      
       ## bisect.c ##
     @@ bisect.c: void find_bisection(struct commit_list **commit_list, int *reaches,
       
       static int register_ref(const char *refname, const struct object_id *oid,
      -			int flags, void *cb_data)
     -+			unsigned int flags, void *cb_data)
     ++			unsigned int unused_flags, void *cb_data)
       {
       	struct strbuf good_prefix = STRBUF_INIT;
       	strbuf_addstr(&good_prefix, term_good);
     @@ bisect.c: int estimate_bisect_steps(int all)
       
       static int mark_for_removal(const char *refname, const struct object_id *oid,
      -			    int flag, void *cb_data)
     -+			    unsigned int flag, void *cb_data)
     ++			    unsigned int unused_flags, void *cb_data)
       {
       	struct string_list *refs = cb_data;
       	char *ref = xstrfmt("refs/bisect%s", refname);
     @@ builtin/bisect--helper.c: static int check_and_set_terms(struct bisect_terms *te
       
       static int mark_good(const char *refname, const struct object_id *oid,
      -		     int flag, void *cb_data)
     -+		     unsigned int flag, void *cb_data)
     ++		     unsigned int unused_flags, void *cb_data)
       {
       	int *m_good = (int *)cb_data;
       	*m_good = 0;
     @@ builtin/bisect--helper.c: finish:
       
       static int add_bisect_ref(const char *refname, const struct object_id *oid,
      -			  int flags, void *cb)
     -+			  unsigned int flags, void *cb)
     ++			  unsigned int unused_flags, void *cb)
       {
       	struct add_bisect_ref_data *data = cb;
       
     @@ builtin/bisect--helper.c: static enum bisect_error bisect_start(struct bisect_te
       	int i, has_double_dash = 0, must_write_terms = 0, bad_seen = 0;
      -	int flags, pathspec_pos;
      +	int pathspec_pos;
     -+	unsigned int flags;
     ++	unsigned int unused_flags;
       	enum bisect_error res = BISECT_OK;
       	struct string_list revs = STRING_LIST_INIT_DUP;
       	struct string_list states = STRING_LIST_INIT_DUP;
     +@@ builtin/bisect--helper.c: static enum bisect_error bisect_start(struct bisect_terms *terms, const char **a
     + 	/*
     + 	 * Verify HEAD
     + 	 */
     +-	head = resolve_ref_unsafe("HEAD", 0, &head_oid, &flags);
     ++	head = resolve_ref_unsafe("HEAD", 0, &head_oid, &unused_flags);
     + 	if (!head)
     + 		if (get_oid("HEAD", &head_oid))
     + 			return error(_("bad HEAD - I need a HEAD"));
      
       ## builtin/branch.c ##
      @@ builtin/branch.c: static int delete_branches(int argc, const char **argv, int force, int kinds,
     @@ builtin/checkout.c: static void update_refs_for_switch(const struct checkout_opt
       static int add_pending_uninteresting_ref(const char *refname,
       					 const struct object_id *oid,
      -					 int flags, void *cb_data)
     -+					 unsigned int flags, void *cb_data)
     ++					 unsigned int unused_flags,
     ++					 void *cb_data)
       {
       	add_pending_oid(cb_data, refname, oid, UNINTERESTING);
       	return 0;
     @@ builtin/checkout.c: static int switch_branches(const struct checkout_opts *opts,
       	struct object_id rev;
      -	int flag, writeout_error = 0;
      +	int writeout_error = 0;
     -+	unsigned int flag;
     ++	unsigned int flags;
       	int do_merge = 1;
       
       	trace2_cmd_mode("branch");
     + 
     + 	memset(&old_branch_info, 0, sizeof(old_branch_info));
     +-	old_branch_info.path = resolve_refdup("HEAD", 0, &rev, &flag);
     ++	old_branch_info.path = resolve_refdup("HEAD", 0, &rev, &flags);
     + 	if (old_branch_info.path)
     + 		old_branch_info.commit = lookup_commit_reference_gently(the_repository, &rev, 1);
     +-	if (!(flag & REF_ISSYMREF))
     ++	if (!(flags & REF_ISSYMREF))
     + 		FREE_AND_NULL(old_branch_info.path);
     + 
     + 	if (old_branch_info.path) {
      @@ builtin/checkout.c: static int checkout_branch(struct checkout_opts *opts,
       
       	if (new_branch_info->path && !opts->force_detach && !opts->new_branch &&
       	    !opts->ignore_other_worktrees) {
      -		int flag;
     -+		unsigned int flag;
     - 		char *head_ref = resolve_refdup("HEAD", 0, NULL, &flag);
     - 		if (head_ref &&
     - 		    (!(flag & REF_ISSYMREF) || strcmp(head_ref, new_branch_info->path)))
     -@@ builtin/checkout.c: static int checkout_branch(struct checkout_opts *opts,
     +-		char *head_ref = resolve_refdup("HEAD", 0, NULL, &flag);
     +-		if (head_ref &&
     +-		    (!(flag & REF_ISSYMREF) || strcmp(head_ref, new_branch_info->path)))
     ++		unsigned int flags;
     ++		char *head_ref = resolve_refdup("HEAD", 0, NULL, &flags);
     ++		if (head_ref && (!(flags & REF_ISSYMREF) ||
     ++				 strcmp(head_ref, new_branch_info->path)))
     + 			die_if_checked_out(new_branch_info->path, 1);
     + 		free(head_ref);
     + 	}
       
       	if (!new_branch_info->commit && opts->new_branch) {
       		struct object_id rev;
      -		int flag;
     -+		unsigned int flag;
     ++		unsigned int flags;
       
     - 		if (!read_ref_full("HEAD", 0, &rev, &flag) &&
     - 		    (flag & REF_ISSYMREF) && is_null_oid(&rev))
     +-		if (!read_ref_full("HEAD", 0, &rev, &flag) &&
     +-		    (flag & REF_ISSYMREF) && is_null_oid(&rev))
     ++		if (!read_ref_full("HEAD", 0, &rev, &flags) &&
     ++		    (flags & REF_ISSYMREF) && is_null_oid(&rev))
     + 			return switch_unborn_to_new_branch(opts);
     + 	}
     + 	return switch_branches(opts, new_branch_info);
      
       ## builtin/describe.c ##
      @@ builtin/describe.c: static void add_to_known_names(const char *path,
     @@ builtin/describe.c: static void add_to_known_names(const char *path,
       
      -static int get_name(const char *path, const struct object_id *oid, int flag, void *cb_data)
      +static int get_name(const char *path, const struct object_id *oid,
     -+		    unsigned int flag, void *cb_data)
     ++		    unsigned int unused_flags, void *cb_data)
       {
       	int is_tag = 0;
       	struct object_id peeled;
     @@ builtin/fetch.c: static struct refname_hash_entry *refname_hash_add(struct hashm
      -			   const struct object_id *oid,
      -			   int flag, void *cbdata)
      +static int add_one_refname(const char *refname, const struct object_id *oid,
     -+			   unsigned int flag, void *cbdata)
     ++			   unsigned int unused_flags, void *cbdata)
       {
       	struct hashmap *refname_map = cbdata;
       
     @@ builtin/fetch.c: static void set_option(struct transport *transport, const char
      -static int add_oid(const char *refname, const struct object_id *oid, int flags,
      -		   void *cb_data)
      +static int add_oid(const char *refname, const struct object_id *oid,
     -+		   unsigned int flags, void *cb_data)
     ++		   unsigned int unused_flags, void *cb_data)
       {
       	struct oid_array *oids = cb_data;
       
     @@ builtin/fsck.c: static int fsck_handle_reflog_ent(struct object_id *ooid, struct
       
       static int fsck_handle_reflog(const char *logname, const struct object_id *oid,
      -			      int flag, void *cb_data)
     -+			      unsigned int flag, void *cb_data)
     ++			      unsigned int unused_flags, void *cb_data)
       {
       	struct strbuf refname = STRBUF_INIT;
       
     @@ builtin/fsck.c: static int fsck_handle_reflog(const char *logname, const struct
       
       static int fsck_handle_ref(const char *refname, const struct object_id *oid,
      -			   int flag, void *cb_data)
     -+			   unsigned int flag, void *cb_data)
     ++			   unsigned int unused_flags, void *cb_data)
       {
       	struct object *obj;
       
     @@ builtin/gc.c: struct cg_auto_data {
      -		      const struct object_id *oid, int flags,
      -		      void *cb_data)
      +static int dfs_on_ref(const char *refname, const struct object_id *oid,
     -+		      unsigned int flags, void *cb_data)
     ++		      unsigned int unused_flags, void *cb_data)
       {
       	struct cg_auto_data *data = (struct cg_auto_data *)cb_data;
       	int result = 0;
     @@ builtin/name-rev.c: static int cmp_by_tag_and_age(const void *a_, const void *b_
       
      -static int name_ref(const char *path, const struct object_id *oid, int flags, void *cb_data)
      +static int name_ref(const char *path, const struct object_id *oid,
     -+		    unsigned int flags, void *cb_data)
     ++		    unsigned int unused_flags, void *cb_data)
       {
       	struct object *o = parse_object(the_repository, oid);
       	struct name_ref_data *data = cb_data;
     @@ builtin/pack-objects.c: static enum write_one_status write_one(struct hashfile *
      -static int mark_tagged(const char *path, const struct object_id *oid, int flag,
      -		       void *cb_data)
      +static int mark_tagged(const char *path, const struct object_id *oid,
     -+		       unsigned int flag, void *cb_data)
     ++		       unsigned int unused_flags, void *cb_data)
       {
       	struct object_id peeled;
       	struct object_entry *entry = packlist_find(&to_pack, oid);
     @@ builtin/pack-objects.c: static void add_tag_chain(const struct object_id *oid)
       
      -static int add_ref_tag(const char *tag, const struct object_id *oid, int flag, void *cb_data)
      +static int add_ref_tag(const char *tag, const struct object_id *oid,
     -+		       unsigned int flag, void *cb_data)
     ++		       unsigned int unused_flags, void *cb_data)
       {
       	struct object_id peeled;
       
     @@ builtin/rebase.c: int cmd_rebase(int argc, const char **argv, const char *prefix
       	const char *branch_name;
      -	int ret, flags, total_argc, in_progress = 0;
      +	int ret, total_argc, in_progress = 0;
     -+	unsigned int flags;
       	int keep_base = 0;
       	int ok_to_skip_pre_rebase = 0;
       	struct strbuf msg = STRBUF_INIT;
     +@@ builtin/rebase.c: int cmd_rebase(int argc, const char **argv, const char *prefix)
     + 		}
     + 	} else if (argc == 0) {
     + 		/* Do not need to switch branches, we are already on it. */
     ++		unsigned int flags;
     + 		options.head_name =
     + 			xstrdup_or_null(resolve_ref_unsafe("HEAD", 0, NULL,
     + 					 &flags));
      @@ builtin/rebase.c: int cmd_rebase(int argc, const char **argv, const char *prefix)
       	if (can_fast_forward(options.onto, options.upstream, options.restrict_revision,
       		    &options.orig_head, &merge_base) &&
       	    allow_preemptive_ff) {
      -		int flag;
     -+		unsigned int flag;
     ++		unsigned int unused_flags;
       
       		if (!(options.flags & REBASE_FORCE)) {
       			/* Lazily switch to the target branch if needed... */
     +@@ builtin/rebase.c: int cmd_rebase(int argc, const char **argv, const char *prefix)
     + 			if (!(options.flags & REBASE_NO_QUIET))
     + 				; /* be quiet */
     + 			else if (!strcmp(branch_name, "HEAD") &&
     +-				 resolve_ref_unsafe("HEAD", 0, NULL, &flag))
     ++				 resolve_ref_unsafe("HEAD", 0, NULL,
     ++						    &unused_flags))
     + 				puts(_("HEAD is up to date."));
     + 			else
     + 				printf(_("Current branch %s is up to date.\n"),
     +@@ builtin/rebase.c: int cmd_rebase(int argc, const char **argv, const char *prefix)
     + 		} else if (!(options.flags & REBASE_NO_QUIET))
     + 			; /* be quiet */
     + 		else if (!strcmp(branch_name, "HEAD") &&
     +-			 resolve_ref_unsafe("HEAD", 0, NULL, &flag))
     ++			 resolve_ref_unsafe("HEAD", 0, NULL, &unused_flags))
     + 			puts(_("HEAD is up to date, rebase forced."));
     + 		else
     + 			printf(_("Current branch %s is up to date, rebase "
      
       ## builtin/receive-pack.c ##
      @@ builtin/receive-pack.c: static void show_ref(const char *path, const struct object_id *oid)
     @@ builtin/receive-pack.c: static void show_ref(const char *path, const struct obje
       
       static int show_ref_cb(const char *path_full, const struct object_id *oid,
      -		       int flag, void *data)
     -+		       unsigned int flag, void *data)
     ++		       unsigned int unused_flags, void *data)
       {
       	struct oidset *seen = data;
       	const char *path = strip_namespace(path_full);
     +@@ builtin/receive-pack.c: static void run_update_post_hook(struct command *commands)
     + 
     + static void check_aliased_update_internal(struct command *cmd,
     + 					  struct string_list *list,
     +-					  const char *dst_name, int flag)
     ++					  const char *dst_name,
     ++					  unsigned int flags)
     + {
     + 	struct string_list_item *item;
     + 	struct command *dst_cmd;
     + 
     +-	if (!(flag & REF_ISSYMREF))
     ++	if (!(flags & REF_ISSYMREF))
     + 		return;
     + 
     + 	if (!dst_name) {
      @@ builtin/receive-pack.c: static void check_aliased_update(struct command *cmd, struct string_list *list)
       {
       	struct strbuf buf = STRBUF_INIT;
       	const char *dst_name;
      -	int flag;
     -+	unsigned int flag;
     ++	unsigned int flags;
       
       	strbuf_addf(&buf, "%s%s", get_git_namespace(), cmd->ref_name);
     - 	dst_name = resolve_ref_unsafe(buf.buf, 0, NULL, &flag);
     +-	dst_name = resolve_ref_unsafe(buf.buf, 0, NULL, &flag);
     +-	check_aliased_update_internal(cmd, list, dst_name, flag);
     ++	dst_name = resolve_ref_unsafe(buf.buf, 0, NULL, &flags);
     ++	check_aliased_update_internal(cmd, list, dst_name, flags);
     + 	strbuf_release(&buf);
     + }
     + 
      
       ## builtin/reflog.c ##
      @@ builtin/reflog.c: static int should_expire_reflog_ent_verbose(struct object_id *ooid,
     @@ builtin/reflog.c: static void reflog_expiry_cleanup(void *cb_data)
       
      -static int collect_reflog(const char *ref, const struct object_id *oid, int unused, void *cb_data)
      +static int collect_reflog(const char *ref, const struct object_id *oid,
     -+			  unsigned int unused, void *cb_data)
     ++			  unsigned int unused_flags, void *cb_data)
       {
       	struct worktree_reflogs *cb = cb_data;
       	struct worktree *worktree = cb->worktree;
     @@ builtin/remote.c: struct branches_for_remote {
       static int add_branch_for_removal(const char *refname,
      -	const struct object_id *oid, int flags, void *cb_data)
      +				  const struct object_id *oid,
     -+				  unsigned int flags, void *cb_data)
     ++				  unsigned int unused_flags, void *cb_data)
       {
       	struct branches_for_remote *branches = cb_data;
       	struct refspec_item refspec;
     @@ builtin/remote.c: struct rename_info {
       
       static int read_remote_branches(const char *refname,
      -	const struct object_id *oid, int flags, void *cb_data)
     -+				const struct object_id *oid, unsigned int flags,
     -+				void *cb_data)
     ++				const struct object_id *oid,
     ++				unsigned int unused_flags, void *cb_data)
       {
       	struct rename_info *rename = cb_data;
       	struct strbuf buf = STRBUF_INIT;
       	struct string_list_item *item;
      -	int flag;
     -+	unsigned int flag;
       	const char *symref;
       
       	strbuf_addf(&buf, "refs/remotes/%s/", rename->old_name);
     + 	if (starts_with(refname, buf.buf)) {
     ++		unsigned int flags;
     + 		item = string_list_append(rename->remote_branches, refname);
     +-		symref = resolve_ref_unsafe(refname, RESOLVE_REF_READING,
     +-					    NULL, &flag);
     +-		if (symref && (flag & REF_ISSYMREF))
     ++		symref = resolve_ref_unsafe(refname, RESOLVE_REF_READING, NULL,
     ++					    &flags);
     ++		if (symref && (flags & REF_ISSYMREF))
     + 			item->util = xstrdup(symref);
     + 		else
     + 			item->util = NULL;
      @@ builtin/remote.c: static int mv(int argc, const char **argv)
       	for_each_ref(read_remote_branches, &rename);
       	for (i = 0; i < remote_branches.nr; i++) {
       		struct string_list_item *item = remote_branches.items + i;
      -		int flag = 0;
     -+		unsigned int flag = 0;
     ++		unsigned int flags = 0;
       
     - 		read_ref_full(item->string, RESOLVE_REF_READING, NULL, &flag);
     - 		if (!(flag & REF_ISSYMREF))
     +-		read_ref_full(item->string, RESOLVE_REF_READING, NULL, &flag);
     +-		if (!(flag & REF_ISSYMREF))
     ++		read_ref_full(item->string, RESOLVE_REF_READING, NULL, &flags);
     ++		if (!(flags & REF_ISSYMREF))
     + 			continue;
     + 		if (delete_ref(NULL, item->string, NULL, REF_NO_DEREF))
     + 			die(_("deleting '%s' failed"), item->string);
      @@ builtin/remote.c: static void free_remote_ref_states(struct ref_states *states)
       }
       
     @@ builtin/remote.c: static void free_remote_ref_states(struct ref_states *states)
      
       ## builtin/repack.c ##
      @@ builtin/repack.c: struct midx_snapshot_ref_data {
     - };
       
       static int midx_snapshot_ref_one(const char *refname,
     --				 const struct object_id *oid,
     + 				 const struct object_id *oid,
      -				 int flag, void *_data)
     -+				 const struct object_id *oid, unsigned int flag,
     -+				 void *_data)
     ++				 unsigned int unused_flag, void *_data)
       {
       	struct midx_snapshot_ref_data *data = _data;
       	struct object_id peeled;
      
       ## builtin/replace.c ##
      @@ builtin/replace.c: struct show_data {
     - };
       
       static int show_reference(struct repository *r, const char *refname,
     --			  const struct object_id *oid,
     + 			  const struct object_id *oid,
      -			  int flag, void *cb_data)
     -+			  const struct object_id *oid, unsigned int flag,
     -+			  void *cb_data)
     ++			  unsigned int unused_flags, void *cb_data)
       {
       	struct show_data *data = cb_data;
       
     @@ builtin/rev-parse.c: static int show_default(void)
       
      -static int show_reference(const char *refname, const struct object_id *oid, int flag, void *cb_data)
      +static int show_reference(const char *refname, const struct object_id *oid,
     -+			  unsigned int flag, void *cb_data)
     ++			  unsigned int unused_flags, void *cb_data)
       {
       	if (ref_excluded(ref_excludes, refname))
       		return 0;
     @@ builtin/rev-parse.c: static int show_reference(const char *refname, const struct
       
      -static int anti_reference(const char *refname, const struct object_id *oid, int flag, void *cb_data)
      +static int anti_reference(const char *refname, const struct object_id *oid,
     -+			  unsigned int flag, void *cb_data)
     ++			  unsigned int unused_flags, void *cb_data)
       {
       	show_rev(REVERSED, oid, refname);
       	return 0;
     @@ builtin/show-branch.c: static int append_ref(const char *refname, const struct o
       
       static int append_head_ref(const char *refname, const struct object_id *oid,
      -			   int flag, void *cb_data)
     -+			   unsigned int flag, void *cb_data)
     ++			   unsigned int unused_flags, void *cb_data)
       {
       	struct object_id tmp;
       	int ofs = 11;
     @@ builtin/show-branch.c: static int append_head_ref(const char *refname, const str
       
       static int append_remote_ref(const char *refname, const struct object_id *oid,
      -			     int flag, void *cb_data)
     -+			     unsigned int flag, void *cb_data)
     ++			     unsigned int unused_flags, void *cb_data)
       {
       	struct object_id tmp;
       	int ofs = 13;
     +@@ builtin/show-branch.c: static int append_remote_ref(const char *refname, const struct object_id *oid,
     + }
     + 
     + static int append_tag_ref(const char *refname, const struct object_id *oid,
     +-			  int flag, void *cb_data)
     ++			  int unused_flags, void *cb_data)
     + {
     + 	if (!starts_with(refname, "refs/tags/"))
     + 		return 0;
      @@ builtin/show-branch.c: static const char *match_ref_pattern = NULL;
       static int match_ref_slash = 0;
       
       static int append_matching_ref(const char *refname, const struct object_id *oid,
      -			       int flag, void *cb_data)
     -+			       unsigned int flag, void *cb_data)
     ++			       unsigned int flags, void *cb_data)
       {
       	/* we want to allow pattern hold/<asterisk> to show all
       	 * branches under refs/heads/hold/, and v0.99.9? to show
     +@@ builtin/show-branch.c: static int append_matching_ref(const char *refname, const struct object_id *oid,
     + 	if (wildmatch(match_ref_pattern, tail, 0))
     + 		return 0;
     + 	if (starts_with(refname, "refs/heads/"))
     +-		return append_head_ref(refname, oid, flag, cb_data);
     ++		return append_head_ref(refname, oid, flags, cb_data);
     + 	if (starts_with(refname, "refs/tags/"))
     +-		return append_tag_ref(refname, oid, flag, cb_data);
     ++		return append_tag_ref(refname, oid, flags, cb_data);
     + 	return append_ref(refname, oid, 0);
     + }
     + 
      
       ## builtin/show-ref.c ##
      @@ builtin/show-ref.c: static void show_one(const char *refname, const struct object_id *oid)
     @@ builtin/show-ref.c: match:
       
       static int add_existing(const char *refname, const struct object_id *oid,
      -			int flag, void *cbdata)
     -+			unsigned int flag, void *cbdata)
     ++			unsigned int unused_flags, void *cbdata)
       {
       	struct string_list *list = (struct string_list *)cbdata;
       	string_list_insert(list, refname);
     @@ builtin/submodule--helper.c: static void print_status(unsigned int flags, char s
      -				     const struct object_id *oid, int flags,
      -				     void *cb_data)
      +				     const struct object_id *oid,
     -+				     unsigned int flags, void *cb_data)
     ++				     unsigned int unused_flags, void *cb_data)
       {
       	struct object_id *output = cb_data;
       	if (oid)
     @@ builtin/symbolic-ref.c: static const char * const git_symbolic_ref_usage[] = {
       static int check_symref(const char *HEAD, int quiet, int shorten, int print)
       {
      -	int flag;
     -+	unsigned int flag;
     - 	const char *refname = resolve_ref_unsafe(HEAD, 0, NULL, &flag);
     +-	const char *refname = resolve_ref_unsafe(HEAD, 0, NULL, &flag);
     ++	unsigned int flags;
     ++	const char *refname = resolve_ref_unsafe(HEAD, 0, NULL, &flags);
       
       	if (!refname)
     + 		die("No such ref: %s", HEAD);
     +-	else if (!(flag & REF_ISSYMREF)) {
     ++	else if (!(flags & REF_ISSYMREF)) {
     + 		if (!quiet)
     + 			die("ref %s is not a symbolic ref", HEAD);
     + 		else
      
       ## bundle.c ##
      @@ bundle.c: static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
     @@ bundle.c: static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
       		char *ref;
       		const char *display_ref;
      -		int flag;
     -+		unsigned int flag;
     ++		unsigned int flags;
       
       		if (e->item->flags & UNINTERESTING)
       			continue;
     + 		if (dwim_ref(e->name, strlen(e->name), &oid, &ref, 0) != 1)
     + 			goto skip_write_ref;
     +-		if (read_ref_full(e->name, RESOLVE_REF_READING, &oid, &flag))
     +-			flag = 0;
     +-		display_ref = (flag & REF_ISSYMREF) ? e->name : ref;
     ++		if (read_ref_full(e->name, RESOLVE_REF_READING, &oid, &flags))
     ++			flags = 0;
     ++		display_ref = (flags & REF_ISSYMREF) ? e->name : ref;
     + 
     + 		if (e->item->type == OBJ_TAG &&
     + 				!is_tag_in_date_range(e->item, revs)) {
      
       ## commit-graph.c ##
      @@ commit-graph.c: struct refs_cb_data {
     @@ delta-islands.c: static void add_ref_to_island(const char *island_name, const st
       
       static int find_island_for_ref(const char *refname, const struct object_id *oid,
      -			       int flags, void *data)
     -+			       unsigned int flags, void *data)
     ++			       unsigned int unused_flags, void *data)
       {
       	/*
       	 * We should advertise 'ARRAY_SIZE(matches) - 2' as the max,
     @@ fetch-pack.c: static int rev_list_insert_ref(struct fetch_negotiator *negotiator
      -				   int flag, void *cb_data)
      +static int rev_list_insert_ref_oid(const char *refname,
      +				   const struct object_id *oid,
     -+				   unsigned int flag, void *cb_data)
     ++				   unsigned int unused_flags, void *cb_data)
       {
       	return rev_list_insert_ref(cb_data, oid);
       }
     @@ fetch-pack.c: static int mark_complete(const struct object_id *oid)
       
       static int mark_complete_oid(const char *refname, const struct object_id *oid,
      -			     int flag, void *cb_data)
     -+			     unsigned int flag, void *cb_data)
     ++			     unsigned int unused_flags, void *cb_data)
       {
       	return mark_complete(oid);
       }
     @@ http-backend.c: static void get_info_refs(struct strbuf *hdr, char *arg)
       
       static int show_head_ref(const char *refname, const struct object_id *oid,
      -			 int flag, void *cb_data)
     -+			 unsigned int flag, void *cb_data)
     ++			 unsigned int flags, void *cb_data)
       {
       	struct strbuf *buf = cb_data;
       
     +-	if (flag & REF_ISSYMREF) {
     ++	if (flags & REF_ISSYMREF) {
     + 		const char *target = resolve_ref_unsafe(refname,
     + 							RESOLVE_REF_READING,
     + 							NULL, NULL);
      
       ## log-tree.c ##
      @@ log-tree.c: static int ref_filter_match(const char *refname,
     @@ log-tree.c: static int ref_filter_match(const char *refname,
       
       static int add_ref_decoration(const char *refname, const struct object_id *oid,
      -			      int flags, void *cb_data)
     -+			      unsigned int flags, void *cb_data)
     ++			      unsigned int unused_flags, void *cb_data)
       {
       	struct object *obj;
       	enum object_type objtype;
     @@ ls-refs.c: struct ls_refs_data {
       
       static int send_ref(const char *refname, const struct object_id *oid,
      -		    int flag, void *cb_data)
     -+		    unsigned int flag, void *cb_data)
     ++		    unsigned int flags, void *cb_data)
       {
       	struct ls_refs_data *data = cb_data;
       	const char *refname_nons = strip_namespace(refname);
     +@@ ls-refs.c: static int send_ref(const char *refname, const struct object_id *oid,
     + 		strbuf_addf(&data->buf, "%s %s", oid_to_hex(oid), refname_nons);
     + 	else
     + 		strbuf_addf(&data->buf, "unborn %s", refname_nons);
     +-	if (data->symrefs && flag & REF_ISSYMREF) {
     ++	if (data->symrefs && flags & REF_ISSYMREF) {
     + 		struct object_id unused;
     +-		const char *symref_target = resolve_ref_unsafe(refname, 0,
     +-							       &unused,
     +-							       &flag);
     ++		const char *symref_target =
     ++			resolve_ref_unsafe(refname, 0, &unused, &flags);
     + 
     + 		if (!symref_target)
     + 			die("'%s' is a symref but it is not?", refname);
      @@ ls-refs.c: static void send_possibly_unborn_head(struct ls_refs_data *data)
       {
       	struct strbuf namespaced = STRBUF_INIT;
       	struct object_id oid;
      -	int flag;
     -+	unsigned int flag;
     ++	unsigned int flags;
       	int oid_is_null;
       
       	strbuf_addf(&namespaced, "%sHEAD", get_git_namespace());
     +-	if (!resolve_ref_unsafe(namespaced.buf, 0, &oid, &flag))
     ++	if (!resolve_ref_unsafe(namespaced.buf, 0, &oid, &flags))
     + 		return; /* bad ref */
     + 	oid_is_null = is_null_oid(&oid);
     + 	if (!oid_is_null ||
     +-	    (data->unborn && data->symrefs && (flag & REF_ISSYMREF)))
     +-		send_ref(namespaced.buf, oid_is_null ? NULL : &oid, flag, data);
     ++	    (data->unborn && data->symrefs && (flags & REF_ISSYMREF)))
     ++		send_ref(namespaced.buf, oid_is_null ? NULL : &oid, flags,
     ++			 data);
     + 	strbuf_release(&namespaced);
     + }
     + 
      
       ## midx.c ##
      @@ midx.c: static void prepare_midx_packing_data(struct packing_data *pdata,
     @@ midx.c: static void prepare_midx_packing_data(struct packing_data *pdata,
      -			      const struct object_id *oid,
      -			      int flag, void *cb_data)
      +static int add_ref_to_pending(const char *refname, const struct object_id *oid,
     -+			      unsigned int flag, void *cb_data)
     ++			      unsigned int flags, void *cb_data)
       {
       	struct rev_info *revs = (struct rev_info*)cb_data;
       	struct object *object;
     + 
     +-	if ((flag & REF_ISSYMREF) && (flag & REF_ISBROKEN)) {
     ++	if ((flags & REF_ISSYMREF) && (flags & REF_ISBROKEN)) {
     + 		warning("symbolic ref is dangling: %s", refname);
     + 		return 0;
     + 	}
      
       ## negotiator/default.c ##
      @@ negotiator/default.c: static void rev_list_push(struct negotiation_state *ns,
     @@ negotiator/default.c: static void rev_list_push(struct negotiation_state *ns,
       
       static int clear_marks(const char *refname, const struct object_id *oid,
      -		       int flag, void *cb_data)
     -+		       unsigned int flag, void *cb_data)
     ++		       unsigned int unused_flags, void *cb_data)
       {
       	struct object *o = deref_tag(the_repository, parse_object(the_repository, oid), refname, 0);
       
     @@ negotiator/skipping.c: static struct entry *rev_list_push(struct data *data, str
       
       static int clear_marks(const char *refname, const struct object_id *oid,
      -		       int flag, void *cb_data)
     -+		       unsigned int flag, void *cb_data)
     ++		       unsigned int unused_flags, void *cb_data)
       {
       	struct object *o = deref_tag(the_repository, parse_object(the_repository, oid), refname, 0);
       
     @@ notes.c: out:
      -				   int flag, void *cb)
      +static int string_list_add_one_ref(const char *refname,
      +				   const struct object_id *oid,
     -+				   unsigned int flag, void *cb)
     ++				   unsigned int unused_flags, void *cb)
       {
       	struct string_list *refs = cb;
       	if (!unsorted_string_list_has_string(refs, refname))
     @@ object-name.c: struct handle_one_ref_cb {
       
       static int handle_one_ref(const char *path, const struct object_id *oid,
      -			  int flag, void *cb_data)
     -+			  unsigned int flag, void *cb_data)
     ++			  unsigned int unused_flags, void *cb_data)
       {
       	struct handle_one_ref_cb *cb = cb_data;
       	struct commit_list **list = cb->list;
     @@ reachable.c: static void update_progress(struct connectivity_progress *cp)
       
       static int add_one_ref(const char *path, const struct object_id *oid,
      -		       int flag, void *cb_data)
     -+		       unsigned int flag, void *cb_data)
     ++		       unsigned int flags, void *cb_data)
       {
       	struct rev_info *revs = (struct rev_info *)cb_data;
       	struct object *object;
     + 
     +-	if ((flag & REF_ISSYMREF) && (flag & REF_ISBROKEN)) {
     ++	if ((flags & REF_ISSYMREF) && (flags & REF_ISBROKEN)) {
     + 		warning("symbolic ref is dangling: %s", path);
     + 		return 0;
     + 	}
      
       ## ref-filter.c ##
      @@ ref-filter.c: struct ref_filter_cbdata {
     @@ ref-filter.c: struct ref_filter_cbdata {
        */
      -static int ref_filter_handler(const char *refname, const struct object_id *oid, int flag, void *cb_data)
      +static int ref_filter_handler(const char *refname, const struct object_id *oid,
     -+			      unsigned int flag, void *cb_data)
     ++			      unsigned int flags, void *cb_data)
       {
       	struct ref_filter_cbdata *ref_cbdata = cb_data;
       	struct ref_filter *filter = ref_cbdata->filter;
     +@@ ref-filter.c: static int ref_filter_handler(const char *refname, const struct object_id *oid,
     + 	struct commit *commit = NULL;
     + 	unsigned int kind;
     + 
     +-	if (flag & REF_BAD_NAME) {
     ++	if (flags & REF_BAD_NAME) {
     + 		warning(_("ignoring ref with broken name %s"), refname);
     + 		return 0;
     + 	}
     + 
     +-	if (flag & REF_ISBROKEN) {
     ++	if (flags & REF_ISBROKEN) {
     + 		warning(_("ignoring broken ref %s"), refname);
     + 		return 0;
     + 	}
     +@@ ref-filter.c: static int ref_filter_handler(const char *refname, const struct object_id *oid,
     + 	 */
     + 	ref = ref_array_push(ref_cbdata->array, refname, oid);
     + 	ref->commit = commit;
     +-	ref->flag = flag;
     ++	ref->flag = flags;
     + 	ref->kind = kind;
     + 
     + 	return 0;
      
       ## refs.c ##
      @@ refs.c: static unsigned char refname_disposition[256] = {
     @@ refs.c: int ref_resolves_to_object(const char *refname,
      -			  const char *refname, int resolve_flags,
      -			  struct object_id *oid, int *flags)
      +char *refs_resolve_refdup(struct ref_store *refs, const char *refname,
     -+			  int resolve_flags, struct object_id *oid,
     ++			  unsigned int resolve_flags, struct object_id *oid,
      +			  unsigned int *flags)
       {
       	const char *result;
     @@ refs.c: int head_ref_namespaced(each_ref_fn fn, void *cb_data)
       	int ret = 0;
       	struct object_id oid;
      -	int flag;
     -+	unsigned int flag;
     ++	unsigned int flags;
       
       	strbuf_addf(&buf, "%sHEAD", get_git_namespace());
     - 	if (!read_ref_full(buf.buf, RESOLVE_REF_READING, &oid, &flag))
     +-	if (!read_ref_full(buf.buf, RESOLVE_REF_READING, &oid, &flag))
     +-		ret = fn(buf.buf, &oid, flag, cb_data);
     ++	if (!read_ref_full(buf.buf, RESOLVE_REF_READING, &oid, &flags))
     ++		ret = fn(buf.buf, &oid, flags, cb_data);
     + 	strbuf_release(&buf);
     + 
     + 	return ret;
      @@ refs.c: int expand_ref(struct repository *repo, const char *str, int len,
       	for (p = ref_rev_parse_rules; *p; p++) {
       		struct object_id oid_from_ref;
       		struct object_id *this_result;
      -		int flag;
     -+		unsigned int flag;
     ++		unsigned int flags;
       		struct ref_store *refs = get_main_ref_store(repo);
       		int ignore_errno;
       
     +@@ refs.c: int expand_ref(struct repository *repo, const char *str, int len,
     + 		strbuf_reset(&fullref);
     + 		strbuf_addf(&fullref, *p, len, str);
     + 		r = refs_resolve_ref_unsafe(refs, fullref.buf,
     +-					    RESOLVE_REF_READING,
     +-					    this_result, &flag,
     +-					    &ignore_errno);
     ++					    RESOLVE_REF_READING, this_result,
     ++					    &flags, &ignore_errno);
     + 		if (r) {
     + 			if (!refs_found++)
     + 				*ref = xstrdup(r);
     + 			if (!warn_ambiguous_refs)
     + 				break;
     +-		} else if ((flag & REF_ISSYMREF) && strcmp(fullref.buf, "HEAD")) {
     ++		} else if ((flags & REF_ISSYMREF) &&
     ++			   strcmp(fullref.buf, "HEAD")) {
     + 			warning(_("ignoring dangling symref %s"), fullref.buf);
     +-		} else if ((flag & REF_ISBROKEN) && strchr(fullref.buf, '/')) {
     ++		} else if ((flags & REF_ISBROKEN) && strchr(fullref.buf, '/')) {
     + 			warning(_("ignoring broken ref %s"), fullref.buf);
     + 		}
     + 	}
      @@ refs.c: const char *find_descendant_ref(const char *dirname,
       int refs_head_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
       {
       	struct object_id oid;
      -	int flag;
     -+	unsigned int flag;
     ++	unsigned int flags;
       	int ignore_errno;
       
     - 	if (refs_resolve_ref_unsafe(refs, "HEAD", RESOLVE_REF_READING,
     +-	if (refs_resolve_ref_unsafe(refs, "HEAD", RESOLVE_REF_READING,
     +-				    &oid, &flag, &ignore_errno))
     +-		return fn("HEAD", &oid, flag, cb_data);
     ++	if (refs_resolve_ref_unsafe(refs, "HEAD", RESOLVE_REF_READING, &oid,
     ++				    &flags, &ignore_errno))
     ++		return fn("HEAD", &oid, flags, cb_data);
     + 
     + 	return 0;
     + }
      @@ refs.c: struct do_for_each_ref_help {
       	void *cb_data;
       };
     @@ refs.c: int refs_read_raw_ref(struct ref_store *ref_store, const char *refname,
      -				    struct object_id *oid,
      -				    int *flags, int *failure_errno)
      +const char *refs_resolve_ref_unsafe(struct ref_store *refs, const char *refname,
     -+				    int resolve_flags, struct object_id *oid,
     -+				    unsigned int *flags, int *failure_errno)
     ++				    unsigned int resolve_flags,
     ++				    struct object_id *oid, unsigned int *flags,
     ++				    int *failure_errno)
       {
       	static struct strbuf sb_refname = STRBUF_INIT;
       	struct object_id unused_oid;
     @@ refs.c: int refs_read_raw_ref(struct ref_store *ref_store, const char *refname,
       
       	assert(failure_errno);
      @@ refs.c: int refs_init_db(struct strbuf *err)
     + 	return refs->be->init_db(refs, err);
       }
       
     - const char *resolve_ref_unsafe(const char *refname, int resolve_flags,
     +-const char *resolve_ref_unsafe(const char *refname, int resolve_flags,
      -			       struct object_id *oid, int *flags)
     ++const char *resolve_ref_unsafe(const char *refname, unsigned int resolve_flags,
      +			       struct object_id *oid, unsigned int *flags)
       {
       	int ignore_errno;
     @@ refs.c: int resolve_gitlink_ref(const char *submodule, const char *refname,
       {
       	struct ref_store *refs;
      -	int flags;
     -+	unsigned int flags;
     ++	unsigned int unused_flags;
       	int ignore_errno;
       
       	refs = get_submodule_ref_store(submodule);
     +@@ refs.c: int resolve_gitlink_ref(const char *submodule, const char *refname,
     + 	if (!refs)
     + 		return -1;
     + 
     +-	if (!refs_resolve_ref_unsafe(refs, refname, 0, oid, &flags,
     +-				     &ignore_errno) || is_null_oid(oid))
     ++	if (!refs_resolve_ref_unsafe(refs, refname, 0, oid, &unused_flags,
     ++				     &ignore_errno) ||
     ++	    is_null_oid(oid))
     + 		return -1;
     + 	return 0;
     + }
      
       ## refs.h ##
      @@ refs.h: struct worktree;
     @@ refs.h: struct worktree;
      -				    int resolve_flags,
      -				    struct object_id *oid,
      -				    int *flags, int *failure_errno);
     -+const char *refs_resolve_ref_unsafe(struct ref_store *refs, const char *refname,
     -+				    int resolve_flags, struct object_id *oid,
     -+				    unsigned int *flags, int *failure_errno);
     - 
     - const char *resolve_ref_unsafe(const char *refname, int resolve_flags,
     +-
     +-const char *resolve_ref_unsafe(const char *refname, int resolve_flags,
      -			       struct object_id *oid, int *flags);
     -+			       struct object_id *oid, unsigned int *flags);
     - 
     +-
      -char *refs_resolve_refdup(struct ref_store *refs,
      -			  const char *refname, int resolve_flags,
      -			  struct object_id *oid, int *flags);
      -char *resolve_refdup(const char *refname, int resolve_flags,
      -		     struct object_id *oid, int *flags);
     +-
     +-int read_ref_full(const char *refname, int resolve_flags,
     +-		  struct object_id *oid, int *flags);
     ++const char *refs_resolve_ref_unsafe(struct ref_store *refs, const char *refname,
     ++				    unsigned int resolve_flags,
     ++				    struct object_id *oid, unsigned int *flags,
     ++				    int *failure_errno);
     ++
     ++const char *resolve_ref_unsafe(const char *refname, unsigned int resolve_flags,
     ++			       struct object_id *oid, unsigned int *flags);
     ++
      +char *refs_resolve_refdup(struct ref_store *refs, const char *refname,
     -+			  int resolve_flags, struct object_id *oid,
     ++			  unsigned int resolve_flags, struct object_id *oid,
      +			  unsigned int *flags);
      +char *resolve_refdup(const char *refname, unsigned int resolve_flags,
      +		     struct object_id *oid, unsigned int *flags);
     - 
     --int read_ref_full(const char *refname, int resolve_flags,
     --		  struct object_id *oid, int *flags);
     ++
      +int read_ref_full(const char *refname, unsigned int resolve_flags,
      +		  struct object_id *oid, unsigned int *flags);
       int read_ref(const char *refname, struct object_id *oid);
     @@ refs/files-backend.c: static void loose_fill_ref_dir(struct ref_store *ref_store
       		struct object_id oid;
       		struct stat st;
      -		int flag;
     -+		unsigned int flag;
       
       		if (de->d_name[0] == '.')
       			continue;
     +@@ refs/files-backend.c: static void loose_fill_ref_dir(struct ref_store *ref_store,
     + 							  refname.len));
     + 		} else {
     + 			int ignore_errno;
     +-			if (!refs_resolve_ref_unsafe(&refs->base,
     +-						     refname.buf,
     +-						     RESOLVE_REF_READING,
     +-						     &oid, &flag, &ignore_errno)) {
     ++			unsigned int flags;
     ++			if (!refs_resolve_ref_unsafe(&refs->base, refname.buf,
     ++						     RESOLVE_REF_READING, &oid,
     ++						     &flags, &ignore_errno)) {
     + 				oidclr(&oid);
     +-				flag |= REF_ISBROKEN;
     ++				flags |= REF_ISBROKEN;
     + 			} else if (is_null_oid(&oid)) {
     + 				/*
     + 				 * It is so astronomically unlikely
     +@@ refs/files-backend.c: static void loose_fill_ref_dir(struct ref_store *ref_store,
     + 				 * file to be repo corruption
     + 				 * (probably due to a software bug).
     + 				 */
     +-				flag |= REF_ISBROKEN;
     ++				flags |= REF_ISBROKEN;
     + 			}
     + 
     + 			if (check_refname_format(refname.buf,
     +@@ refs/files-backend.c: static void loose_fill_ref_dir(struct ref_store *ref_store,
     + 				if (!refname_is_safe(refname.buf))
     + 					die("loose refname is dangerous: %s", refname.buf);
     + 				oidclr(&oid);
     +-				flag |= REF_BAD_NAME | REF_ISBROKEN;
     ++				flags |= REF_BAD_NAME | REF_ISBROKEN;
     + 			}
     +-			add_entry_to_dir(dir,
     +-					 create_ref_entry(refname.buf, &oid, flag));
     ++			add_entry_to_dir(dir, create_ref_entry(refname.buf,
     ++							       &oid, flags));
     + 		}
     + 		strbuf_setlen(&refname, dirnamelen);
     + 		strbuf_setlen(&path, path_baselen);
      @@ refs/files-backend.c: static int files_copy_or_rename_ref(struct ref_store *ref_store,
       	struct files_ref_store *refs =
       		files_downcast(ref_store, REF_STORE_WRITE, "rename_ref");
       	struct object_id orig_oid;
      -	int flag = 0, logmoved = 0;
      +	int logmoved = 0;
     -+	unsigned int flag = 0;
     ++	unsigned int flags = 0;
       	struct ref_lock *lock;
       	struct stat loginfo;
       	struct strbuf sb_oldref = STRBUF_INIT;
     +@@ refs/files-backend.c: static int files_copy_or_rename_ref(struct ref_store *ref_store,
     + 	}
     + 
     + 	if (!refs_resolve_ref_unsafe(&refs->base, oldrefname,
     +-				     RESOLVE_REF_READING | RESOLVE_REF_NO_RECURSE,
     +-				     &orig_oid, &flag, &ignore_errno)) {
     ++				     RESOLVE_REF_READING |
     ++					     RESOLVE_REF_NO_RECURSE,
     ++				     &orig_oid, &flags, &ignore_errno)) {
     + 		ret = error("refname %s not found", oldrefname);
     + 		goto out;
     + 	}
     + 
     +-	if (flag & REF_ISSYMREF) {
     ++	if (flags & REF_ISSYMREF) {
     + 		if (copy)
     + 			ret = error("refname %s is a symbolic ref, copying it is not supported",
     + 				    oldrefname);
     +@@ refs/files-backend.c: static int files_copy_or_rename_ref(struct ref_store *ref_store,
     + 		goto rollbacklog;
     + 	}
     + 
     +-	flag = log_all_ref_updates;
     ++	flags = log_all_ref_updates;
     + 	log_all_ref_updates = LOG_REFS_NONE;
     + 	if (write_ref_to_lockfile(lock, &orig_oid, 0, &err) ||
     + 	    commit_ref_update(refs, lock, &orig_oid, NULL, &err)) {
     + 		error("unable to write current sha1 into %s: %s", oldrefname, err.buf);
     + 		strbuf_release(&err);
     + 	}
     +-	log_all_ref_updates = flag;
     ++	log_all_ref_updates = flags;
     + 
     +  rollbacklog:
     + 	if (logmoved && rename(sb_newref.buf, sb_oldref.buf))
     +@@ refs/files-backend.c: static int log_ref_write_fd(int fd, const struct object_id *old_oid,
     + }
     + 
     + static int files_log_ref_write(struct files_ref_store *refs,
     +-			       const char *refname, const struct object_id *old_oid,
     ++			       const char *refname,
     ++			       const struct object_id *old_oid,
     + 			       const struct object_id *new_oid, const char *msg,
     +-			       int flags, struct strbuf *err)
     ++			       unsigned int flags, struct strbuf *err)
     + {
     + 	int logfd, result;
     + 
      @@ refs/files-backend.c: static int commit_ref_update(struct files_ref_store *refs,
       		 * check with HEAD only which should cover 99% of all usage
       		 * scenarios (even 100% of the default ones).
       		 */
      -		int head_flag;
     -+		unsigned int head_flag;
     ++		unsigned int head_flags;
       		const char *head_ref;
       		int ignore_errno;
       
     + 		head_ref = refs_resolve_ref_unsafe(&refs->base, "HEAD",
     +-						   RESOLVE_REF_READING,
     +-						   NULL, &head_flag,
     +-						   &ignore_errno);
     +-		if (head_ref && (head_flag & REF_ISSYMREF) &&
     ++						   RESOLVE_REF_READING, NULL,
     ++						   &head_flags, &ignore_errno);
     ++		if (head_ref && (head_flags & REF_ISSYMREF) &&
     + 		    !strcmp(head_ref, lock->ref_name)) {
     + 			struct strbuf log_err = STRBUF_INIT;
     + 			if (files_log_ref_write(refs, "HEAD",
      @@ refs/files-backend.c: static int files_reflog_iterator_advance(struct ref_iterator *ref_iterator)
       	int ignore_errno;
       
     @@ refs/files-backend.c: static int files_transaction_abort(struct ref_store *ref_s
      -static int ref_present(const char *refname,
      -		       const struct object_id *oid, int flags, void *cb_data)
      +static int ref_present(const char *refname, const struct object_id *oid,
     -+		       unsigned int flags, void *cb_data)
     ++		       unsigned int unused_flags, void *cb_data)
       {
       	struct string_list *affected_refnames = cb_data;
       
     @@ remote.c: static void alias_all_urls(struct remote_state *remote_state)
       static void read_config(struct repository *repo)
       {
      -	int flag;
     -+	unsigned int flag;
     ++	unsigned int flags;
       
       	if (repo->remote_state->initialized)
       		return;
     +@@ remote.c: static void read_config(struct repository *repo)
     + 	if (startup_info->have_repository) {
     + 		int ignore_errno;
     + 		const char *head_ref = refs_resolve_ref_unsafe(
     +-			get_main_ref_store(repo), "HEAD", 0, NULL, &flag, &ignore_errno);
     +-		if (head_ref && (flag & REF_ISSYMREF) &&
     ++			get_main_ref_store(repo), "HEAD", 0, NULL, &flags,
     ++			&ignore_errno);
     ++		if (head_ref && (flags & REF_ISSYMREF) &&
     + 		    skip_prefix(head_ref, "refs/heads/", &head_ref)) {
     + 			repo->remote_state->current_branch = make_branch(
     + 				repo->remote_state, head_ref, strlen(head_ref));
      @@ remote.c: static int match_explicit(struct ref *src, struct ref *dst,
       		return -1;
       
       	if (!dst_value) {
      -		int flag;
     -+		unsigned int flag;
     - 
     - 		dst_value = resolve_ref_unsafe(matched_src->name,
     - 					       RESOLVE_REF_READING,
     +-
     +-		dst_value = resolve_ref_unsafe(matched_src->name,
     +-					       RESOLVE_REF_READING,
     +-					       NULL, &flag);
     +-		if (!dst_value ||
     +-		    ((flag & REF_ISSYMREF) &&
     +-		     !starts_with(dst_value, "refs/heads/")))
     ++		unsigned int flags;
     ++
     ++		dst_value = resolve_ref_unsafe(
     ++			matched_src->name, RESOLVE_REF_READING, NULL, &flags);
     ++		if (!dst_value || ((flags & REF_ISSYMREF) &&
     ++				   !starts_with(dst_value, "refs/heads/")))
     + 			die(_("%s cannot be resolved to branch"),
     + 			    matched_src->name);
     + 	}
      @@ remote.c: const char *branch_get_push(struct branch *branch, struct strbuf *err)
       
       static int ignore_symref_update(const char *refname)
       {
      -	int flag;
     -+	unsigned int flag;
     ++	unsigned int flags;
       
     - 	if (!resolve_ref_unsafe(refname, 0, NULL, &flag))
     +-	if (!resolve_ref_unsafe(refname, 0, NULL, &flag))
     ++	if (!resolve_ref_unsafe(refname, 0, NULL, &flags))
       		return 0; /* non-existing refs are OK */
     +-	return (flag & REF_ISSYMREF);
     ++	return (flags & REF_ISSYMREF);
     + }
     + 
     + /*
      @@ remote.c: int format_tracking_info(struct branch *branch, struct strbuf *sb,
       }
       
     @@ replace-object.c
       
      -static int register_replace_ref(struct repository *r,
      -				const char *refname,
     --				const struct object_id *oid,
     --				int flag, void *cb_data)
      +static int register_replace_ref(struct repository *r, const char *refname,
     -+				const struct object_id *oid, unsigned int flag,
     -+				void *cb_data)
     + 				const struct object_id *oid,
     +-				int flag, void *cb_data)
     ++				unsigned int unused_flags, void *cb_data)
       {
       	/* Get sha1 from refname */
       	const char *slash = strrchr(refname, '/');
     @@ revision.c: int ref_excluded(struct string_list *ref_excludes, const char *path)
       
       static int handle_one_ref(const char *path, const struct object_id *oid,
      -			  int flag, void *cb_data)
     -+			  unsigned int flag, void *cb_data)
     ++			  unsigned int unused_flags, void *cb_data)
       {
       	struct all_refs_cb *cb = cb_data;
       	struct object *object;
      @@ revision.c: static int handle_one_reflog_ent(struct object_id *ooid, struct object_id *noid,
     - }
       
       static int handle_one_reflog(const char *refname_in_wt,
     --			     const struct object_id *oid,
     + 			     const struct object_id *oid,
      -			     int flag, void *cb_data)
     -+			     const struct object_id *oid, unsigned int flag,
     -+			     void *cb_data)
     ++			     unsigned int unused_flags, void *cb_data)
       {
       	struct all_refs_cb *cb = cb_data;
       	struct strbuf refname = STRBUF_INIT;
     @@ server-info.c: out:
       
       static int add_info_ref(const char *path, const struct object_id *oid,
      -			int flag, void *cb_data)
     -+			unsigned int flag, void *cb_data)
     ++			unsigned int unused_flags, void *cb_data)
       {
       	struct update_info_ctx *uic = cb_data;
       	struct object *o = parse_object(the_repository, oid);
     @@ shallow.c: static void paint_down(struct paint_info *info, const struct object_i
       
       static int mark_uninteresting(const char *refname, const struct object_id *oid,
      -			      int flags, void *cb_data)
     -+			      unsigned int flags, void *cb_data)
     ++			      unsigned int unused_flags, void *cb_data)
       {
       	struct commit *commit = lookup_commit_reference_gently(the_repository,
       							       oid, 1);
     @@ shallow.c: struct commit_array {
       
       static int add_ref(const char *refname, const struct object_id *oid,
      -		   int flags, void *cb_data)
     -+		   unsigned int flags, void *cb_data)
     ++		   unsigned int unused_flags, void *cb_data)
       {
       	struct commit_array *ca = cb_data;
       	ALLOC_GROW(ca->commits, ca->nr + 1, ca->alloc);
     @@ submodule.c: static void free_submodules_oids(struct string_list *submodules)
       
       static int has_remote(const char *refname, const struct object_id *oid,
      -		      int flags, void *cb_data)
     -+		      unsigned int flags, void *cb_data)
     ++		      unsigned int unused_flags, void *cb_data)
       {
       	return 1;
       }
     @@ submodule.c: int push_unpushed_submodules(struct repository *r,
       
       static int append_oid_to_array(const char *ref, const struct object_id *oid,
      -			       int flags, void *data)
     -+			       unsigned int flags, void *data)
     ++			       unsigned int unused_flags, void *data)
       {
       	struct oid_array *array = data;
       	oid_array_append(array, oid);
     @@ transport-helper.c: static int push_refs_with_export(struct transport *transport
       				if (!ref->deletion) {
       					const char *name;
      -					int flag;
     -+					unsigned int flag;
     ++					unsigned int ref_flags;
       
       					/* Follow symbolic refs (mainly for HEAD). */
     - 					name = resolve_ref_unsafe(ref->peer_ref->name,
     +-					name = resolve_ref_unsafe(ref->peer_ref->name,
     +-								  RESOLVE_REF_READING,
     +-								  &oid, &flag);
     +-					if (!name || !(flag & REF_ISSYMREF))
     ++					name = resolve_ref_unsafe(
     ++						ref->peer_ref->name,
     ++						RESOLVE_REF_READING, &oid,
     ++						&ref_flags);
     ++					if (!name ||
     ++					    !(ref_flags & REF_ISSYMREF))
     + 						name = ref->peer_ref->name;
     + 
     + 					strbuf_addf(&buf, "%s:%s", name, ref->name);
      
       ## transport.c ##
      @@ transport.c: static void set_upstreams(struct transport *transport, struct ref *refs,
     @@ transport.c: static void set_upstreams(struct transport *transport, struct ref *
       		const char *tmp;
       		const char *remotename;
      -		int flag = 0;
     -+		unsigned int flag = 0;
     ++		unsigned int ref_flags = 0;
       		/*
       		 * Check suitability for tracking. Must be successful /
       		 * already up-to-date ref create/modify (not delete).
     +@@ transport.c: static void set_upstreams(struct transport *transport, struct ref *refs,
     + 		/* Follow symbolic refs (mainly for HEAD). */
     + 		localname = ref->peer_ref->name;
     + 		remotename = ref->name;
     +-		tmp = resolve_ref_unsafe(localname, RESOLVE_REF_READING,
     +-					 NULL, &flag);
     +-		if (tmp && flag & REF_ISSYMREF &&
     +-			starts_with(tmp, "refs/heads/"))
     ++		tmp = resolve_ref_unsafe(localname, RESOLVE_REF_READING, NULL,
     ++					 &ref_flags);
     ++		if (tmp && ref_flags & REF_ISSYMREF &&
     ++		    starts_with(tmp, "refs/heads/"))
     + 			localname = tmp;
     + 
     + 		/* Both source and destination must be local branches. */
      
       ## upload-pack.c ##
      @@ upload-pack.c: static void send_unshallow(struct upload_pack_data *data)
     @@ upload-pack.c: static int mark_our_ref(const char *refname, const char *refname_
       
       static int check_ref(const char *refname_full, const struct object_id *oid,
      -		     int flag, void *cb_data)
     -+		     unsigned int flag, void *cb_data)
     ++		     unsigned int unused_flags, void *cb_data)
       {
       	const char *refname = strip_namespace(refname_full);
       
     @@ upload-pack.c: static void format_session_id(struct strbuf *buf, struct upload_p
       
       static int send_ref(const char *refname, const struct object_id *oid,
      -		    int flag, void *cb_data)
     -+		    unsigned int flag, void *cb_data)
     ++		    unsigned int unused_flags, void *cb_data)
       {
       	static const char *capabilities = "multi_ack thin-pack side-band"
       		" side-band-64k ofs-delta shallow deepen-since deepen-not"
     @@ upload-pack.c: static int send_ref(const char *refname, const struct object_id *
       
       static int find_symref(const char *refname, const struct object_id *oid,
      -		       int flag, void *cb_data)
     -+		       unsigned int flag, void *cb_data)
     ++		       unsigned int flags, void *cb_data)
       {
       	const char *symref_target;
       	struct string_list_item *item;
     + 
     +-	if ((flag & REF_ISSYMREF) == 0)
     ++	if ((flags & REF_ISSYMREF) == 0)
     + 		return 0;
     +-	symref_target = resolve_ref_unsafe(refname, 0, NULL, &flag);
     +-	if (!symref_target || (flag & REF_ISSYMREF) == 0)
     ++	symref_target = resolve_ref_unsafe(refname, 0, NULL, &flags);
     ++	if (!symref_target || (flags & REF_ISSYMREF) == 0)
     + 		die("'%s' is a symref but it is not?", refname);
     + 	item = string_list_append(cb_data, strip_namespace(refname));
     + 	item->util = xstrdup(strip_namespace(symref_target));
      
       ## walker.c ##
      @@ walker.c: static int interpret_target(struct walker *walker, char *target, struct object_i
     @@ walker.c: static int interpret_target(struct walker *walker, char *target, struc
       
       static int mark_complete(const char *path, const struct object_id *oid,
      -			 int flag, void *cb_data)
     -+			 unsigned int flag, void *cb_data)
     ++			 unsigned int unused_flags, void *cb_data)
       {
       	struct commit *commit = lookup_commit_reference_gently(the_repository,
       							       oid, 1);
     @@ worktree.c: int other_head_refs(each_ref_fn fn, void *cb_data)
       		struct worktree *wt = *p;
       		struct object_id oid;
      -		int flag;
     -+		unsigned int flag;
     ++		unsigned int flags;
       		int ignore_errno;
       
       		if (wt->is_current)
     +@@ worktree.c: int other_head_refs(each_ref_fn fn, void *cb_data)
     + 		strbuf_reset(&refname);
     + 		strbuf_worktree_ref(wt, &refname, "HEAD");
     + 		if (refs_resolve_ref_unsafe(get_main_ref_store(the_repository),
     +-					    refname.buf,
     +-					    RESOLVE_REF_READING,
     +-					    &oid, &flag, &ignore_errno))
     +-			ret = fn(refname.buf, &oid, flag, cb_data);
     ++					    refname.buf, RESOLVE_REF_READING,
     ++					    &oid, &flags, &ignore_errno))
     ++			ret = fn(refname.buf, &oid, flags, cb_data);
     + 		if (ret)
     + 			break;
     + 	}


 bisect.c                    |  4 +-
 builtin/bisect--helper.c    |  9 +++--
 builtin/branch.c            |  4 +-
 builtin/checkout.c          | 24 ++++++-----
 builtin/describe.c          |  3 +-
 builtin/fetch.c             | 10 ++---
 builtin/fsck.c              |  4 +-
 builtin/gc.c                |  5 +--
 builtin/name-rev.c          |  3 +-
 builtin/pack-objects.c      | 11 ++---
 builtin/rebase.c            | 10 +++--
 builtin/receive-pack.c      | 13 +++---
 builtin/reflog.c            |  5 ++-
 builtin/remote.c            | 23 ++++++-----
 builtin/repack.c            |  2 +-
 builtin/replace.c           |  2 +-
 builtin/rev-parse.c         |  6 ++-
 builtin/show-branch.c       | 12 +++---
 builtin/show-ref.c          |  4 +-
 builtin/stash.c             |  2 +-
 builtin/submodule--helper.c |  4 +-
 builtin/symbolic-ref.c      |  6 +--
 bundle.c                    |  8 ++--
 commit-graph.c              |  5 +--
 config.c                    |  2 +-
 delta-islands.c             |  2 +-
 fetch-pack.c                |  7 ++--
 help.c                      |  2 +-
 http-backend.c              |  6 +--
 log-tree.c                  |  4 +-
 ls-refs.c                   | 18 ++++-----
 midx.c                      |  7 ++--
 negotiator/default.c        |  2 +-
 negotiator/skipping.c       |  2 +-
 notes.c                     |  5 ++-
 object-name.c               |  2 +-
 reachable.c                 |  4 +-
 ref-filter.c                |  9 +++--
 refs.c                      | 80 ++++++++++++++++++-------------------
 refs.h                      | 47 ++++++++++------------
 refs/files-backend.c        | 57 +++++++++++++-------------
 remote.c                    | 31 +++++++-------
 replace-object.c            |  5 +--
 revision.c                  |  6 +--
 server-info.c               |  2 +-
 shallow.c                   |  4 +-
 submodule.c                 |  4 +-
 t/helper/test-ref-store.c   |  4 +-
 transport-helper.c          | 12 +++---
 transport.c                 | 10 ++---
 upload-pack.c               | 14 +++----
 walker.c                    |  2 +-
 worktree.c                  | 13 +++---
 53 files changed, 276 insertions(+), 266 deletions(-)

diff --git a/bisect.c b/bisect.c
index 888949fba6b..64807d2996b 100644
--- a/bisect.c
+++ b/bisect.c
@@ -441,7 +441,7 @@ void find_bisection(struct commit_list **commit_list, int *reaches,
 }
 
 static int register_ref(const char *refname, const struct object_id *oid,
-			int flags, void *cb_data)
+			unsigned int unused_flags, void *cb_data)
 {
 	struct strbuf good_prefix = STRBUF_INIT;
 	strbuf_addstr(&good_prefix, term_good);
@@ -1146,7 +1146,7 @@ int estimate_bisect_steps(int all)
 }
 
 static int mark_for_removal(const char *refname, const struct object_id *oid,
-			    int flag, void *cb_data)
+			    unsigned int unused_flags, void *cb_data)
 {
 	struct string_list *refs = cb_data;
 	char *ref = xstrfmt("refs/bisect%s", refname);
diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c
index 28a2e6a5750..ec460308bee 100644
--- a/builtin/bisect--helper.c
+++ b/builtin/bisect--helper.c
@@ -330,7 +330,7 @@ static int check_and_set_terms(struct bisect_terms *terms, const char *cmd)
 }
 
 static int mark_good(const char *refname, const struct object_id *oid,
-		     int flag, void *cb_data)
+		     unsigned int unused_flags, void *cb_data)
 {
 	int *m_good = (int *)cb_data;
 	*m_good = 0;
@@ -477,7 +477,7 @@ finish:
 }
 
 static int add_bisect_ref(const char *refname, const struct object_id *oid,
-			  int flags, void *cb)
+			  unsigned int unused_flags, void *cb)
 {
 	struct add_bisect_ref_data *data = cb;
 
@@ -617,7 +617,8 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, const char **a
 	int no_checkout = 0;
 	int first_parent_only = 0;
 	int i, has_double_dash = 0, must_write_terms = 0, bad_seen = 0;
-	int flags, pathspec_pos;
+	int pathspec_pos;
+	unsigned int unused_flags;
 	enum bisect_error res = BISECT_OK;
 	struct string_list revs = STRING_LIST_INIT_DUP;
 	struct string_list states = STRING_LIST_INIT_DUP;
@@ -707,7 +708,7 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, const char **a
 	/*
 	 * Verify HEAD
 	 */
-	head = resolve_ref_unsafe("HEAD", 0, &head_oid, &flags);
+	head = resolve_ref_unsafe("HEAD", 0, &head_oid, &unused_flags);
 	if (!head)
 		if (get_oid("HEAD", &head_oid))
 			return error(_("bad HEAD - I need a HEAD"));
diff --git a/builtin/branch.c b/builtin/branch.c
index 4ce2a247542..542eb2e4d50 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -234,7 +234,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
 
 	for (i = 0; i < argc; i++, strbuf_reset(&bname)) {
 		char *target = NULL;
-		int flags = 0;
+		unsigned int flags = 0;
 
 		strbuf_branchname(&bname, argv[i], allowed_interpret);
 		free(name);
@@ -469,7 +469,7 @@ static void print_ref_list(struct ref_filter *filter, struct ref_sorting *sortin
 
 static void print_current_branch_name(void)
 {
-	int flags;
+	unsigned int flags;
 	const char *refname = resolve_ref_unsafe("HEAD", 0, NULL, &flags);
 	const char *shortname;
 	if (!refname)
diff --git a/builtin/checkout.c b/builtin/checkout.c
index cc804ba8e1e..c964154fb4d 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -968,7 +968,8 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
 
 static int add_pending_uninteresting_ref(const char *refname,
 					 const struct object_id *oid,
-					 int flags, void *cb_data)
+					 unsigned int unused_flags,
+					 void *cb_data)
 {
 	add_pending_oid(cb_data, refname, oid, UNINTERESTING);
 	return 0;
@@ -1077,16 +1078,17 @@ static int switch_branches(const struct checkout_opts *opts,
 	int ret = 0;
 	struct branch_info old_branch_info = { 0 };
 	struct object_id rev;
-	int flag, writeout_error = 0;
+	int writeout_error = 0;
+	unsigned int flags;
 	int do_merge = 1;
 
 	trace2_cmd_mode("branch");
 
 	memset(&old_branch_info, 0, sizeof(old_branch_info));
-	old_branch_info.path = resolve_refdup("HEAD", 0, &rev, &flag);
+	old_branch_info.path = resolve_refdup("HEAD", 0, &rev, &flags);
 	if (old_branch_info.path)
 		old_branch_info.commit = lookup_commit_reference_gently(the_repository, &rev, 1);
-	if (!(flag & REF_ISSYMREF))
+	if (!(flags & REF_ISSYMREF))
 		FREE_AND_NULL(old_branch_info.path);
 
 	if (old_branch_info.path) {
@@ -1503,20 +1505,20 @@ static int checkout_branch(struct checkout_opts *opts,
 
 	if (new_branch_info->path && !opts->force_detach && !opts->new_branch &&
 	    !opts->ignore_other_worktrees) {
-		int flag;
-		char *head_ref = resolve_refdup("HEAD", 0, NULL, &flag);
-		if (head_ref &&
-		    (!(flag & REF_ISSYMREF) || strcmp(head_ref, new_branch_info->path)))
+		unsigned int flags;
+		char *head_ref = resolve_refdup("HEAD", 0, NULL, &flags);
+		if (head_ref && (!(flags & REF_ISSYMREF) ||
+				 strcmp(head_ref, new_branch_info->path)))
 			die_if_checked_out(new_branch_info->path, 1);
 		free(head_ref);
 	}
 
 	if (!new_branch_info->commit && opts->new_branch) {
 		struct object_id rev;
-		int flag;
+		unsigned int flags;
 
-		if (!read_ref_full("HEAD", 0, &rev, &flag) &&
-		    (flag & REF_ISSYMREF) && is_null_oid(&rev))
+		if (!read_ref_full("HEAD", 0, &rev, &flags) &&
+		    (flags & REF_ISSYMREF) && is_null_oid(&rev))
 			return switch_unborn_to_new_branch(opts);
 	}
 	return switch_branches(opts, new_branch_info);
diff --git a/builtin/describe.c b/builtin/describe.c
index 42159cd26bd..c7b24390ca6 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -140,7 +140,8 @@ static void add_to_known_names(const char *path,
 	}
 }
 
-static int get_name(const char *path, const struct object_id *oid, int flag, void *cb_data)
+static int get_name(const char *path, const struct object_id *oid,
+		    unsigned int unused_flags, void *cb_data)
 {
 	int is_tag = 0;
 	struct object_id peeled;
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 5f06b21f8e9..56b53ba3fff 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -323,9 +323,8 @@ static struct refname_hash_entry *refname_hash_add(struct hashmap *map,
 	return ent;
 }
 
-static int add_one_refname(const char *refname,
-			   const struct object_id *oid,
-			   int flag, void *cbdata)
+static int add_one_refname(const char *refname, const struct object_id *oid,
+			   unsigned int unused_flags, void *cbdata)
 {
 	struct hashmap *refname_map = cbdata;
 
@@ -1429,9 +1428,8 @@ static void set_option(struct transport *transport, const char *name, const char
 			name, transport->url);
 }
 
-
-static int add_oid(const char *refname, const struct object_id *oid, int flags,
-		   void *cb_data)
+static int add_oid(const char *refname, const struct object_id *oid,
+		   unsigned int unused_flags, void *cb_data)
 {
 	struct oid_array *oids = cb_data;
 
diff --git a/builtin/fsck.c b/builtin/fsck.c
index 9e54892311d..c52bd1843d1 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -502,7 +502,7 @@ static int fsck_handle_reflog_ent(struct object_id *ooid, struct object_id *noid
 }
 
 static int fsck_handle_reflog(const char *logname, const struct object_id *oid,
-			      int flag, void *cb_data)
+			      unsigned int unused_flags, void *cb_data)
 {
 	struct strbuf refname = STRBUF_INIT;
 
@@ -513,7 +513,7 @@ static int fsck_handle_reflog(const char *logname, const struct object_id *oid,
 }
 
 static int fsck_handle_ref(const char *refname, const struct object_id *oid,
-			   int flag, void *cb_data)
+			   unsigned int unused_flags, void *cb_data)
 {
 	struct object *obj;
 
diff --git a/builtin/gc.c b/builtin/gc.c
index 8e60ef1eaba..983196dae26 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -768,9 +768,8 @@ struct cg_auto_data {
 	int limit;
 };
 
-static int dfs_on_ref(const char *refname,
-		      const struct object_id *oid, int flags,
-		      void *cb_data)
+static int dfs_on_ref(const char *refname, const struct object_id *oid,
+		      unsigned int unused_flags, void *cb_data)
 {
 	struct cg_auto_data *data = (struct cg_auto_data *)cb_data;
 	int result = 0;
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index 27f60153a6c..3a89589645a 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -305,7 +305,8 @@ static int cmp_by_tag_and_age(const void *a_, const void *b_)
 	return a->taggerdate != b->taggerdate;
 }
 
-static int name_ref(const char *path, const struct object_id *oid, int flags, void *cb_data)
+static int name_ref(const char *path, const struct object_id *oid,
+		    unsigned int unused_flags, void *cb_data)
 {
 	struct object *o = parse_object(the_repository, oid);
 	struct name_ref_data *data = cb_data;
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index ba2006f2212..86bc62e68ed 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -758,8 +758,8 @@ static enum write_one_status write_one(struct hashfile *f,
 	return WRITE_ONE_WRITTEN;
 }
 
-static int mark_tagged(const char *path, const struct object_id *oid, int flag,
-		       void *cb_data)
+static int mark_tagged(const char *path, const struct object_id *oid,
+		       unsigned int unused_flags, void *cb_data)
 {
 	struct object_id peeled;
 	struct object_entry *entry = packlist_find(&to_pack, oid);
@@ -3012,7 +3012,8 @@ static void add_tag_chain(const struct object_id *oid)
 	}
 }
 
-static int add_ref_tag(const char *tag, const struct object_id *oid, int flag, void *cb_data)
+static int add_ref_tag(const char *tag, const struct object_id *oid,
+		       unsigned int unused_flags, void *cb_data)
 {
 	struct object_id peeled;
 
@@ -3684,8 +3685,8 @@ static void record_recent_commit(struct commit *commit, void *data)
 }
 
 static int mark_bitmap_preferred_tip(const char *refname,
-				     const struct object_id *oid, int flags,
-				     void *_data)
+				     const struct object_id *oid,
+				     unsigned int flags, void *_data)
 {
 	struct object_id peeled;
 	struct object *object;
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 36490d06c8a..01021d6e1a8 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -999,7 +999,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 {
 	struct rebase_options options = REBASE_OPTIONS_INIT;
 	const char *branch_name;
-	int ret, flags, total_argc, in_progress = 0;
+	int ret, total_argc, in_progress = 0;
 	int keep_base = 0;
 	int ok_to_skip_pre_rebase = 0;
 	struct strbuf msg = STRBUF_INIT;
@@ -1611,6 +1611,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 		}
 	} else if (argc == 0) {
 		/* Do not need to switch branches, we are already on it. */
+		unsigned int flags;
 		options.head_name =
 			xstrdup_or_null(resolve_ref_unsafe("HEAD", 0, NULL,
 					 &flags));
@@ -1668,7 +1669,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 	if (can_fast_forward(options.onto, options.upstream, options.restrict_revision,
 		    &options.orig_head, &merge_base) &&
 	    allow_preemptive_ff) {
-		int flag;
+		unsigned int unused_flags;
 
 		if (!(options.flags & REBASE_FORCE)) {
 			/* Lazily switch to the target branch if needed... */
@@ -1693,7 +1694,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 			if (!(options.flags & REBASE_NO_QUIET))
 				; /* be quiet */
 			else if (!strcmp(branch_name, "HEAD") &&
-				 resolve_ref_unsafe("HEAD", 0, NULL, &flag))
+				 resolve_ref_unsafe("HEAD", 0, NULL,
+						    &unused_flags))
 				puts(_("HEAD is up to date."));
 			else
 				printf(_("Current branch %s is up to date.\n"),
@@ -1703,7 +1705,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 		} else if (!(options.flags & REBASE_NO_QUIET))
 			; /* be quiet */
 		else if (!strcmp(branch_name, "HEAD") &&
-			 resolve_ref_unsafe("HEAD", 0, NULL, &flag))
+			 resolve_ref_unsafe("HEAD", 0, NULL, &unused_flags))
 			puts(_("HEAD is up to date, rebase forced."));
 		else
 			printf(_("Current branch %s is up to date, rebase "
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 9f4a0b816cf..aa000ada17f 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -291,7 +291,7 @@ static void show_ref(const char *path, const struct object_id *oid)
 }
 
 static int show_ref_cb(const char *path_full, const struct object_id *oid,
-		       int flag, void *data)
+		       unsigned int unused_flags, void *data)
 {
 	struct oidset *seen = data;
 	const char *path = strip_namespace(path_full);
@@ -1655,12 +1655,13 @@ static void run_update_post_hook(struct command *commands)
 
 static void check_aliased_update_internal(struct command *cmd,
 					  struct string_list *list,
-					  const char *dst_name, int flag)
+					  const char *dst_name,
+					  unsigned int flags)
 {
 	struct string_list_item *item;
 	struct command *dst_cmd;
 
-	if (!(flag & REF_ISSYMREF))
+	if (!(flags & REF_ISSYMREF))
 		return;
 
 	if (!dst_name) {
@@ -1701,11 +1702,11 @@ static void check_aliased_update(struct command *cmd, struct string_list *list)
 {
 	struct strbuf buf = STRBUF_INIT;
 	const char *dst_name;
-	int flag;
+	unsigned int flags;
 
 	strbuf_addf(&buf, "%s%s", get_git_namespace(), cmd->ref_name);
-	dst_name = resolve_ref_unsafe(buf.buf, 0, NULL, &flag);
-	check_aliased_update_internal(cmd, list, dst_name, flag);
+	dst_name = resolve_ref_unsafe(buf.buf, 0, NULL, &flags);
+	check_aliased_update_internal(cmd, list, dst_name, flags);
 	strbuf_release(&buf);
 }
 
diff --git a/builtin/reflog.c b/builtin/reflog.c
index a4b1dd27e13..ddb5b6fb788 100644
--- a/builtin/reflog.c
+++ b/builtin/reflog.c
@@ -343,7 +343,7 @@ static int should_expire_reflog_ent_verbose(struct object_id *ooid,
 }
 
 static int push_tip_to_list(const char *refname, const struct object_id *oid,
-			    int flags, void *cb_data)
+			    unsigned int flags, void *cb_data)
 {
 	struct commit_list **list = cb_data;
 	struct commit *tip_commit;
@@ -424,7 +424,8 @@ static void reflog_expiry_cleanup(void *cb_data)
 	}
 }
 
-static int collect_reflog(const char *ref, const struct object_id *oid, int unused, void *cb_data)
+static int collect_reflog(const char *ref, const struct object_id *oid,
+			  unsigned int unused_flags, void *cb_data)
 {
 	struct worktree_reflogs *cb = cb_data;
 	struct worktree *worktree = cb->worktree;
diff --git a/builtin/remote.c b/builtin/remote.c
index 299c466116d..6e509e276cd 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -533,7 +533,8 @@ struct branches_for_remote {
 };
 
 static int add_branch_for_removal(const char *refname,
-	const struct object_id *oid, int flags, void *cb_data)
+				  const struct object_id *oid,
+				  unsigned int unused_flags, void *cb_data)
 {
 	struct branches_for_remote *branches = cb_data;
 	struct refspec_item refspec;
@@ -574,20 +575,21 @@ struct rename_info {
 };
 
 static int read_remote_branches(const char *refname,
-	const struct object_id *oid, int flags, void *cb_data)
+				const struct object_id *oid,
+				unsigned int unused_flags, void *cb_data)
 {
 	struct rename_info *rename = cb_data;
 	struct strbuf buf = STRBUF_INIT;
 	struct string_list_item *item;
-	int flag;
 	const char *symref;
 
 	strbuf_addf(&buf, "refs/remotes/%s/", rename->old_name);
 	if (starts_with(refname, buf.buf)) {
+		unsigned int flags;
 		item = string_list_append(rename->remote_branches, refname);
-		symref = resolve_ref_unsafe(refname, RESOLVE_REF_READING,
-					    NULL, &flag);
-		if (symref && (flag & REF_ISSYMREF))
+		symref = resolve_ref_unsafe(refname, RESOLVE_REF_READING, NULL,
+					    &flags);
+		if (symref && (flags & REF_ISSYMREF))
 			item->util = xstrdup(symref);
 		else
 			item->util = NULL;
@@ -766,10 +768,10 @@ static int mv(int argc, const char **argv)
 	for_each_ref(read_remote_branches, &rename);
 	for (i = 0; i < remote_branches.nr; i++) {
 		struct string_list_item *item = remote_branches.items + i;
-		int flag = 0;
+		unsigned int flags = 0;
 
-		read_ref_full(item->string, RESOLVE_REF_READING, NULL, &flag);
-		if (!(flag & REF_ISSYMREF))
+		read_ref_full(item->string, RESOLVE_REF_READING, NULL, &flags);
+		if (!(flags & REF_ISSYMREF))
 			continue;
 		if (delete_ref(NULL, item->string, NULL, REF_NO_DEREF))
 			die(_("deleting '%s' failed"), item->string);
@@ -923,7 +925,8 @@ static void free_remote_ref_states(struct ref_states *states)
 }
 
 static int append_ref_to_tracked_list(const char *refname,
-	const struct object_id *oid, int flags, void *cb_data)
+				      const struct object_id *oid,
+				      unsigned int flags, void *cb_data)
 {
 	struct ref_states *states = cb_data;
 	struct refspec_item refspec;
diff --git a/builtin/repack.c b/builtin/repack.c
index da1e364a756..f995f829970 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -465,7 +465,7 @@ struct midx_snapshot_ref_data {
 
 static int midx_snapshot_ref_one(const char *refname,
 				 const struct object_id *oid,
-				 int flag, void *_data)
+				 unsigned int unused_flag, void *_data)
 {
 	struct midx_snapshot_ref_data *data = _data;
 	struct object_id peeled;
diff --git a/builtin/replace.c b/builtin/replace.c
index 6ff1734d587..af35b9f27ad 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -41,7 +41,7 @@ struct show_data {
 
 static int show_reference(struct repository *r, const char *refname,
 			  const struct object_id *oid,
-			  int flag, void *cb_data)
+			  unsigned int unused_flags, void *cb_data)
 {
 	struct show_data *data = cb_data;
 
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 8480a59f573..46f09c25db6 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -195,7 +195,8 @@ static int show_default(void)
 	return 0;
 }
 
-static int show_reference(const char *refname, const struct object_id *oid, int flag, void *cb_data)
+static int show_reference(const char *refname, const struct object_id *oid,
+			  unsigned int unused_flags, void *cb_data)
 {
 	if (ref_excluded(ref_excludes, refname))
 		return 0;
@@ -203,7 +204,8 @@ static int show_reference(const char *refname, const struct object_id *oid, int
 	return 0;
 }
 
-static int anti_reference(const char *refname, const struct object_id *oid, int flag, void *cb_data)
+static int anti_reference(const char *refname, const struct object_id *oid,
+			  unsigned int unused_flags, void *cb_data)
 {
 	show_rev(REVERSED, oid, refname);
 	return 0;
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index e12c5e80e3e..8c392afcd74 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -403,7 +403,7 @@ static int append_ref(const char *refname, const struct object_id *oid,
 }
 
 static int append_head_ref(const char *refname, const struct object_id *oid,
-			   int flag, void *cb_data)
+			   unsigned int unused_flags, void *cb_data)
 {
 	struct object_id tmp;
 	int ofs = 11;
@@ -418,7 +418,7 @@ static int append_head_ref(const char *refname, const struct object_id *oid,
 }
 
 static int append_remote_ref(const char *refname, const struct object_id *oid,
-			     int flag, void *cb_data)
+			     unsigned int unused_flags, void *cb_data)
 {
 	struct object_id tmp;
 	int ofs = 13;
@@ -433,7 +433,7 @@ static int append_remote_ref(const char *refname, const struct object_id *oid,
 }
 
 static int append_tag_ref(const char *refname, const struct object_id *oid,
-			  int flag, void *cb_data)
+			  int unused_flags, void *cb_data)
 {
 	if (!starts_with(refname, "refs/tags/"))
 		return 0;
@@ -444,7 +444,7 @@ static const char *match_ref_pattern = NULL;
 static int match_ref_slash = 0;
 
 static int append_matching_ref(const char *refname, const struct object_id *oid,
-			       int flag, void *cb_data)
+			       unsigned int flags, void *cb_data)
 {
 	/* we want to allow pattern hold/<asterisk> to show all
 	 * branches under refs/heads/hold/, and v0.99.9? to show
@@ -460,9 +460,9 @@ static int append_matching_ref(const char *refname, const struct object_id *oid,
 	if (wildmatch(match_ref_pattern, tail, 0))
 		return 0;
 	if (starts_with(refname, "refs/heads/"))
-		return append_head_ref(refname, oid, flag, cb_data);
+		return append_head_ref(refname, oid, flags, cb_data);
 	if (starts_with(refname, "refs/tags/"))
-		return append_tag_ref(refname, oid, flag, cb_data);
+		return append_tag_ref(refname, oid, flags, cb_data);
 	return append_ref(refname, oid, 0);
 }
 
diff --git a/builtin/show-ref.c b/builtin/show-ref.c
index 7f8a5332f83..ff017b1202a 100644
--- a/builtin/show-ref.c
+++ b/builtin/show-ref.c
@@ -47,7 +47,7 @@ static void show_one(const char *refname, const struct object_id *oid)
 }
 
 static int show_ref(const char *refname, const struct object_id *oid,
-		    int flag, void *cbdata)
+		    unsigned int flag, void *cbdata)
 {
 	if (show_head && !strcmp(refname, "HEAD"))
 		goto match;
@@ -86,7 +86,7 @@ match:
 }
 
 static int add_existing(const char *refname, const struct object_id *oid,
-			int flag, void *cbdata)
+			unsigned int unused_flags, void *cbdata)
 {
 	struct string_list *list = (struct string_list *)cbdata;
 	string_list_insert(list, refname);
diff --git a/builtin/stash.c b/builtin/stash.c
index 86cd0b456e7..c02e014acb7 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -1296,7 +1296,7 @@ static int do_create_stash(const struct pathspec *ps, struct strbuf *stash_msg_b
 			   int quiet)
 {
 	int ret = 0;
-	int flags = 0;
+	unsigned int flags = 0;
 	int untracked_commit_option = 0;
 	const char *head_short_sha1 = NULL;
 	const char *branch_ref = NULL;
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index c5d3fc3817f..0a2755c8eee 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -738,8 +738,8 @@ static void print_status(unsigned int flags, char state, const char *path,
 }
 
 static int handle_submodule_head_ref(const char *refname,
-				     const struct object_id *oid, int flags,
-				     void *cb_data)
+				     const struct object_id *oid,
+				     unsigned int unused_flags, void *cb_data)
 {
 	struct object_id *output = cb_data;
 	if (oid)
diff --git a/builtin/symbolic-ref.c b/builtin/symbolic-ref.c
index e547a08d6c7..478ae36b4da 100644
--- a/builtin/symbolic-ref.c
+++ b/builtin/symbolic-ref.c
@@ -12,12 +12,12 @@ static const char * const git_symbolic_ref_usage[] = {
 
 static int check_symref(const char *HEAD, int quiet, int shorten, int print)
 {
-	int flag;
-	const char *refname = resolve_ref_unsafe(HEAD, 0, NULL, &flag);
+	unsigned int flags;
+	const char *refname = resolve_ref_unsafe(HEAD, 0, NULL, &flags);
 
 	if (!refname)
 		die("No such ref: %s", HEAD);
-	else if (!(flag & REF_ISSYMREF)) {
+	else if (!(flags & REF_ISSYMREF)) {
 		if (!quiet)
 			die("ref %s is not a symbolic ref", HEAD);
 		else
diff --git a/bundle.c b/bundle.c
index a0bb687b0f4..a6658dab789 100644
--- a/bundle.c
+++ b/bundle.c
@@ -371,15 +371,15 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
 		struct object_id oid;
 		char *ref;
 		const char *display_ref;
-		int flag;
+		unsigned int flags;
 
 		if (e->item->flags & UNINTERESTING)
 			continue;
 		if (dwim_ref(e->name, strlen(e->name), &oid, &ref, 0) != 1)
 			goto skip_write_ref;
-		if (read_ref_full(e->name, RESOLVE_REF_READING, &oid, &flag))
-			flag = 0;
-		display_ref = (flag & REF_ISSYMREF) ? e->name : ref;
+		if (read_ref_full(e->name, RESOLVE_REF_READING, &oid, &flags))
+			flags = 0;
+		display_ref = (flags & REF_ISSYMREF) ? e->name : ref;
 
 		if (e->item->type == OBJ_TAG &&
 				!is_tag_in_date_range(e->item, revs)) {
diff --git a/commit-graph.c b/commit-graph.c
index 265c010122e..1a7d1bb154d 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -1636,9 +1636,8 @@ struct refs_cb_data {
 	struct progress *progress;
 };
 
-static int add_ref_to_set(const char *refname,
-			  const struct object_id *oid,
-			  int flags, void *cb_data)
+static int add_ref_to_set(const char *refname, const struct object_id *oid,
+			  unsigned int flags, void *cb_data)
 {
 	struct object_id peeled;
 	struct refs_cb_data *data = (struct refs_cb_data *)cb_data;
diff --git a/config.c b/config.c
index 2bffa8d4a01..a4f9cf339f7 100644
--- a/config.c
+++ b/config.c
@@ -276,7 +276,7 @@ done:
 
 static int include_by_branch(const char *cond, size_t cond_len)
 {
-	int flags;
+	unsigned int flags;
 	int ret;
 	struct strbuf pattern = STRBUF_INIT;
 	const char *refname = !the_repository->gitdir ?
diff --git a/delta-islands.c b/delta-islands.c
index aa98b2e5414..b53b8dc7f4a 100644
--- a/delta-islands.c
+++ b/delta-islands.c
@@ -365,7 +365,7 @@ static void add_ref_to_island(const char *island_name, const struct object_id *o
 }
 
 static int find_island_for_ref(const char *refname, const struct object_id *oid,
-			       int flags, void *data)
+			       unsigned int unused_flags, void *data)
 {
 	/*
 	 * We should advertise 'ARRAY_SIZE(matches) - 2' as the max,
diff --git a/fetch-pack.c b/fetch-pack.c
index dd6ec449f2d..1f3dce5860f 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -164,8 +164,9 @@ static int rev_list_insert_ref(struct fetch_negotiator *negotiator,
 	return 0;
 }
 
-static int rev_list_insert_ref_oid(const char *refname, const struct object_id *oid,
-				   int flag, void *cb_data)
+static int rev_list_insert_ref_oid(const char *refname,
+				   const struct object_id *oid,
+				   unsigned int unused_flags, void *cb_data)
 {
 	return rev_list_insert_ref(cb_data, oid);
 }
@@ -548,7 +549,7 @@ static int mark_complete(const struct object_id *oid)
 }
 
 static int mark_complete_oid(const char *refname, const struct object_id *oid,
-			     int flag, void *cb_data)
+			     unsigned int unused_flags, void *cb_data)
 {
 	return mark_complete(oid);
 }
diff --git a/help.c b/help.c
index 71444906ddf..38e3def7cb6 100644
--- a/help.c
+++ b/help.c
@@ -728,7 +728,7 @@ struct similar_ref_cb {
 };
 
 static int append_similar_ref(const char *refname, const struct object_id *oid,
-			      int flags, void *cb_data)
+			      unsigned int flags, void *cb_data)
 {
 	struct similar_ref_cb *cb = (struct similar_ref_cb *)(cb_data);
 	char *branch = strrchr(refname, '/') + 1;
diff --git a/http-backend.c b/http-backend.c
index 807fb8839e7..351a124333b 100644
--- a/http-backend.c
+++ b/http-backend.c
@@ -504,7 +504,7 @@ static void run_service(const char **argv, int buffer_input)
 }
 
 static int show_text_ref(const char *name, const struct object_id *oid,
-			 int flag, void *cb_data)
+			 unsigned int flag, void *cb_data)
 {
 	const char *name_nons = strip_namespace(name);
 	struct strbuf *buf = cb_data;
@@ -559,11 +559,11 @@ static void get_info_refs(struct strbuf *hdr, char *arg)
 }
 
 static int show_head_ref(const char *refname, const struct object_id *oid,
-			 int flag, void *cb_data)
+			 unsigned int flags, void *cb_data)
 {
 	struct strbuf *buf = cb_data;
 
-	if (flag & REF_ISSYMREF) {
+	if (flags & REF_ISSYMREF) {
 		const char *target = resolve_ref_unsafe(refname,
 							RESOLVE_REF_READING,
 							NULL, NULL);
diff --git a/log-tree.c b/log-tree.c
index d3e7a40b648..4d2b74cf754 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -131,7 +131,7 @@ static int ref_filter_match(const char *refname,
 }
 
 static int add_ref_decoration(const char *refname, const struct object_id *oid,
-			      int flags, void *cb_data)
+			      unsigned int unused_flags, void *cb_data)
 {
 	struct object *obj;
 	enum object_type objtype;
@@ -241,7 +241,7 @@ static const struct name_decoration *current_pointed_by_HEAD(const struct name_d
 {
 	const struct name_decoration *list, *head = NULL;
 	const char *branch_name = NULL;
-	int rru_flags;
+	unsigned int rru_flags;
 
 	/* First find HEAD */
 	for (list = decoration; list; list = list->next)
diff --git a/ls-refs.c b/ls-refs.c
index 54078323dcb..3abdccb9394 100644
--- a/ls-refs.c
+++ b/ls-refs.c
@@ -76,7 +76,7 @@ struct ls_refs_data {
 };
 
 static int send_ref(const char *refname, const struct object_id *oid,
-		    int flag, void *cb_data)
+		    unsigned int flags, void *cb_data)
 {
 	struct ls_refs_data *data = cb_data;
 	const char *refname_nons = strip_namespace(refname);
@@ -93,11 +93,10 @@ static int send_ref(const char *refname, const struct object_id *oid,
 		strbuf_addf(&data->buf, "%s %s", oid_to_hex(oid), refname_nons);
 	else
 		strbuf_addf(&data->buf, "unborn %s", refname_nons);
-	if (data->symrefs && flag & REF_ISSYMREF) {
+	if (data->symrefs && flags & REF_ISSYMREF) {
 		struct object_id unused;
-		const char *symref_target = resolve_ref_unsafe(refname, 0,
-							       &unused,
-							       &flag);
+		const char *symref_target =
+			resolve_ref_unsafe(refname, 0, &unused, &flags);
 
 		if (!symref_target)
 			die("'%s' is a symref but it is not?", refname);
@@ -122,16 +121,17 @@ static void send_possibly_unborn_head(struct ls_refs_data *data)
 {
 	struct strbuf namespaced = STRBUF_INIT;
 	struct object_id oid;
-	int flag;
+	unsigned int flags;
 	int oid_is_null;
 
 	strbuf_addf(&namespaced, "%sHEAD", get_git_namespace());
-	if (!resolve_ref_unsafe(namespaced.buf, 0, &oid, &flag))
+	if (!resolve_ref_unsafe(namespaced.buf, 0, &oid, &flags))
 		return; /* bad ref */
 	oid_is_null = is_null_oid(&oid);
 	if (!oid_is_null ||
-	    (data->unborn && data->symrefs && (flag & REF_ISSYMREF)))
-		send_ref(namespaced.buf, oid_is_null ? NULL : &oid, flag, data);
+	    (data->unborn && data->symrefs && (flags & REF_ISSYMREF)))
+		send_ref(namespaced.buf, oid_is_null ? NULL : &oid, flags,
+			 data);
 	strbuf_release(&namespaced);
 }
 
diff --git a/midx.c b/midx.c
index 837b46b2af5..003bcce7633 100644
--- a/midx.c
+++ b/midx.c
@@ -922,14 +922,13 @@ static void prepare_midx_packing_data(struct packing_data *pdata,
 	}
 }
 
-static int add_ref_to_pending(const char *refname,
-			      const struct object_id *oid,
-			      int flag, void *cb_data)
+static int add_ref_to_pending(const char *refname, const struct object_id *oid,
+			      unsigned int flags, void *cb_data)
 {
 	struct rev_info *revs = (struct rev_info*)cb_data;
 	struct object *object;
 
-	if ((flag & REF_ISSYMREF) && (flag & REF_ISBROKEN)) {
+	if ((flags & REF_ISSYMREF) && (flags & REF_ISBROKEN)) {
 		warning("symbolic ref is dangling: %s", refname);
 		return 0;
 	}
diff --git a/negotiator/default.c b/negotiator/default.c
index 434189ae5dc..7ddc40e480b 100644
--- a/negotiator/default.c
+++ b/negotiator/default.c
@@ -36,7 +36,7 @@ static void rev_list_push(struct negotiation_state *ns,
 }
 
 static int clear_marks(const char *refname, const struct object_id *oid,
-		       int flag, void *cb_data)
+		       unsigned int unused_flags, void *cb_data)
 {
 	struct object *o = deref_tag(the_repository, parse_object(the_repository, oid), refname, 0);
 
diff --git a/negotiator/skipping.c b/negotiator/skipping.c
index 1236e792248..6ac6310b247 100644
--- a/negotiator/skipping.c
+++ b/negotiator/skipping.c
@@ -72,7 +72,7 @@ static struct entry *rev_list_push(struct data *data, struct commit *commit, int
 }
 
 static int clear_marks(const char *refname, const struct object_id *oid,
-		       int flag, void *cb_data)
+		       unsigned int unused_flags, void *cb_data)
 {
 	struct object *o = deref_tag(the_repository, parse_object(the_repository, oid), refname, 0);
 
diff --git a/notes.c b/notes.c
index f87dac40684..df41b004f49 100644
--- a/notes.c
+++ b/notes.c
@@ -924,8 +924,9 @@ out:
 	return ret;
 }
 
-static int string_list_add_one_ref(const char *refname, const struct object_id *oid,
-				   int flag, void *cb)
+static int string_list_add_one_ref(const char *refname,
+				   const struct object_id *oid,
+				   unsigned int unused_flags, void *cb)
 {
 	struct string_list *refs = cb;
 	if (!unsorted_string_list_has_string(refs, refname))
diff --git a/object-name.c b/object-name.c
index fdff4601b2c..d89b4ed9f3e 100644
--- a/object-name.c
+++ b/object-name.c
@@ -1208,7 +1208,7 @@ struct handle_one_ref_cb {
 };
 
 static int handle_one_ref(const char *path, const struct object_id *oid,
-			  int flag, void *cb_data)
+			  unsigned int unused_flags, void *cb_data)
 {
 	struct handle_one_ref_cb *cb = cb_data;
 	struct commit_list **list = cb->list;
diff --git a/reachable.c b/reachable.c
index 84e3d0d75ed..fc04a57cbf6 100644
--- a/reachable.c
+++ b/reachable.c
@@ -27,12 +27,12 @@ static void update_progress(struct connectivity_progress *cp)
 }
 
 static int add_one_ref(const char *path, const struct object_id *oid,
-		       int flag, void *cb_data)
+		       unsigned int flags, void *cb_data)
 {
 	struct rev_info *revs = (struct rev_info *)cb_data;
 	struct object *object;
 
-	if ((flag & REF_ISSYMREF) && (flag & REF_ISBROKEN)) {
+	if ((flags & REF_ISSYMREF) && (flags & REF_ISBROKEN)) {
 		warning("symbolic ref is dangling: %s", path);
 		return 0;
 	}
diff --git a/ref-filter.c b/ref-filter.c
index f7a2f17bfd9..addb7a237a4 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -2233,7 +2233,8 @@ struct ref_filter_cbdata {
  * A call-back given to for_each_ref().  Filter refs and keep them for
  * later object processing.
  */
-static int ref_filter_handler(const char *refname, const struct object_id *oid, int flag, void *cb_data)
+static int ref_filter_handler(const char *refname, const struct object_id *oid,
+			      unsigned int flags, void *cb_data)
 {
 	struct ref_filter_cbdata *ref_cbdata = cb_data;
 	struct ref_filter *filter = ref_cbdata->filter;
@@ -2241,12 +2242,12 @@ static int ref_filter_handler(const char *refname, const struct object_id *oid,
 	struct commit *commit = NULL;
 	unsigned int kind;
 
-	if (flag & REF_BAD_NAME) {
+	if (flags & REF_BAD_NAME) {
 		warning(_("ignoring ref with broken name %s"), refname);
 		return 0;
 	}
 
-	if (flag & REF_ISBROKEN) {
+	if (flags & REF_ISBROKEN) {
 		warning(_("ignoring broken ref %s"), refname);
 		return 0;
 	}
@@ -2289,7 +2290,7 @@ static int ref_filter_handler(const char *refname, const struct object_id *oid,
 	 */
 	ref = ref_array_push(ref_cbdata->array, refname, oid);
 	ref->commit = commit;
-	ref->flag = flag;
+	ref->flag = flags;
 	ref->kind = kind;
 
 	return 0;
diff --git a/refs.c b/refs.c
index addb26293b4..3178a0cbdef 100644
--- a/refs.c
+++ b/refs.c
@@ -74,7 +74,7 @@ static unsigned char refname_disposition[256] = {
  * as an error, try to come up with a usable replacement for the input
  * refname in it.
  */
-static int check_refname_component(const char *refname, int *flags,
+static int check_refname_component(const char *refname, unsigned int *flags,
 				   struct strbuf *sanitized)
 {
 	const char *cp;
@@ -158,7 +158,7 @@ out:
 	return cp - refname;
 }
 
-static int check_or_sanitize_refname(const char *refname, int flags,
+static int check_or_sanitize_refname(const char *refname, unsigned int flags,
 				     struct strbuf *sanitized)
 {
 	int component_len, component_count = 0;
@@ -202,7 +202,7 @@ static int check_or_sanitize_refname(const char *refname, int flags,
 	return 0;
 }
 
-int check_refname_format(const char *refname, int flags)
+int check_refname_format(const char *refname, unsigned int flags)
 {
 	return check_or_sanitize_refname(refname, flags, NULL);
 }
@@ -264,9 +264,9 @@ int ref_resolves_to_object(const char *refname,
 	return 1;
 }
 
-char *refs_resolve_refdup(struct ref_store *refs,
-			  const char *refname, int resolve_flags,
-			  struct object_id *oid, int *flags)
+char *refs_resolve_refdup(struct ref_store *refs, const char *refname,
+			  unsigned int resolve_flags, struct object_id *oid,
+			  unsigned int *flags)
 {
 	const char *result;
 	int ignore_errno;
@@ -276,8 +276,8 @@ char *refs_resolve_refdup(struct ref_store *refs,
 	return xstrdup_or_null(result);
 }
 
-char *resolve_refdup(const char *refname, int resolve_flags,
-		     struct object_id *oid, int *flags)
+char *resolve_refdup(const char *refname, unsigned int resolve_flags,
+		     struct object_id *oid, unsigned int *flags)
 {
 	return refs_resolve_refdup(get_main_ref_store(the_repository),
 				   refname, resolve_flags,
@@ -292,7 +292,8 @@ struct ref_filter {
 	void *cb_data;
 };
 
-int read_ref_full(const char *refname, int resolve_flags, struct object_id *oid, int *flags)
+int read_ref_full(const char *refname, unsigned int resolve_flags,
+		  struct object_id *oid, unsigned int *flags)
 {
 	int ignore_errno;
 	struct ref_store *refs = get_main_ref_store(the_repository);
@@ -321,7 +322,7 @@ int ref_exists(const char *refname)
 }
 
 static int filter_refs(const char *refname, const struct object_id *oid,
-			   int flags, void *data)
+		       unsigned int flags, void *data)
 {
 	struct ref_filter *filter = (struct ref_filter *)data;
 
@@ -360,8 +361,9 @@ struct warn_if_dangling_data {
 	const char *msg_fmt;
 };
 
-static int warn_if_dangling_symref(const char *refname, const struct object_id *oid,
-				   int flags, void *cb_data)
+static int warn_if_dangling_symref(const char *refname,
+				   const struct object_id *oid,
+				   unsigned int flags, void *cb_data)
 {
 	struct warn_if_dangling_data *d = cb_data;
 	const char *resolves_to;
@@ -439,11 +441,11 @@ int head_ref_namespaced(each_ref_fn fn, void *cb_data)
 	struct strbuf buf = STRBUF_INIT;
 	int ret = 0;
 	struct object_id oid;
-	int flag;
+	unsigned int flags;
 
 	strbuf_addf(&buf, "%sHEAD", get_git_namespace());
-	if (!read_ref_full(buf.buf, RESOLVE_REF_READING, &oid, &flag))
-		ret = fn(buf.buf, &oid, flag, cb_data);
+	if (!read_ref_full(buf.buf, RESOLVE_REF_READING, &oid, &flags))
+		ret = fn(buf.buf, &oid, flags, cb_data);
 	strbuf_release(&buf);
 
 	return ret;
@@ -654,7 +656,7 @@ int expand_ref(struct repository *repo, const char *str, int len,
 	for (p = ref_rev_parse_rules; *p; p++) {
 		struct object_id oid_from_ref;
 		struct object_id *this_result;
-		int flag;
+		unsigned int flags;
 		struct ref_store *refs = get_main_ref_store(repo);
 		int ignore_errno;
 
@@ -662,17 +664,17 @@ int expand_ref(struct repository *repo, const char *str, int len,
 		strbuf_reset(&fullref);
 		strbuf_addf(&fullref, *p, len, str);
 		r = refs_resolve_ref_unsafe(refs, fullref.buf,
-					    RESOLVE_REF_READING,
-					    this_result, &flag,
-					    &ignore_errno);
+					    RESOLVE_REF_READING, this_result,
+					    &flags, &ignore_errno);
 		if (r) {
 			if (!refs_found++)
 				*ref = xstrdup(r);
 			if (!warn_ambiguous_refs)
 				break;
-		} else if ((flag & REF_ISSYMREF) && strcmp(fullref.buf, "HEAD")) {
+		} else if ((flags & REF_ISSYMREF) &&
+			   strcmp(fullref.buf, "HEAD")) {
 			warning(_("ignoring dangling symref %s"), fullref.buf);
-		} else if ((flag & REF_ISBROKEN) && strchr(fullref.buf, '/')) {
+		} else if ((flags & REF_ISBROKEN) && strchr(fullref.buf, '/')) {
 			warning(_("ignoring broken ref %s"), fullref.buf);
 		}
 	}
@@ -1389,12 +1391,12 @@ const char *find_descendant_ref(const char *dirname,
 int refs_head_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
 {
 	struct object_id oid;
-	int flag;
+	unsigned int flags;
 	int ignore_errno;
 
-	if (refs_resolve_ref_unsafe(refs, "HEAD", RESOLVE_REF_READING,
-				    &oid, &flag, &ignore_errno))
-		return fn("HEAD", &oid, flag, cb_data);
+	if (refs_resolve_ref_unsafe(refs, "HEAD", RESOLVE_REF_READING, &oid,
+				    &flags, &ignore_errno))
+		return fn("HEAD", &oid, flags, cb_data);
 
 	return 0;
 }
@@ -1467,11 +1469,9 @@ struct do_for_each_ref_help {
 	void *cb_data;
 };
 
-static int do_for_each_ref_helper(struct repository *r,
-				  const char *refname,
+static int do_for_each_ref_helper(struct repository *r, const char *refname,
 				  const struct object_id *oid,
-				  int flags,
-				  void *cb_data)
+				  unsigned int flags, void *cb_data)
 {
 	struct do_for_each_ref_help *hp = cb_data;
 
@@ -1678,15 +1678,14 @@ int refs_read_raw_ref(struct ref_store *ref_store, const char *refname,
 					   type, failure_errno);
 }
 
-const char *refs_resolve_ref_unsafe(struct ref_store *refs,
-				    const char *refname,
-				    int resolve_flags,
-				    struct object_id *oid,
-				    int *flags, int *failure_errno)
+const char *refs_resolve_ref_unsafe(struct ref_store *refs, const char *refname,
+				    unsigned int resolve_flags,
+				    struct object_id *oid, unsigned int *flags,
+				    int *failure_errno)
 {
 	static struct strbuf sb_refname = STRBUF_INIT;
 	struct object_id unused_oid;
-	int unused_flags;
+	unsigned int unused_flags;
 	int symref_count;
 
 	assert(failure_errno);
@@ -1781,8 +1780,8 @@ int refs_init_db(struct strbuf *err)
 	return refs->be->init_db(refs, err);
 }
 
-const char *resolve_ref_unsafe(const char *refname, int resolve_flags,
-			       struct object_id *oid, int *flags)
+const char *resolve_ref_unsafe(const char *refname, unsigned int resolve_flags,
+			       struct object_id *oid, unsigned int *flags)
 {
 	int ignore_errno;
 
@@ -1794,7 +1793,7 @@ int resolve_gitlink_ref(const char *submodule, const char *refname,
 			struct object_id *oid)
 {
 	struct ref_store *refs;
-	int flags;
+	unsigned int unused_flags;
 	int ignore_errno;
 
 	refs = get_submodule_ref_store(submodule);
@@ -1802,8 +1801,9 @@ int resolve_gitlink_ref(const char *submodule, const char *refname,
 	if (!refs)
 		return -1;
 
-	if (!refs_resolve_ref_unsafe(refs, refname, 0, oid, &flags,
-				     &ignore_errno) || is_null_oid(oid))
+	if (!refs_resolve_ref_unsafe(refs, refname, 0, oid, &unused_flags,
+				     &ignore_errno) ||
+	    is_null_oid(oid))
 		return -1;
 	return 0;
 }
diff --git a/refs.h b/refs.h
index 8f91a7f9ff2..6a4ef87b99e 100644
--- a/refs.h
+++ b/refs.h
@@ -68,23 +68,22 @@ struct worktree;
 #define RESOLVE_REF_NO_RECURSE 0x02
 #define RESOLVE_REF_ALLOW_BAD_NAME 0x04
 
-const char *refs_resolve_ref_unsafe(struct ref_store *refs,
-				    const char *refname,
-				    int resolve_flags,
-				    struct object_id *oid,
-				    int *flags, int *failure_errno);
-
-const char *resolve_ref_unsafe(const char *refname, int resolve_flags,
-			       struct object_id *oid, int *flags);
-
-char *refs_resolve_refdup(struct ref_store *refs,
-			  const char *refname, int resolve_flags,
-			  struct object_id *oid, int *flags);
-char *resolve_refdup(const char *refname, int resolve_flags,
-		     struct object_id *oid, int *flags);
-
-int read_ref_full(const char *refname, int resolve_flags,
-		  struct object_id *oid, int *flags);
+const char *refs_resolve_ref_unsafe(struct ref_store *refs, const char *refname,
+				    unsigned int resolve_flags,
+				    struct object_id *oid, unsigned int *flags,
+				    int *failure_errno);
+
+const char *resolve_ref_unsafe(const char *refname, unsigned int resolve_flags,
+			       struct object_id *oid, unsigned int *flags);
+
+char *refs_resolve_refdup(struct ref_store *refs, const char *refname,
+			  unsigned int resolve_flags, struct object_id *oid,
+			  unsigned int *flags);
+char *resolve_refdup(const char *refname, unsigned int resolve_flags,
+		     struct object_id *oid, unsigned int *flags);
+
+int read_ref_full(const char *refname, unsigned int resolve_flags,
+		  struct object_id *oid, unsigned int *flags);
 int read_ref(const char *refname, struct object_id *oid);
 
 /*
@@ -298,17 +297,15 @@ struct ref_transaction;
  * arguments is only guaranteed to be valid for the duration of a
  * single callback invocation.
  */
-typedef int each_ref_fn(const char *refname,
-			const struct object_id *oid, int flags, void *cb_data);
+typedef int each_ref_fn(const char *refname, const struct object_id *oid,
+			unsigned int flags, void *cb_data);
 
 /*
  * The same as each_ref_fn, but also with a repository argument that
  * contains the repository associated with the callback.
  */
-typedef int each_repo_ref_fn(struct repository *r,
-			     const char *refname,
-			     const struct object_id *oid,
-			     int flags,
+typedef int each_repo_ref_fn(struct repository *r, const char *refname,
+			     const struct object_id *oid, unsigned int flags,
 			     void *cb_data);
 
 /*
@@ -532,7 +529,7 @@ int for_each_reflog(each_ref_fn fn, void *cb_data);
  * allow a single "*" wildcard character in the refspec. No leading or
  * repeated slashes are accepted.
  */
-int check_refname_format(const char *refname, int flags);
+int check_refname_format(const char *refname, unsigned int flags);
 
 /*
  * Apply the rules from check_refname_format, but mutate the result until it
@@ -896,7 +893,7 @@ struct ref_store *get_main_ref_store(struct repository *r);
  *
  * ----
  * static int handle_remote_ref(const char *refname,
- * 		const unsigned char *sha1, int flags, void *cb_data)
+ * 		const unsigned char *sha1, unsigned int flags, void *cb_data)
  * {
  * 	struct strbuf *output = cb_data;
  * 	strbuf_addf(output, "%s\n", refname);
diff --git a/refs/files-backend.c b/refs/files-backend.c
index 43a3b882d7c..8890e2f684c 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -261,7 +261,6 @@ static void loose_fill_ref_dir(struct ref_store *ref_store,
 	while ((de = readdir(d)) != NULL) {
 		struct object_id oid;
 		struct stat st;
-		int flag;
 
 		if (de->d_name[0] == '.')
 			continue;
@@ -278,12 +277,12 @@ static void loose_fill_ref_dir(struct ref_store *ref_store,
 							  refname.len));
 		} else {
 			int ignore_errno;
-			if (!refs_resolve_ref_unsafe(&refs->base,
-						     refname.buf,
-						     RESOLVE_REF_READING,
-						     &oid, &flag, &ignore_errno)) {
+			unsigned int flags;
+			if (!refs_resolve_ref_unsafe(&refs->base, refname.buf,
+						     RESOLVE_REF_READING, &oid,
+						     &flags, &ignore_errno)) {
 				oidclr(&oid);
-				flag |= REF_ISBROKEN;
+				flags |= REF_ISBROKEN;
 			} else if (is_null_oid(&oid)) {
 				/*
 				 * It is so astronomically unlikely
@@ -293,7 +292,7 @@ static void loose_fill_ref_dir(struct ref_store *ref_store,
 				 * file to be repo corruption
 				 * (probably due to a software bug).
 				 */
-				flag |= REF_ISBROKEN;
+				flags |= REF_ISBROKEN;
 			}
 
 			if (check_refname_format(refname.buf,
@@ -301,10 +300,10 @@ static void loose_fill_ref_dir(struct ref_store *ref_store,
 				if (!refname_is_safe(refname.buf))
 					die("loose refname is dangerous: %s", refname.buf);
 				oidclr(&oid);
-				flag |= REF_BAD_NAME | REF_ISBROKEN;
+				flags |= REF_BAD_NAME | REF_ISBROKEN;
 			}
-			add_entry_to_dir(dir,
-					 create_ref_entry(refname.buf, &oid, flag));
+			add_entry_to_dir(dir, create_ref_entry(refname.buf,
+							       &oid, flags));
 		}
 		strbuf_setlen(&refname, dirnamelen);
 		strbuf_setlen(&path, path_baselen);
@@ -1391,7 +1390,8 @@ static int files_copy_or_rename_ref(struct ref_store *ref_store,
 	struct files_ref_store *refs =
 		files_downcast(ref_store, REF_STORE_WRITE, "rename_ref");
 	struct object_id orig_oid;
-	int flag = 0, logmoved = 0;
+	int logmoved = 0;
+	unsigned int flags = 0;
 	struct ref_lock *lock;
 	struct stat loginfo;
 	struct strbuf sb_oldref = STRBUF_INIT;
@@ -1412,13 +1412,14 @@ static int files_copy_or_rename_ref(struct ref_store *ref_store,
 	}
 
 	if (!refs_resolve_ref_unsafe(&refs->base, oldrefname,
-				     RESOLVE_REF_READING | RESOLVE_REF_NO_RECURSE,
-				     &orig_oid, &flag, &ignore_errno)) {
+				     RESOLVE_REF_READING |
+					     RESOLVE_REF_NO_RECURSE,
+				     &orig_oid, &flags, &ignore_errno)) {
 		ret = error("refname %s not found", oldrefname);
 		goto out;
 	}
 
-	if (flag & REF_ISSYMREF) {
+	if (flags & REF_ISSYMREF) {
 		if (copy)
 			ret = error("refname %s is a symbolic ref, copying it is not supported",
 				    oldrefname);
@@ -1514,14 +1515,14 @@ static int files_copy_or_rename_ref(struct ref_store *ref_store,
 		goto rollbacklog;
 	}
 
-	flag = log_all_ref_updates;
+	flags = log_all_ref_updates;
 	log_all_ref_updates = LOG_REFS_NONE;
 	if (write_ref_to_lockfile(lock, &orig_oid, 0, &err) ||
 	    commit_ref_update(refs, lock, &orig_oid, NULL, &err)) {
 		error("unable to write current sha1 into %s: %s", oldrefname, err.buf);
 		strbuf_release(&err);
 	}
-	log_all_ref_updates = flag;
+	log_all_ref_updates = flags;
 
  rollbacklog:
 	if (logmoved && rename(sb_newref.buf, sb_oldref.buf))
@@ -1702,9 +1703,10 @@ static int log_ref_write_fd(int fd, const struct object_id *old_oid,
 }
 
 static int files_log_ref_write(struct files_ref_store *refs,
-			       const char *refname, const struct object_id *old_oid,
+			       const char *refname,
+			       const struct object_id *old_oid,
 			       const struct object_id *new_oid, const char *msg,
-			       int flags, struct strbuf *err)
+			       unsigned int flags, struct strbuf *err)
 {
 	int logfd, result;
 
@@ -1826,15 +1828,14 @@ static int commit_ref_update(struct files_ref_store *refs,
 		 * check with HEAD only which should cover 99% of all usage
 		 * scenarios (even 100% of the default ones).
 		 */
-		int head_flag;
+		unsigned int head_flags;
 		const char *head_ref;
 		int ignore_errno;
 
 		head_ref = refs_resolve_ref_unsafe(&refs->base, "HEAD",
-						   RESOLVE_REF_READING,
-						   NULL, &head_flag,
-						   &ignore_errno);
-		if (head_ref && (head_flag & REF_ISSYMREF) &&
+						   RESOLVE_REF_READING, NULL,
+						   &head_flags, &ignore_errno);
+		if (head_ref && (head_flags & REF_ISSYMREF) &&
 		    !strcmp(head_ref, lock->ref_name)) {
 			struct strbuf log_err = STRBUF_INIT;
 			if (files_log_ref_write(refs, "HEAD",
@@ -2159,7 +2160,7 @@ static int files_reflog_iterator_advance(struct ref_iterator *ref_iterator)
 	int ignore_errno;
 
 	while ((ok = dir_iterator_advance(diter)) == ITER_OK) {
-		int flags;
+		unsigned int flags;
 
 		if (!S_ISREG(diter->st.st_mode))
 			continue;
@@ -2669,7 +2670,7 @@ static int files_transaction_prepare(struct ref_store *ref_store,
 	int ret = 0;
 	struct string_list affected_refnames = STRING_LIST_INIT_NODUP;
 	char *head_ref = NULL;
-	int head_type;
+	unsigned int head_type;
 	struct files_transaction_backend_data *backend_data;
 	struct ref_transaction *packed_transaction = NULL;
 
@@ -2982,8 +2983,8 @@ static int files_transaction_abort(struct ref_store *ref_store,
 	return 0;
 }
 
-static int ref_present(const char *refname,
-		       const struct object_id *oid, int flags, void *cb_data)
+static int ref_present(const char *refname, const struct object_id *oid,
+		       unsigned int unused_flags, void *cb_data)
 {
 	struct string_list *affected_refnames = cb_data;
 
@@ -3209,7 +3210,7 @@ static int files_reflog_expire(struct ref_store *ref_store,
 		if ((expire_flags & EXPIRE_REFLOGS_UPDATE_REF) &&
 		    !is_null_oid(&cb.last_kept_oid)) {
 			int ignore_errno;
-			int type;
+			unsigned int type;
 			const char *ref;
 
 			ref = refs_resolve_ref_unsafe(&refs->base, refname,
diff --git a/remote.c b/remote.c
index a6d8ec6c1ac..d889241ce0a 100644
--- a/remote.c
+++ b/remote.c
@@ -500,7 +500,7 @@ static void alias_all_urls(struct remote_state *remote_state)
 
 static void read_config(struct repository *repo)
 {
-	int flag;
+	unsigned int flags;
 
 	if (repo->remote_state->initialized)
 		return;
@@ -510,8 +510,9 @@ static void read_config(struct repository *repo)
 	if (startup_info->have_repository) {
 		int ignore_errno;
 		const char *head_ref = refs_resolve_ref_unsafe(
-			get_main_ref_store(repo), "HEAD", 0, NULL, &flag, &ignore_errno);
-		if (head_ref && (flag & REF_ISSYMREF) &&
+			get_main_ref_store(repo), "HEAD", 0, NULL, &flags,
+			&ignore_errno);
+		if (head_ref && (flags & REF_ISSYMREF) &&
 		    skip_prefix(head_ref, "refs/heads/", &head_ref)) {
 			repo->remote_state->current_branch = make_branch(
 				repo->remote_state, head_ref, strlen(head_ref));
@@ -1272,14 +1273,12 @@ static int match_explicit(struct ref *src, struct ref *dst,
 		return -1;
 
 	if (!dst_value) {
-		int flag;
-
-		dst_value = resolve_ref_unsafe(matched_src->name,
-					       RESOLVE_REF_READING,
-					       NULL, &flag);
-		if (!dst_value ||
-		    ((flag & REF_ISSYMREF) &&
-		     !starts_with(dst_value, "refs/heads/")))
+		unsigned int flags;
+
+		dst_value = resolve_ref_unsafe(
+			matched_src->name, RESOLVE_REF_READING, NULL, &flags);
+		if (!dst_value || ((flags & REF_ISSYMREF) &&
+				   !starts_with(dst_value, "refs/heads/")))
 			die(_("%s cannot be resolved to branch"),
 			    matched_src->name);
 	}
@@ -1948,11 +1947,11 @@ const char *branch_get_push(struct branch *branch, struct strbuf *err)
 
 static int ignore_symref_update(const char *refname)
 {
-	int flag;
+	unsigned int flags;
 
-	if (!resolve_ref_unsafe(refname, 0, NULL, &flag))
+	if (!resolve_ref_unsafe(refname, 0, NULL, &flags))
 		return 0; /* non-existing refs are OK */
-	return (flag & REF_ISSYMREF);
+	return (flags & REF_ISSYMREF);
 }
 
 /*
@@ -2288,7 +2287,7 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb,
 }
 
 static int one_local_ref(const char *refname, const struct object_id *oid,
-			 int flag, void *cb_data)
+			 unsigned int flag, void *cb_data)
 {
 	struct ref ***local_tail = cb_data;
 	struct ref *ref;
@@ -2369,7 +2368,7 @@ struct stale_heads_info {
 };
 
 static int get_stale_heads_cb(const char *refname, const struct object_id *oid,
-			      int flags, void *cb_data)
+			      unsigned int flags, void *cb_data)
 {
 	struct stale_heads_info *info = cb_data;
 	struct string_list matches = STRING_LIST_INIT_DUP;
diff --git a/replace-object.c b/replace-object.c
index 7bd9aba6ee6..d00486305a5 100644
--- a/replace-object.c
+++ b/replace-object.c
@@ -6,10 +6,9 @@
 #include "repository.h"
 #include "commit.h"
 
-static int register_replace_ref(struct repository *r,
-				const char *refname,
+static int register_replace_ref(struct repository *r, const char *refname,
 				const struct object_id *oid,
-				int flag, void *cb_data)
+				unsigned int unused_flags, void *cb_data)
 {
 	/* Get sha1 from refname */
 	const char *slash = strrchr(refname, '/');
diff --git a/revision.c b/revision.c
index ad4286fbdde..4b6f7f112a8 100644
--- a/revision.c
+++ b/revision.c
@@ -1527,7 +1527,7 @@ int ref_excluded(struct string_list *ref_excludes, const char *path)
 }
 
 static int handle_one_ref(const char *path, const struct object_id *oid,
-			  int flag, void *cb_data)
+			  unsigned int unused_flags, void *cb_data)
 {
 	struct all_refs_cb *cb = cb_data;
 	struct object *object;
@@ -1612,7 +1612,7 @@ static int handle_one_reflog_ent(struct object_id *ooid, struct object_id *noid,
 
 static int handle_one_reflog(const char *refname_in_wt,
 			     const struct object_id *oid,
-			     int flag, void *cb_data)
+			     unsigned int unused_flags, void *cb_data)
 {
 	struct all_refs_cb *cb = cb_data;
 	struct strbuf refname = STRBUF_INIT;
@@ -2678,7 +2678,7 @@ static int handle_revision_pseudo_opt(struct rev_info *revs,
 
 static void NORETURN diagnose_missing_default(const char *def)
 {
-	int flags;
+	unsigned int flags;
 	const char *refname;
 
 	refname = resolve_ref_unsafe(def, 0, NULL, &flags);
diff --git a/server-info.c b/server-info.c
index 7701d7c20a1..06e3eb388ea 100644
--- a/server-info.c
+++ b/server-info.c
@@ -147,7 +147,7 @@ out:
 }
 
 static int add_info_ref(const char *path, const struct object_id *oid,
-			int flag, void *cb_data)
+			unsigned int unused_flags, void *cb_data)
 {
 	struct update_info_ctx *uic = cb_data;
 	struct object *o = parse_object(the_repository, oid);
diff --git a/shallow.c b/shallow.c
index 9ed18eb8849..709e265dde7 100644
--- a/shallow.c
+++ b/shallow.c
@@ -596,7 +596,7 @@ static void paint_down(struct paint_info *info, const struct object_id *oid,
 }
 
 static int mark_uninteresting(const char *refname, const struct object_id *oid,
-			      int flags, void *cb_data)
+			      unsigned int unused_flags, void *cb_data)
 {
 	struct commit *commit = lookup_commit_reference_gently(the_repository,
 							       oid, 1);
@@ -707,7 +707,7 @@ struct commit_array {
 };
 
 static int add_ref(const char *refname, const struct object_id *oid,
-		   int flags, void *cb_data)
+		   unsigned int unused_flags, void *cb_data)
 {
 	struct commit_array *ca = cb_data;
 	ALLOC_GROW(ca->commits, ca->nr + 1, ca->alloc);
diff --git a/submodule.c b/submodule.c
index c6890705241..325cfc7cd4b 100644
--- a/submodule.c
+++ b/submodule.c
@@ -909,7 +909,7 @@ static void free_submodules_oids(struct string_list *submodules)
 }
 
 static int has_remote(const char *refname, const struct object_id *oid,
-		      int flags, void *cb_data)
+		      unsigned int unused_flags, void *cb_data)
 {
 	return 1;
 }
@@ -1216,7 +1216,7 @@ int push_unpushed_submodules(struct repository *r,
 }
 
 static int append_oid_to_array(const char *ref, const struct object_id *oid,
-			       int flags, void *data)
+			       unsigned int unused_flags, void *data)
 {
 	struct oid_array *array = data;
 	oid_array_append(array, oid);
diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c
index 3e4ddaee705..5054600e3a9 100644
--- a/t/helper/test-ref-store.c
+++ b/t/helper/test-ref-store.c
@@ -160,7 +160,7 @@ static int cmd_rename_ref(struct ref_store *refs, const char **argv)
 }
 
 static int each_ref(const char *refname, const struct object_id *oid,
-		    int flags, void *cb_data)
+		    unsigned int flags, void *cb_data)
 {
 	printf("%s %s 0x%x\n", oid_to_hex(oid), refname, flags);
 	return 0;
@@ -178,7 +178,7 @@ static int cmd_resolve_ref(struct ref_store *refs, const char **argv)
 	struct object_id oid = *null_oid();
 	const char *refname = notnull(*argv++, "refname");
 	int resolve_flags = arg_flags(*argv++, "resolve-flags", empty_flags);
-	int flags;
+	unsigned int flags;
 	const char *ref;
 	int ignore_errno;
 
diff --git a/transport-helper.c b/transport-helper.c
index a0297b0986c..b31c1198b8e 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -1090,13 +1090,15 @@ static int push_refs_with_export(struct transport *transport,
 			if (strcmp(ref->name, ref->peer_ref->name)) {
 				if (!ref->deletion) {
 					const char *name;
-					int flag;
+					unsigned int ref_flags;
 
 					/* Follow symbolic refs (mainly for HEAD). */
-					name = resolve_ref_unsafe(ref->peer_ref->name,
-								  RESOLVE_REF_READING,
-								  &oid, &flag);
-					if (!name || !(flag & REF_ISSYMREF))
+					name = resolve_ref_unsafe(
+						ref->peer_ref->name,
+						RESOLVE_REF_READING, &oid,
+						&ref_flags);
+					if (!name ||
+					    !(ref_flags & REF_ISSYMREF))
 						name = ref->peer_ref->name;
 
 					strbuf_addf(&buf, "%s:%s", name, ref->name);
diff --git a/transport.c b/transport.c
index 2a3e3241545..00f4906e12b 100644
--- a/transport.c
+++ b/transport.c
@@ -80,7 +80,7 @@ static void set_upstreams(struct transport *transport, struct ref *refs,
 		const char *localname;
 		const char *tmp;
 		const char *remotename;
-		int flag = 0;
+		unsigned int ref_flags = 0;
 		/*
 		 * Check suitability for tracking. Must be successful /
 		 * already up-to-date ref create/modify (not delete).
@@ -96,10 +96,10 @@ static void set_upstreams(struct transport *transport, struct ref *refs,
 		/* Follow symbolic refs (mainly for HEAD). */
 		localname = ref->peer_ref->name;
 		remotename = ref->name;
-		tmp = resolve_ref_unsafe(localname, RESOLVE_REF_READING,
-					 NULL, &flag);
-		if (tmp && flag & REF_ISSYMREF &&
-			starts_with(tmp, "refs/heads/"))
+		tmp = resolve_ref_unsafe(localname, RESOLVE_REF_READING, NULL,
+					 &ref_flags);
+		if (tmp && ref_flags & REF_ISSYMREF &&
+		    starts_with(tmp, "refs/heads/"))
 			localname = tmp;
 
 		/* Both source and destination must be local branches. */
diff --git a/upload-pack.c b/upload-pack.c
index 8acc98741bb..6300af75f20 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -822,7 +822,7 @@ static void send_unshallow(struct upload_pack_data *data)
 }
 
 static int check_ref(const char *refname_full, const struct object_id *oid,
-		     int flag, void *cb_data);
+		     unsigned int flag, void *cb_data);
 static void deepen(struct upload_pack_data *data, int depth)
 {
 	if (depth == INFINITE_DEPTH && !is_repository_shallow(the_repository)) {
@@ -1169,7 +1169,7 @@ static int mark_our_ref(const char *refname, const char *refname_full,
 }
 
 static int check_ref(const char *refname_full, const struct object_id *oid,
-		     int flag, void *cb_data)
+		     unsigned int unused_flags, void *cb_data)
 {
 	const char *refname = strip_namespace(refname_full);
 
@@ -1193,7 +1193,7 @@ static void format_session_id(struct strbuf *buf, struct upload_pack_data *d) {
 }
 
 static int send_ref(const char *refname, const struct object_id *oid,
-		    int flag, void *cb_data)
+		    unsigned int unused_flags, void *cb_data)
 {
 	static const char *capabilities = "multi_ack thin-pack side-band"
 		" side-band-64k ofs-delta shallow deepen-since deepen-not"
@@ -1236,15 +1236,15 @@ static int send_ref(const char *refname, const struct object_id *oid,
 }
 
 static int find_symref(const char *refname, const struct object_id *oid,
-		       int flag, void *cb_data)
+		       unsigned int flags, void *cb_data)
 {
 	const char *symref_target;
 	struct string_list_item *item;
 
-	if ((flag & REF_ISSYMREF) == 0)
+	if ((flags & REF_ISSYMREF) == 0)
 		return 0;
-	symref_target = resolve_ref_unsafe(refname, 0, NULL, &flag);
-	if (!symref_target || (flag & REF_ISSYMREF) == 0)
+	symref_target = resolve_ref_unsafe(refname, 0, NULL, &flags);
+	if (!symref_target || (flags & REF_ISSYMREF) == 0)
 		die("'%s' is a symref but it is not?", refname);
 	item = string_list_append(cb_data, strip_namespace(refname));
 	item->util = xstrdup(strip_namespace(symref_target));
diff --git a/walker.c b/walker.c
index c5e29219795..af8ce53a15b 100644
--- a/walker.c
+++ b/walker.c
@@ -216,7 +216,7 @@ static int interpret_target(struct walker *walker, char *target, struct object_i
 }
 
 static int mark_complete(const char *path, const struct object_id *oid,
-			 int flag, void *cb_data)
+			 unsigned int unused_flags, void *cb_data)
 {
 	struct commit *commit = lookup_commit_reference_gently(the_repository,
 							       oid, 1);
diff --git a/worktree.c b/worktree.c
index 6f598dcfcdf..1c92993952a 100644
--- a/worktree.c
+++ b/worktree.c
@@ -26,7 +26,7 @@ void free_worktrees(struct worktree **worktrees)
  */
 static void add_head_info(struct worktree *wt)
 {
-	int flags;
+	unsigned int flags;
 	const char *target;
 	int ignore_errno;
 
@@ -415,7 +415,7 @@ const struct worktree *find_shared_symref(struct worktree **worktrees,
 		struct worktree *wt = worktrees[i];
 		const char *symref_target;
 		struct ref_store *refs;
-		int flags;
+		unsigned int flags;
 		int ignore_errno;
 
 		if (wt->is_bare)
@@ -562,7 +562,7 @@ int other_head_refs(each_ref_fn fn, void *cb_data)
 	for (p = worktrees; *p; p++) {
 		struct worktree *wt = *p;
 		struct object_id oid;
-		int flag;
+		unsigned int flags;
 		int ignore_errno;
 
 		if (wt->is_current)
@@ -571,10 +571,9 @@ int other_head_refs(each_ref_fn fn, void *cb_data)
 		strbuf_reset(&refname);
 		strbuf_worktree_ref(wt, &refname, "HEAD");
 		if (refs_resolve_ref_unsafe(get_main_ref_store(the_repository),
-					    refname.buf,
-					    RESOLVE_REF_READING,
-					    &oid, &flag, &ignore_errno))
-			ret = fn(refname.buf, &oid, flag, cb_data);
+					    refname.buf, RESOLVE_REF_READING,
+					    &oid, &flags, &ignore_errno))
+			ret = fn(refname.buf, &oid, flags, cb_data);
 		if (ret)
 			break;
 	}

base-commit: 5d01301f2b865aa8dba1654d3f447ce9d21db0b5
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH] refs.h: make all flags arguments unsigned
  2022-02-01 11:47   ` Han-Wen Nienhuys
@ 2022-02-01 18:41     ` Junio C Hamano
  0 siblings, 0 replies; 17+ messages in thread
From: Junio C Hamano @ 2022-02-01 18:41 UTC (permalink / raw)
  To: Han-Wen Nienhuys; +Cc: Han-Wen Nienhuys via GitGitGadget, git, Han-Wen Nienhuys

Han-Wen Nienhuys <hanwen@google.com> writes:

> On Tue, Feb 1, 2022 at 3:02 AM Junio C Hamano <gitster@pobox.com> wrote:
>>
>> "Han-Wen Nienhuys via GitGitGadget" <gitgitgadget@gmail.com> writes:
>>
>> > From: Han-Wen Nienhuys <hanwen@google.com>
>> >
>> > As discussed in
>> > https://lore.kernel.org/git/xmqqbkzrkevo.fsf@gitster.g/ , we don't
>> > want to treat the sign bit specially, so make all flags in refs.h
>> > unsigned.
>>
>> It may be true that we do not want to, but are we sure there is no
>> code that already uses some cleverness to make the topmost bit
>> special by e.g. doing ugly things like "if (flags < 0)" ;-)?
>
> In refs.h, we don't have any bitmasks that accept 32 different bit
> values, so it's hard to see how we would stumble into a case like
> that.
>
>> I haven't had energy to vet the entire codebase for all flag words
>> and that is why I've never produced a patch like this one myself.
>>
>> Thanks for carefully vetting after creating this (presumably
>> mechanically prepared) patch---producing is the easy part, but
>> making sure it does not break unexpectedly is much harder.
>
> I went over the changes once more, uniformizing the naming. I didn't
> see any shenanigans.

Thanks again.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2] refs.h: make all flags arguments unsigned
  2022-02-01 12:46 ` [PATCH v2] " Han-Wen Nienhuys via GitGitGadget
@ 2022-02-01 20:20   ` Ævar Arnfjörð Bjarmason
  2022-02-01 23:03     ` Junio C Hamano
  2022-02-03 14:26   ` [PATCH v3 0/2] " Han-Wen Nienhuys via GitGitGadget
  1 sibling, 1 reply; 17+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2022-02-01 20:20 UTC (permalink / raw)
  To: Han-Wen Nienhuys via GitGitGadget; +Cc: git, Han-Wen Nienhuys, Han-Wen Nienhuys


On Tue, Feb 01 2022, Han-Wen Nienhuys via GitGitGadget wrote:

> From: Han-Wen Nienhuys <hanwen@google.com>
>
> As discussed in
> https://lore.kernel.org/git/xmqqbkzrkevo.fsf@gitster.g/ , we don't
> want to treat the sign bit specially, so make all flags in refs.h
> unsigned.
>
> For uniformity, rename all variables to `flags` or `unused_flags`,
> from `flag`. In a couple of shadowing cases, use `ref_flags` for
> clarity.

For what it's worth I thought the suggestion of enums in your
https://lore.kernel.org/git/xmqqbkzrkevo.fsf@gitster.g/ made more sense,
e.g. I tried this on top:
	
	diff --git a/refs.c b/refs.c
	index 5f29775def1..dc33573f064 100644
	--- a/refs.c
	+++ b/refs.c
	@@ -265,7 +265,8 @@ int ref_resolves_to_object(const char *refname,
	 }
	 
	 char *refs_resolve_refdup(struct ref_store *refs, const char *refname,
	-			  int resolve_flags, struct object_id *oid,
	+			  enum resolve_ref_flags resolve_flags,
	+			  struct object_id *oid,
	 			  unsigned int *flags)
	 {
	 	const char *result;
	@@ -276,7 +277,8 @@ char *refs_resolve_refdup(struct ref_store *refs, const char *refname,
	 	return xstrdup_or_null(result);
	 }
	 
	-char *resolve_refdup(const char *refname, unsigned int resolve_flags,
	+char *resolve_refdup(const char *refname,
	+		     enum resolve_ref_flags resolve_flags,
	 		     struct object_id *oid, unsigned int *flags)
	 {
	 	return refs_resolve_refdup(get_main_ref_store(the_repository),
	@@ -292,7 +294,8 @@ struct ref_filter {
	 	void *cb_data;
	 };
	 
	-int read_ref_full(const char *refname, unsigned int resolve_flags,
	+int read_ref_full(const char *refname,
	+		  enum resolve_ref_flags resolve_flags,
	 		  struct object_id *oid, unsigned int *flags)
	 {
	 	int ignore_errno;
	@@ -1679,7 +1682,8 @@ int refs_read_raw_ref(struct ref_store *ref_store, const char *refname,
	 }
	 
	 const char *refs_resolve_ref_unsafe(struct ref_store *refs, const char *refname,
	-				    int resolve_flags, struct object_id *oid,
	+				    enum resolve_ref_flags resolve_flags,
	+				    struct object_id *oid,
	 				    unsigned int *flags, int *failure_errno)
	 {
	 	static struct strbuf sb_refname = STRBUF_INIT;
	@@ -1779,7 +1783,8 @@ int refs_init_db(struct strbuf *err)
	 	return refs->be->init_db(refs, err);
	 }
	 
	-const char *resolve_ref_unsafe(const char *refname, int resolve_flags,
	+const char *resolve_ref_unsafe(const char *refname,
	+			       enum resolve_ref_flags resolve_flags,
	 			       struct object_id *oid, unsigned int *flags)
	 {
	 	int ignore_errno;
	diff --git a/refs.h b/refs.h
	index c5462b75807..8c7404eaf78 100644
	--- a/refs.h
	+++ b/refs.h
	@@ -64,24 +64,30 @@ struct worktree;
	  * type of failure encountered, but not necessarily one that came from
	  * a syscall. We might have faked it up.
	  */
	-#define RESOLVE_REF_READING 0x01
	-#define RESOLVE_REF_NO_RECURSE 0x02
	-#define RESOLVE_REF_ALLOW_BAD_NAME 0x04
	+enum resolve_ref_flags {
	+	RESOLVE_REF_READING = 1 << 0,
	+	RESOLVE_REF_NO_RECURSE = 1 << 1,
	+	RESOLVE_REF_ALLOW_BAD_NAME = 1 << 2,
	+};
	 
	 const char *refs_resolve_ref_unsafe(struct ref_store *refs, const char *refname,
	-				    int resolve_flags, struct object_id *oid,
	+				    enum resolve_ref_flags resolve_flags,
	+				    struct object_id *oid,
	 				    unsigned int *flags, int *failure_errno);
	 
	-const char *resolve_ref_unsafe(const char *refname, int resolve_flags,
	+const char *resolve_ref_unsafe(const char *refname,
	+			       enum resolve_ref_flags resolve_flags,
	 			       struct object_id *oid, unsigned int *flags);
	 
	 char *refs_resolve_refdup(struct ref_store *refs, const char *refname,
	-			  int resolve_flags, struct object_id *oid,
	+			  enum resolve_ref_flags resolve_flags,
	+			  struct object_id *oid,
	 			  unsigned int *flags);
	-char *resolve_refdup(const char *refname, unsigned int resolve_flags,
	+char *resolve_refdup(const char *refname,
	+		     enum resolve_ref_flags resolve_flags,
	 		     struct object_id *oid, unsigned int *flags);
	 
	-int read_ref_full(const char *refname, unsigned int resolve_flags,
	+int read_ref_full(const char *refname, enum resolve_ref_flags resolve_flags,
	 		  struct object_id *oid, unsigned int *flags);
	 int read_ref(const char *refname, struct object_id *oid);

I don't mind if this goes in, but I think doing that would make this
much easier to deal with, as it would be more obvious when working on
the code just what flag you're dealing with. Even as Junio points out
downthread of that it mostly doesn't matter in C.

See though 3f9ab7ccdea (parse-options.[ch]: consistently use "enum
parse_opt_flags", 2021-10-08) where doing it this way makes debugging
much nicer to work with.

> -		int flag;
> -		char *head_ref = resolve_refdup("HEAD", 0, NULL, &flag);
> -		if (head_ref &&
> -		    (!(flag & REF_ISSYMREF) || strcmp(head_ref, new_branch_info->path)))
> +		unsigned int flags;
> +		char *head_ref = resolve_refdup("HEAD", 0, NULL, &flags);
> +		if (head_ref && (!(flags & REF_ISSYMREF) ||
> +				 strcmp(head_ref, new_branch_info->path)))

I don't think this needs a re-roll, but FWIW I think it's much easier to
review changes like these if the changes are kept apart. E.g. this
variable renaming from the type change.

> -static int add_one_refname(const char *refname,
> -			   const struct object_id *oid,
> -			   int flag, void *cbdata)
> +static int add_one_refname(const char *refname, const struct object_id *oid,
> +			   unsigned int unused_flags, void *cbdata)

And this change not mentioned in the commit message of seemingly doing
some re-flowing of argument lists while we're at it.

The post-image is better, but better done is another step IMO.

I didn't look through the rest of the diff as you sent it, but locally
with appropriate word-diff flags to hide any formatting changes.

The post-image LGTM, but I'm also a bit "meh" on the churn just for
signed->unsigned, especially given the conflict with my in-flight
ab/no-errno-from-resolve-ref-unsafe. But it's not too bad, and if Junio
hasn't complained about it...

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2] refs.h: make all flags arguments unsigned
  2022-02-01 20:20   ` Ævar Arnfjörð Bjarmason
@ 2022-02-01 23:03     ` Junio C Hamano
  2022-02-03 14:29       ` Han-Wen Nienhuys
  0 siblings, 1 reply; 17+ messages in thread
From: Junio C Hamano @ 2022-02-01 23:03 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: Han-Wen Nienhuys via GitGitGadget, git, Han-Wen Nienhuys,
	Han-Wen Nienhuys

Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:

> The post-image LGTM, but I'm also a bit "meh" on the churn just for
> signed->unsigned, especially given the conflict with my in-flight
> ab/no-errno-from-resolve-ref-unsafe. But it's not too bad, and if Junio
> hasn't complained about it...

I won't complain myself.  I'd still try to help newer developers,
but my intention is to make it the responsibility for individual
developers to make sure their topic works well with topics in
flight ;-)

Between "enum" and #define that is stored in "unsigned", neither
gives us much type safety in C; "enum" may be somewhat worse by
giving a false sense of having a type safety that does not really
exist, than "unsigned int" that is more honestly defeats such a
false sense of safety.  So I have no strong preference either way.


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v3 0/2] refs.h: make all flags arguments unsigned
  2022-02-01 12:46 ` [PATCH v2] " Han-Wen Nienhuys via GitGitGadget
  2022-02-01 20:20   ` Ævar Arnfjörð Bjarmason
@ 2022-02-03 14:26   ` Han-Wen Nienhuys via GitGitGadget
  2022-02-03 14:26     ` [PATCH v3 1/2] " Han-Wen Nienhuys via GitGitGadget
  2022-02-03 14:26     ` [PATCH v3 2/2] Uniformize flag argument naming to `flags` or `unused_flags` Han-Wen Nienhuys via GitGitGadget
  1 sibling, 2 replies; 17+ messages in thread
From: Han-Wen Nienhuys via GitGitGadget @ 2022-02-03 14:26 UTC (permalink / raw)
  To: git
  Cc: Han-Wen Nienhuys, Ævar Arnfjörð Bjarmason,
	Han-Wen Nienhuys

v3:

 * split off rename commit
 * base on seen (@fde6c449a)

Signed-off-by: Han-Wen Nienhuys hanwen@google.com

Han-Wen Nienhuys (2):
  refs.h: make all flags arguments unsigned
  Uniformize flag argument naming to `flags` or `unused_flags`

 bisect.c                    |  4 +-
 builtin/bisect--helper.c    | 11 +++---
 builtin/branch.c            |  4 +-
 builtin/checkout.c          | 24 ++++++------
 builtin/describe.c          |  3 +-
 builtin/fetch.c             | 10 ++---
 builtin/fsck.c              |  4 +-
 builtin/gc.c                |  5 +--
 builtin/name-rev.c          |  3 +-
 builtin/pack-objects.c      | 11 +++---
 builtin/rebase.c            | 10 +++--
 builtin/receive-pack.c      | 13 ++++---
 builtin/reflog.c            |  5 ++-
 builtin/remote.c            | 23 +++++++-----
 builtin/repack.c            |  2 +-
 builtin/replace.c           |  2 +-
 builtin/rev-parse.c         |  6 ++-
 builtin/show-branch.c       | 12 +++---
 builtin/show-ref.c          |  4 +-
 builtin/stash.c             |  2 +-
 builtin/submodule--helper.c |  4 +-
 builtin/symbolic-ref.c      |  6 +--
 bundle.c                    |  8 ++--
 commit-graph.c              |  5 +--
 config.c                    |  2 +-
 delta-islands.c             |  2 +-
 fetch-pack.c                |  7 ++--
 help.c                      |  2 +-
 http-backend.c              |  6 +--
 log-tree.c                  |  4 +-
 ls-refs.c                   | 18 ++++-----
 midx.c                      |  7 ++--
 negotiator/default.c        |  2 +-
 negotiator/skipping.c       |  2 +-
 notes.c                     |  5 ++-
 object-name.c               |  2 +-
 reachable.c                 |  4 +-
 ref-filter.c                |  9 +++--
 refs.c                      | 75 ++++++++++++++++++-------------------
 refs.h                      | 46 +++++++++++------------
 refs/files-backend.c        | 56 ++++++++++++++-------------
 remote.c                    | 30 +++++++--------
 replace-object.c            |  5 +--
 revision.c                  |  6 +--
 server-info.c               |  2 +-
 shallow.c                   |  4 +-
 submodule.c                 |  4 +-
 t/helper/test-ref-store.c   |  4 +-
 transport-helper.c          | 12 +++---
 transport.c                 | 10 ++---
 upload-pack.c               | 14 +++----
 walker.c                    |  2 +-
 worktree.c                  | 13 +++----
 53 files changed, 272 insertions(+), 264 deletions(-)


base-commit: fde6c449af7cc83f7d357653f1b8ee055f6cad3b
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1210%2Fhanwen%2Funsigned-flags-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1210/hanwen/unsigned-flags-v3
Pull-Request: https://github.com/git/git/pull/1210

Range-diff vs v2:

 1:  216006057b7 ! 1:  54dfe8d6a86 refs.h: make all flags arguments unsigned
     @@ Commit message
          want to treat the sign bit specially, so make all flags in refs.h
          unsigned.
      
     -    For uniformity, rename all variables to `flags` or `unused_flags`,
     -    from `flag`. In a couple of shadowing cases, use `ref_flags` for
     -    clarity.
     -
          Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
      
       ## bisect.c ##
     @@ bisect.c: void find_bisection(struct commit_list **commit_list, int *reaches,
       
       static int register_ref(const char *refname, const struct object_id *oid,
      -			int flags, void *cb_data)
     -+			unsigned int unused_flags, void *cb_data)
     ++			unsigned int flags, void *cb_data)
       {
       	struct strbuf good_prefix = STRBUF_INIT;
       	strbuf_addstr(&good_prefix, term_good);
     @@ bisect.c: int estimate_bisect_steps(int all)
       
       static int mark_for_removal(const char *refname, const struct object_id *oid,
      -			    int flag, void *cb_data)
     -+			    unsigned int unused_flags, void *cb_data)
     ++			    unsigned int flag, void *cb_data)
       {
       	struct string_list *refs = cb_data;
       	char *ref = xstrfmt("refs/bisect%s", refname);
     @@ builtin/bisect--helper.c: static int check_and_set_terms(struct bisect_terms *te
       
       static int mark_good(const char *refname, const struct object_id *oid,
      -		     int flag, void *cb_data)
     -+		     unsigned int unused_flags, void *cb_data)
     ++		     unsigned int flag, void *cb_data)
       {
       	int *m_good = (int *)cb_data;
       	*m_good = 0;
     @@ builtin/bisect--helper.c: finish:
       
       static int add_bisect_ref(const char *refname, const struct object_id *oid,
      -			  int flags, void *cb)
     -+			  unsigned int unused_flags, void *cb)
     ++			  unsigned int flags, void *cb)
       {
       	struct add_bisect_ref_data *data = cb;
       
     @@ builtin/bisect--helper.c: static enum bisect_error bisect_start(struct bisect_te
       	int i, has_double_dash = 0, must_write_terms = 0, bad_seen = 0;
      -	int flags, pathspec_pos;
      +	int pathspec_pos;
     -+	unsigned int unused_flags;
     ++	unsigned int flags;
       	enum bisect_error res = BISECT_OK;
       	struct string_list revs = STRING_LIST_INIT_DUP;
       	struct string_list states = STRING_LIST_INIT_DUP;
     -@@ builtin/bisect--helper.c: static enum bisect_error bisect_start(struct bisect_terms *terms, const char **a
     - 	/*
     - 	 * Verify HEAD
     - 	 */
     --	head = resolve_ref_unsafe("HEAD", 0, &head_oid, &flags);
     -+	head = resolve_ref_unsafe("HEAD", 0, &head_oid, &unused_flags);
     - 	if (!head)
     - 		if (get_oid("HEAD", &head_oid))
     - 			return error(_("bad HEAD - I need a HEAD"));
      
       ## builtin/branch.c ##
      @@ builtin/branch.c: static int delete_branches(int argc, const char **argv, int force, int kinds,
     @@ builtin/checkout.c: static void update_refs_for_switch(const struct checkout_opt
       static int add_pending_uninteresting_ref(const char *refname,
       					 const struct object_id *oid,
      -					 int flags, void *cb_data)
     -+					 unsigned int unused_flags,
     -+					 void *cb_data)
     ++					 unsigned int flags, void *cb_data)
       {
       	add_pending_oid(cb_data, refname, oid, UNINTERESTING);
       	return 0;
     @@ builtin/checkout.c: static int switch_branches(const struct checkout_opts *opts,
       	struct object_id rev;
      -	int flag, writeout_error = 0;
      +	int writeout_error = 0;
     -+	unsigned int flags;
     ++	unsigned int flag;
       	int do_merge = 1;
       
       	trace2_cmd_mode("branch");
     - 
     - 	memset(&old_branch_info, 0, sizeof(old_branch_info));
     --	old_branch_info.path = resolve_refdup("HEAD", 0, &rev, &flag);
     -+	old_branch_info.path = resolve_refdup("HEAD", 0, &rev, &flags);
     - 	if (old_branch_info.path)
     - 		old_branch_info.commit = lookup_commit_reference_gently(the_repository, &rev, 1);
     --	if (!(flag & REF_ISSYMREF))
     -+	if (!(flags & REF_ISSYMREF))
     - 		FREE_AND_NULL(old_branch_info.path);
     - 
     - 	if (old_branch_info.path) {
      @@ builtin/checkout.c: static int checkout_branch(struct checkout_opts *opts,
       
       	if (new_branch_info->path && !opts->force_detach && !opts->new_branch &&
       	    !opts->ignore_other_worktrees) {
      -		int flag;
     --		char *head_ref = resolve_refdup("HEAD", 0, NULL, &flag);
     --		if (head_ref &&
     --		    (!(flag & REF_ISSYMREF) || strcmp(head_ref, new_branch_info->path)))
     -+		unsigned int flags;
     -+		char *head_ref = resolve_refdup("HEAD", 0, NULL, &flags);
     -+		if (head_ref && (!(flags & REF_ISSYMREF) ||
     -+				 strcmp(head_ref, new_branch_info->path)))
     - 			die_if_checked_out(new_branch_info->path, 1);
     - 		free(head_ref);
     - 	}
     ++		unsigned int flag;
     + 		char *head_ref = resolve_refdup("HEAD", 0, NULL, &flag);
     + 		if (head_ref &&
     + 		    (!(flag & REF_ISSYMREF) || strcmp(head_ref, new_branch_info->path)))
     +@@ builtin/checkout.c: static int checkout_branch(struct checkout_opts *opts,
       
       	if (!new_branch_info->commit && opts->new_branch) {
       		struct object_id rev;
      -		int flag;
     -+		unsigned int flags;
     ++		unsigned int flag;
       
     --		if (!read_ref_full("HEAD", 0, &rev, &flag) &&
     --		    (flag & REF_ISSYMREF) && is_null_oid(&rev))
     -+		if (!read_ref_full("HEAD", 0, &rev, &flags) &&
     -+		    (flags & REF_ISSYMREF) && is_null_oid(&rev))
     - 			return switch_unborn_to_new_branch(opts);
     - 	}
     - 	return switch_branches(opts, new_branch_info);
     + 		if (!read_ref_full("HEAD", 0, &rev, &flag) &&
     + 		    (flag & REF_ISSYMREF) && is_null_oid(&rev))
      
       ## builtin/describe.c ##
      @@ builtin/describe.c: static void add_to_known_names(const char *path,
     @@ builtin/describe.c: static void add_to_known_names(const char *path,
       
      -static int get_name(const char *path, const struct object_id *oid, int flag, void *cb_data)
      +static int get_name(const char *path, const struct object_id *oid,
     -+		    unsigned int unused_flags, void *cb_data)
     ++		    unsigned int flag, void *cb_data)
       {
       	int is_tag = 0;
       	struct object_id peeled;
     @@ builtin/fetch.c: static struct refname_hash_entry *refname_hash_add(struct hashm
      -			   const struct object_id *oid,
      -			   int flag, void *cbdata)
      +static int add_one_refname(const char *refname, const struct object_id *oid,
     -+			   unsigned int unused_flags, void *cbdata)
     ++			   unsigned int flag, void *cbdata)
       {
       	struct hashmap *refname_map = cbdata;
       
     @@ builtin/fetch.c: static void set_option(struct transport *transport, const char
      -static int add_oid(const char *refname, const struct object_id *oid, int flags,
      -		   void *cb_data)
      +static int add_oid(const char *refname, const struct object_id *oid,
     -+		   unsigned int unused_flags, void *cb_data)
     ++		   unsigned int flags, void *cb_data)
       {
       	struct oid_array *oids = cb_data;
       
     @@ builtin/fsck.c: static int fsck_handle_reflog_ent(struct object_id *ooid, struct
       
       static int fsck_handle_reflog(const char *logname, const struct object_id *oid,
      -			      int flag, void *cb_data)
     -+			      unsigned int unused_flags, void *cb_data)
     ++			      unsigned int flag, void *cb_data)
       {
       	struct strbuf refname = STRBUF_INIT;
       
     @@ builtin/fsck.c: static int fsck_handle_reflog(const char *logname, const struct
       
       static int fsck_handle_ref(const char *refname, const struct object_id *oid,
      -			   int flag, void *cb_data)
     -+			   unsigned int unused_flags, void *cb_data)
     ++			   unsigned int flag, void *cb_data)
       {
       	struct object *obj;
       
     @@ builtin/gc.c: struct cg_auto_data {
      -		      const struct object_id *oid, int flags,
      -		      void *cb_data)
      +static int dfs_on_ref(const char *refname, const struct object_id *oid,
     -+		      unsigned int unused_flags, void *cb_data)
     ++		      unsigned int flags, void *cb_data)
       {
       	struct cg_auto_data *data = (struct cg_auto_data *)cb_data;
       	int result = 0;
     @@ builtin/name-rev.c: static int cmp_by_tag_and_age(const void *a_, const void *b_
       
      -static int name_ref(const char *path, const struct object_id *oid, int flags, void *cb_data)
      +static int name_ref(const char *path, const struct object_id *oid,
     -+		    unsigned int unused_flags, void *cb_data)
     ++		    unsigned int flags, void *cb_data)
       {
       	struct object *o = parse_object(the_repository, oid);
       	struct name_ref_data *data = cb_data;
     @@ builtin/pack-objects.c: static enum write_one_status write_one(struct hashfile *
      -static int mark_tagged(const char *path, const struct object_id *oid, int flag,
      -		       void *cb_data)
      +static int mark_tagged(const char *path, const struct object_id *oid,
     -+		       unsigned int unused_flags, void *cb_data)
     ++		       unsigned int flag, void *cb_data)
       {
       	struct object_id peeled;
       	struct object_entry *entry = packlist_find(&to_pack, oid);
     @@ builtin/pack-objects.c: static void add_tag_chain(const struct object_id *oid)
       
      -static int add_ref_tag(const char *tag, const struct object_id *oid, int flag, void *cb_data)
      +static int add_ref_tag(const char *tag, const struct object_id *oid,
     -+		       unsigned int unused_flags, void *cb_data)
     ++		       unsigned int flag, void *cb_data)
       {
       	struct object_id peeled;
       
     @@ builtin/rebase.c: int cmd_rebase(int argc, const char **argv, const char *prefix
       	const char *branch_name;
      -	int ret, flags, total_argc, in_progress = 0;
      +	int ret, total_argc, in_progress = 0;
     ++	unsigned int flags;
       	int keep_base = 0;
       	int ok_to_skip_pre_rebase = 0;
       	struct strbuf msg = STRBUF_INIT;
     -@@ builtin/rebase.c: int cmd_rebase(int argc, const char **argv, const char *prefix)
     - 		}
     - 	} else if (argc == 0) {
     - 		/* Do not need to switch branches, we are already on it. */
     -+		unsigned int flags;
     - 		options.head_name =
     - 			xstrdup_or_null(resolve_ref_unsafe("HEAD", 0, NULL,
     - 					 &flags));
      @@ builtin/rebase.c: int cmd_rebase(int argc, const char **argv, const char *prefix)
       	if (can_fast_forward(options.onto, options.upstream, options.restrict_revision,
       		    &options.orig_head, &merge_base) &&
       	    allow_preemptive_ff) {
      -		int flag;
     -+		unsigned int unused_flags;
     ++		unsigned int flag;
       
       		if (!(options.flags & REBASE_FORCE)) {
       			/* Lazily switch to the target branch if needed... */
     -@@ builtin/rebase.c: int cmd_rebase(int argc, const char **argv, const char *prefix)
     - 			if (!(options.flags & REBASE_NO_QUIET))
     - 				; /* be quiet */
     - 			else if (!strcmp(branch_name, "HEAD") &&
     --				 resolve_ref_unsafe("HEAD", 0, NULL, &flag))
     -+				 resolve_ref_unsafe("HEAD", 0, NULL,
     -+						    &unused_flags))
     - 				puts(_("HEAD is up to date."));
     - 			else
     - 				printf(_("Current branch %s is up to date.\n"),
     -@@ builtin/rebase.c: int cmd_rebase(int argc, const char **argv, const char *prefix)
     - 		} else if (!(options.flags & REBASE_NO_QUIET))
     - 			; /* be quiet */
     - 		else if (!strcmp(branch_name, "HEAD") &&
     --			 resolve_ref_unsafe("HEAD", 0, NULL, &flag))
     -+			 resolve_ref_unsafe("HEAD", 0, NULL, &unused_flags))
     - 			puts(_("HEAD is up to date, rebase forced."));
     - 		else
     - 			printf(_("Current branch %s is up to date, rebase "
      
       ## builtin/receive-pack.c ##
      @@ builtin/receive-pack.c: static void show_ref(const char *path, const struct object_id *oid)
     @@ builtin/receive-pack.c: static void show_ref(const char *path, const struct obje
       
       static int show_ref_cb(const char *path_full, const struct object_id *oid,
      -		       int flag, void *data)
     -+		       unsigned int unused_flags, void *data)
     ++		       unsigned int flag, void *data)
       {
       	struct oidset *seen = data;
       	const char *path = strip_namespace(path_full);
     -@@ builtin/receive-pack.c: static void run_update_post_hook(struct command *commands)
     - 
     - static void check_aliased_update_internal(struct command *cmd,
     - 					  struct string_list *list,
     --					  const char *dst_name, int flag)
     -+					  const char *dst_name,
     -+					  unsigned int flags)
     - {
     - 	struct string_list_item *item;
     - 	struct command *dst_cmd;
     - 
     --	if (!(flag & REF_ISSYMREF))
     -+	if (!(flags & REF_ISSYMREF))
     - 		return;
     - 
     - 	if (!dst_name) {
      @@ builtin/receive-pack.c: static void check_aliased_update(struct command *cmd, struct string_list *list)
       {
       	struct strbuf buf = STRBUF_INIT;
       	const char *dst_name;
      -	int flag;
     -+	unsigned int flags;
     ++	unsigned int flag;
       
       	strbuf_addf(&buf, "%s%s", get_git_namespace(), cmd->ref_name);
     --	dst_name = resolve_ref_unsafe(buf.buf, 0, NULL, &flag);
     --	check_aliased_update_internal(cmd, list, dst_name, flag);
     -+	dst_name = resolve_ref_unsafe(buf.buf, 0, NULL, &flags);
     -+	check_aliased_update_internal(cmd, list, dst_name, flags);
     - 	strbuf_release(&buf);
     - }
     - 
     + 	dst_name = resolve_ref_unsafe(buf.buf, 0, NULL, &flag);
      
       ## builtin/reflog.c ##
      @@ builtin/reflog.c: static int should_expire_reflog_ent_verbose(struct object_id *ooid,
     @@ builtin/reflog.c: static void reflog_expiry_cleanup(void *cb_data)
       
      -static int collect_reflog(const char *ref, const struct object_id *oid, int unused, void *cb_data)
      +static int collect_reflog(const char *ref, const struct object_id *oid,
     -+			  unsigned int unused_flags, void *cb_data)
     ++			  unsigned int unused, void *cb_data)
       {
       	struct worktree_reflogs *cb = cb_data;
       	struct worktree *worktree = cb->worktree;
     @@ builtin/remote.c: struct branches_for_remote {
       static int add_branch_for_removal(const char *refname,
      -	const struct object_id *oid, int flags, void *cb_data)
      +				  const struct object_id *oid,
     -+				  unsigned int unused_flags, void *cb_data)
     ++				  unsigned int flags, void *cb_data)
       {
       	struct branches_for_remote *branches = cb_data;
       	struct refspec_item refspec;
     @@ builtin/remote.c: struct rename_info {
       
       static int read_remote_branches(const char *refname,
      -	const struct object_id *oid, int flags, void *cb_data)
     -+				const struct object_id *oid,
     -+				unsigned int unused_flags, void *cb_data)
     ++				const struct object_id *oid, unsigned int flags,
     ++				void *cb_data)
       {
       	struct rename_info *rename = cb_data;
       	struct strbuf buf = STRBUF_INIT;
       	struct string_list_item *item;
      -	int flag;
     ++	unsigned int flag;
       	const char *symref;
       
       	strbuf_addf(&buf, "refs/remotes/%s/", rename->old_name);
     - 	if (starts_with(refname, buf.buf)) {
     -+		unsigned int flags;
     - 		item = string_list_append(rename->remote_branches, refname);
     --		symref = resolve_ref_unsafe(refname, RESOLVE_REF_READING,
     --					    NULL, &flag);
     --		if (symref && (flag & REF_ISSYMREF))
     -+		symref = resolve_ref_unsafe(refname, RESOLVE_REF_READING, NULL,
     -+					    &flags);
     -+		if (symref && (flags & REF_ISSYMREF))
     - 			item->util = xstrdup(symref);
     - 		else
     - 			item->util = NULL;
      @@ builtin/remote.c: static int mv(int argc, const char **argv)
       	for_each_ref(read_remote_branches, &rename);
       	for (i = 0; i < remote_branches.nr; i++) {
       		struct string_list_item *item = remote_branches.items + i;
      -		int flag = 0;
     -+		unsigned int flags = 0;
     ++		unsigned int flag = 0;
       
     --		read_ref_full(item->string, RESOLVE_REF_READING, NULL, &flag);
     --		if (!(flag & REF_ISSYMREF))
     -+		read_ref_full(item->string, RESOLVE_REF_READING, NULL, &flags);
     -+		if (!(flags & REF_ISSYMREF))
     - 			continue;
     - 		if (delete_ref(NULL, item->string, NULL, REF_NO_DEREF))
     - 			die(_("deleting '%s' failed"), item->string);
     + 		read_ref_full(item->string, RESOLVE_REF_READING, NULL, &flag);
     + 		if (!(flag & REF_ISSYMREF))
      @@ builtin/remote.c: static void free_remote_ref_states(struct ref_states *states)
       }
       
     @@ builtin/remote.c: static void free_remote_ref_states(struct ref_states *states)
      
       ## builtin/repack.c ##
      @@ builtin/repack.c: struct midx_snapshot_ref_data {
     + };
       
       static int midx_snapshot_ref_one(const char *refname,
     - 				 const struct object_id *oid,
     +-				 const struct object_id *oid,
      -				 int flag, void *_data)
     -+				 unsigned int unused_flag, void *_data)
     ++				 const struct object_id *oid, unsigned int flag,
     ++				 void *_data)
       {
       	struct midx_snapshot_ref_data *data = _data;
       	struct object_id peeled;
      
       ## builtin/replace.c ##
      @@ builtin/replace.c: struct show_data {
     + };
       
       static int show_reference(struct repository *r, const char *refname,
     - 			  const struct object_id *oid,
     +-			  const struct object_id *oid,
      -			  int flag, void *cb_data)
     -+			  unsigned int unused_flags, void *cb_data)
     ++			  const struct object_id *oid, unsigned int flag,
     ++			  void *cb_data)
       {
       	struct show_data *data = cb_data;
       
     @@ builtin/rev-parse.c: static int show_default(void)
       
      -static int show_reference(const char *refname, const struct object_id *oid, int flag, void *cb_data)
      +static int show_reference(const char *refname, const struct object_id *oid,
     -+			  unsigned int unused_flags, void *cb_data)
     ++			  unsigned int flag, void *cb_data)
       {
       	if (ref_excluded(ref_excludes, refname))
       		return 0;
     @@ builtin/rev-parse.c: static int show_reference(const char *refname, const struct
       
      -static int anti_reference(const char *refname, const struct object_id *oid, int flag, void *cb_data)
      +static int anti_reference(const char *refname, const struct object_id *oid,
     -+			  unsigned int unused_flags, void *cb_data)
     ++			  unsigned int flag, void *cb_data)
       {
       	show_rev(REVERSED, oid, refname);
       	return 0;
     @@ builtin/show-branch.c: static int append_ref(const char *refname, const struct o
       
       static int append_head_ref(const char *refname, const struct object_id *oid,
      -			   int flag, void *cb_data)
     -+			   unsigned int unused_flags, void *cb_data)
     ++			   unsigned int flag, void *cb_data)
       {
       	struct object_id tmp;
       	int ofs = 11;
     @@ builtin/show-branch.c: static int append_head_ref(const char *refname, const str
       
       static int append_remote_ref(const char *refname, const struct object_id *oid,
      -			     int flag, void *cb_data)
     -+			     unsigned int unused_flags, void *cb_data)
     ++			     unsigned int flag, void *cb_data)
       {
       	struct object_id tmp;
       	int ofs = 13;
     -@@ builtin/show-branch.c: static int append_remote_ref(const char *refname, const struct object_id *oid,
     - }
     - 
     - static int append_tag_ref(const char *refname, const struct object_id *oid,
     --			  int flag, void *cb_data)
     -+			  int unused_flags, void *cb_data)
     - {
     - 	if (!starts_with(refname, "refs/tags/"))
     - 		return 0;
      @@ builtin/show-branch.c: static const char *match_ref_pattern = NULL;
       static int match_ref_slash = 0;
       
       static int append_matching_ref(const char *refname, const struct object_id *oid,
      -			       int flag, void *cb_data)
     -+			       unsigned int flags, void *cb_data)
     ++			       unsigned int flag, void *cb_data)
       {
       	/* we want to allow pattern hold/<asterisk> to show all
       	 * branches under refs/heads/hold/, and v0.99.9? to show
     -@@ builtin/show-branch.c: static int append_matching_ref(const char *refname, const struct object_id *oid,
     - 	if (wildmatch(match_ref_pattern, tail, 0))
     - 		return 0;
     - 	if (starts_with(refname, "refs/heads/"))
     --		return append_head_ref(refname, oid, flag, cb_data);
     -+		return append_head_ref(refname, oid, flags, cb_data);
     - 	if (starts_with(refname, "refs/tags/"))
     --		return append_tag_ref(refname, oid, flag, cb_data);
     -+		return append_tag_ref(refname, oid, flags, cb_data);
     - 	return append_ref(refname, oid, 0);
     - }
     - 
      
       ## builtin/show-ref.c ##
      @@ builtin/show-ref.c: static void show_one(const char *refname, const struct object_id *oid)
     @@ builtin/show-ref.c: match:
       
       static int add_existing(const char *refname, const struct object_id *oid,
      -			int flag, void *cbdata)
     -+			unsigned int unused_flags, void *cbdata)
     ++			unsigned int flag, void *cbdata)
       {
       	struct string_list *list = (struct string_list *)cbdata;
       	string_list_insert(list, refname);
     @@ builtin/submodule--helper.c: static void print_status(unsigned int flags, char s
      -				     const struct object_id *oid, int flags,
      -				     void *cb_data)
      +				     const struct object_id *oid,
     -+				     unsigned int unused_flags, void *cb_data)
     ++				     unsigned int flags, void *cb_data)
       {
       	struct object_id *output = cb_data;
       	if (oid)
     @@ builtin/symbolic-ref.c: static const char * const git_symbolic_ref_usage[] = {
       static int check_symref(const char *HEAD, int quiet, int shorten, int print)
       {
      -	int flag;
     --	const char *refname = resolve_ref_unsafe(HEAD, 0, NULL, &flag);
     -+	unsigned int flags;
     -+	const char *refname = resolve_ref_unsafe(HEAD, 0, NULL, &flags);
     ++	unsigned int flag;
     + 	const char *refname = resolve_ref_unsafe(HEAD, 0, NULL, &flag);
       
       	if (!refname)
     - 		die("No such ref: %s", HEAD);
     --	else if (!(flag & REF_ISSYMREF)) {
     -+	else if (!(flags & REF_ISSYMREF)) {
     - 		if (!quiet)
     - 			die("ref %s is not a symbolic ref", HEAD);
     - 		else
      
       ## bundle.c ##
      @@ bundle.c: static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
     @@ bundle.c: static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
       		char *ref;
       		const char *display_ref;
      -		int flag;
     -+		unsigned int flags;
     ++		unsigned int flag;
       
       		if (e->item->flags & UNINTERESTING)
       			continue;
     - 		if (dwim_ref(e->name, strlen(e->name), &oid, &ref, 0) != 1)
     - 			goto skip_write_ref;
     --		if (read_ref_full(e->name, RESOLVE_REF_READING, &oid, &flag))
     --			flag = 0;
     --		display_ref = (flag & REF_ISSYMREF) ? e->name : ref;
     -+		if (read_ref_full(e->name, RESOLVE_REF_READING, &oid, &flags))
     -+			flags = 0;
     -+		display_ref = (flags & REF_ISSYMREF) ? e->name : ref;
     - 
     - 		if (e->item->type == OBJ_TAG &&
     - 				!is_tag_in_date_range(e->item, revs)) {
      
       ## commit-graph.c ##
      @@ commit-graph.c: struct refs_cb_data {
     @@ delta-islands.c: static void add_ref_to_island(const char *island_name, const st
       
       static int find_island_for_ref(const char *refname, const struct object_id *oid,
      -			       int flags, void *data)
     -+			       unsigned int unused_flags, void *data)
     ++			       unsigned int flags, void *data)
       {
       	/*
       	 * We should advertise 'ARRAY_SIZE(matches) - 2' as the max,
     @@ fetch-pack.c: static int rev_list_insert_ref(struct fetch_negotiator *negotiator
      -				   int flag, void *cb_data)
      +static int rev_list_insert_ref_oid(const char *refname,
      +				   const struct object_id *oid,
     -+				   unsigned int unused_flags, void *cb_data)
     ++				   unsigned int flag, void *cb_data)
       {
       	return rev_list_insert_ref(cb_data, oid);
       }
     @@ fetch-pack.c: static int mark_complete(const struct object_id *oid)
       
       static int mark_complete_oid(const char *refname, const struct object_id *oid,
      -			     int flag, void *cb_data)
     -+			     unsigned int unused_flags, void *cb_data)
     ++			     unsigned int flag, void *cb_data)
       {
       	return mark_complete(oid);
       }
     @@ http-backend.c: static void get_info_refs(struct strbuf *hdr, char *arg)
       
       static int show_head_ref(const char *refname, const struct object_id *oid,
      -			 int flag, void *cb_data)
     -+			 unsigned int flags, void *cb_data)
     ++			 unsigned int flag, void *cb_data)
       {
       	struct strbuf *buf = cb_data;
       
     --	if (flag & REF_ISSYMREF) {
     -+	if (flags & REF_ISSYMREF) {
     - 		const char *target = resolve_ref_unsafe(refname,
     - 							RESOLVE_REF_READING,
     - 							NULL, NULL);
      
       ## log-tree.c ##
      @@ log-tree.c: static int ref_filter_match(const char *refname,
     @@ log-tree.c: static int ref_filter_match(const char *refname,
       
       static int add_ref_decoration(const char *refname, const struct object_id *oid,
      -			      int flags, void *cb_data)
     -+			      unsigned int unused_flags, void *cb_data)
     ++			      unsigned int flags, void *cb_data)
       {
       	struct object *obj;
       	enum object_type objtype;
     @@ ls-refs.c: struct ls_refs_data {
       
       static int send_ref(const char *refname, const struct object_id *oid,
      -		    int flag, void *cb_data)
     -+		    unsigned int flags, void *cb_data)
     ++		    unsigned int flag, void *cb_data)
       {
       	struct ls_refs_data *data = cb_data;
       	const char *refname_nons = strip_namespace(refname);
     -@@ ls-refs.c: static int send_ref(const char *refname, const struct object_id *oid,
     - 		strbuf_addf(&data->buf, "%s %s", oid_to_hex(oid), refname_nons);
     - 	else
     - 		strbuf_addf(&data->buf, "unborn %s", refname_nons);
     --	if (data->symrefs && flag & REF_ISSYMREF) {
     -+	if (data->symrefs && flags & REF_ISSYMREF) {
     - 		struct object_id unused;
     --		const char *symref_target = resolve_ref_unsafe(refname, 0,
     --							       &unused,
     --							       &flag);
     -+		const char *symref_target =
     -+			resolve_ref_unsafe(refname, 0, &unused, &flags);
     - 
     - 		if (!symref_target)
     - 			die("'%s' is a symref but it is not?", refname);
      @@ ls-refs.c: static void send_possibly_unborn_head(struct ls_refs_data *data)
       {
       	struct strbuf namespaced = STRBUF_INIT;
       	struct object_id oid;
      -	int flag;
     -+	unsigned int flags;
     ++	unsigned int flag;
       	int oid_is_null;
       
       	strbuf_addf(&namespaced, "%sHEAD", get_git_namespace());
     --	if (!resolve_ref_unsafe(namespaced.buf, 0, &oid, &flag))
     -+	if (!resolve_ref_unsafe(namespaced.buf, 0, &oid, &flags))
     - 		return; /* bad ref */
     - 	oid_is_null = is_null_oid(&oid);
     - 	if (!oid_is_null ||
     --	    (data->unborn && data->symrefs && (flag & REF_ISSYMREF)))
     --		send_ref(namespaced.buf, oid_is_null ? NULL : &oid, flag, data);
     -+	    (data->unborn && data->symrefs && (flags & REF_ISSYMREF)))
     -+		send_ref(namespaced.buf, oid_is_null ? NULL : &oid, flags,
     -+			 data);
     - 	strbuf_release(&namespaced);
     - }
     - 
      
       ## midx.c ##
      @@ midx.c: static void prepare_midx_packing_data(struct packing_data *pdata,
     @@ midx.c: static void prepare_midx_packing_data(struct packing_data *pdata,
      -			      const struct object_id *oid,
      -			      int flag, void *cb_data)
      +static int add_ref_to_pending(const char *refname, const struct object_id *oid,
     -+			      unsigned int flags, void *cb_data)
     ++			      unsigned int flag, void *cb_data)
       {
       	struct rev_info *revs = (struct rev_info*)cb_data;
       	struct object *object;
     - 
     --	if ((flag & REF_ISSYMREF) && (flag & REF_ISBROKEN)) {
     -+	if ((flags & REF_ISSYMREF) && (flags & REF_ISBROKEN)) {
     - 		warning("symbolic ref is dangling: %s", refname);
     - 		return 0;
     - 	}
      
       ## negotiator/default.c ##
      @@ negotiator/default.c: static void rev_list_push(struct negotiation_state *ns,
     @@ negotiator/default.c: static void rev_list_push(struct negotiation_state *ns,
       
       static int clear_marks(const char *refname, const struct object_id *oid,
      -		       int flag, void *cb_data)
     -+		       unsigned int unused_flags, void *cb_data)
     ++		       unsigned int flag, void *cb_data)
       {
       	struct object *o = deref_tag(the_repository, parse_object(the_repository, oid), refname, 0);
       
     @@ negotiator/skipping.c: static struct entry *rev_list_push(struct data *data, str
       
       static int clear_marks(const char *refname, const struct object_id *oid,
      -		       int flag, void *cb_data)
     -+		       unsigned int unused_flags, void *cb_data)
     ++		       unsigned int flag, void *cb_data)
       {
       	struct object *o = deref_tag(the_repository, parse_object(the_repository, oid), refname, 0);
       
     @@ notes.c: out:
      -				   int flag, void *cb)
      +static int string_list_add_one_ref(const char *refname,
      +				   const struct object_id *oid,
     -+				   unsigned int unused_flags, void *cb)
     ++				   unsigned int flag, void *cb)
       {
       	struct string_list *refs = cb;
       	if (!unsorted_string_list_has_string(refs, refname))
     @@ object-name.c: struct handle_one_ref_cb {
       
       static int handle_one_ref(const char *path, const struct object_id *oid,
      -			  int flag, void *cb_data)
     -+			  unsigned int unused_flags, void *cb_data)
     ++			  unsigned int flag, void *cb_data)
       {
       	struct handle_one_ref_cb *cb = cb_data;
       	struct commit_list **list = cb->list;
     @@ reachable.c: static void update_progress(struct connectivity_progress *cp)
       
       static int add_one_ref(const char *path, const struct object_id *oid,
      -		       int flag, void *cb_data)
     -+		       unsigned int flags, void *cb_data)
     ++		       unsigned int flag, void *cb_data)
       {
       	struct rev_info *revs = (struct rev_info *)cb_data;
       	struct object *object;
     - 
     --	if ((flag & REF_ISSYMREF) && (flag & REF_ISBROKEN)) {
     -+	if ((flags & REF_ISSYMREF) && (flags & REF_ISBROKEN)) {
     - 		warning("symbolic ref is dangling: %s", path);
     - 		return 0;
     - 	}
      
       ## ref-filter.c ##
      @@ ref-filter.c: struct ref_filter_cbdata {
     @@ ref-filter.c: struct ref_filter_cbdata {
        */
      -static int ref_filter_handler(const char *refname, const struct object_id *oid, int flag, void *cb_data)
      +static int ref_filter_handler(const char *refname, const struct object_id *oid,
     -+			      unsigned int flags, void *cb_data)
     ++			      unsigned int flag, void *cb_data)
       {
       	struct ref_filter_cbdata *ref_cbdata = cb_data;
       	struct ref_filter *filter = ref_cbdata->filter;
     -@@ ref-filter.c: static int ref_filter_handler(const char *refname, const struct object_id *oid,
     - 	struct commit *commit = NULL;
     - 	unsigned int kind;
     - 
     --	if (flag & REF_BAD_NAME) {
     -+	if (flags & REF_BAD_NAME) {
     - 		warning(_("ignoring ref with broken name %s"), refname);
     - 		return 0;
     - 	}
     - 
     --	if (flag & REF_ISBROKEN) {
     -+	if (flags & REF_ISBROKEN) {
     - 		warning(_("ignoring broken ref %s"), refname);
     - 		return 0;
     - 	}
     -@@ ref-filter.c: static int ref_filter_handler(const char *refname, const struct object_id *oid,
     - 	 */
     - 	ref = ref_array_push(ref_cbdata->array, refname, oid);
     - 	ref->commit = commit;
     --	ref->flag = flag;
     -+	ref->flag = flags;
     - 	ref->kind = kind;
     - 
     - 	return 0;
      
       ## refs.c ##
      @@ refs.c: static unsigned char refname_disposition[256] = {
     @@ refs.c: int ref_resolves_to_object(const char *refname,
      +			  unsigned int *flags)
       {
       	const char *result;
     - 	int ignore_errno;
     + 
      @@ refs.c: char *refs_resolve_refdup(struct ref_store *refs,
       	return xstrdup_or_null(result);
       }
     @@ refs.c: struct ref_filter {
      +int read_ref_full(const char *refname, unsigned int resolve_flags,
      +		  struct object_id *oid, unsigned int *flags)
       {
     - 	int ignore_errno;
       	struct ref_store *refs = get_main_ref_store(the_repository);
     + 
      @@ refs.c: int ref_exists(const char *refname)
       }
       
     @@ refs.c: int head_ref_namespaced(each_ref_fn fn, void *cb_data)
       	int ret = 0;
       	struct object_id oid;
      -	int flag;
     -+	unsigned int flags;
     ++	unsigned int flag;
       
       	strbuf_addf(&buf, "%sHEAD", get_git_namespace());
     --	if (!read_ref_full(buf.buf, RESOLVE_REF_READING, &oid, &flag))
     --		ret = fn(buf.buf, &oid, flag, cb_data);
     -+	if (!read_ref_full(buf.buf, RESOLVE_REF_READING, &oid, &flags))
     -+		ret = fn(buf.buf, &oid, flags, cb_data);
     - 	strbuf_release(&buf);
     - 
     - 	return ret;
     + 	if (!read_ref_full(buf.buf, RESOLVE_REF_READING, &oid, &flag))
      @@ refs.c: int expand_ref(struct repository *repo, const char *str, int len,
       	for (p = ref_rev_parse_rules; *p; p++) {
       		struct object_id oid_from_ref;
       		struct object_id *this_result;
      -		int flag;
     -+		unsigned int flags;
     ++		unsigned int flag;
       		struct ref_store *refs = get_main_ref_store(repo);
     - 		int ignore_errno;
       
     -@@ refs.c: int expand_ref(struct repository *repo, const char *str, int len,
     - 		strbuf_reset(&fullref);
     - 		strbuf_addf(&fullref, *p, len, str);
     - 		r = refs_resolve_ref_unsafe(refs, fullref.buf,
     --					    RESOLVE_REF_READING,
     --					    this_result, &flag,
     --					    &ignore_errno);
     -+					    RESOLVE_REF_READING, this_result,
     -+					    &flags, &ignore_errno);
     - 		if (r) {
     - 			if (!refs_found++)
     - 				*ref = xstrdup(r);
     - 			if (!warn_ambiguous_refs)
     - 				break;
     --		} else if ((flag & REF_ISSYMREF) && strcmp(fullref.buf, "HEAD")) {
     -+		} else if ((flags & REF_ISSYMREF) &&
     -+			   strcmp(fullref.buf, "HEAD")) {
     - 			warning(_("ignoring dangling symref %s"), fullref.buf);
     --		} else if ((flag & REF_ISBROKEN) && strchr(fullref.buf, '/')) {
     -+		} else if ((flags & REF_ISBROKEN) && strchr(fullref.buf, '/')) {
     - 			warning(_("ignoring broken ref %s"), fullref.buf);
     - 		}
     - 	}
     + 		this_result = refs_found ? &oid_from_ref : oid;
      @@ refs.c: const char *find_descendant_ref(const char *dirname,
       int refs_head_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
       {
       	struct object_id oid;
      -	int flag;
     -+	unsigned int flags;
     - 	int ignore_errno;
     - 
     --	if (refs_resolve_ref_unsafe(refs, "HEAD", RESOLVE_REF_READING,
     --				    &oid, &flag, &ignore_errno))
     --		return fn("HEAD", &oid, flag, cb_data);
     -+	if (refs_resolve_ref_unsafe(refs, "HEAD", RESOLVE_REF_READING, &oid,
     -+				    &flags, &ignore_errno))
     -+		return fn("HEAD", &oid, flags, cb_data);
     ++	unsigned int flag;
       
     - 	return 0;
     - }
     + 	if (refs_resolve_ref_unsafe(refs, "HEAD", RESOLVE_REF_READING,
     + 				    &oid, &flag))
      @@ refs.c: struct do_for_each_ref_help {
       	void *cb_data;
       };
     @@ refs.c: int refs_read_raw_ref(struct ref_store *ref_store, const char *refname,
      -				    const char *refname,
      -				    int resolve_flags,
      -				    struct object_id *oid,
     --				    int *flags, int *failure_errno)
     +-				    int *flags)
      +const char *refs_resolve_ref_unsafe(struct ref_store *refs, const char *refname,
      +				    unsigned int resolve_flags,
     -+				    struct object_id *oid, unsigned int *flags,
     -+				    int *failure_errno)
     ++				    struct object_id *oid, unsigned int *flags)
       {
       	static struct strbuf sb_refname = STRBUF_INIT;
       	struct object_id unused_oid;
     @@ refs.c: int refs_read_raw_ref(struct ref_store *ref_store, const char *refname,
      +	unsigned int unused_flags;
       	int symref_count;
       
     - 	assert(failure_errno);
     + 	if (!oid)
      @@ refs.c: int refs_init_db(struct strbuf *err)
       	return refs->be->init_db(refs, err);
       }
     @@ refs.c: int refs_init_db(struct strbuf *err)
      +const char *resolve_ref_unsafe(const char *refname, unsigned int resolve_flags,
      +			       struct object_id *oid, unsigned int *flags)
       {
     - 	int ignore_errno;
     - 
     + 	return refs_resolve_ref_unsafe(get_main_ref_store(the_repository), refname,
     + 				       resolve_flags, oid, flags);
      @@ refs.c: int resolve_gitlink_ref(const char *submodule, const char *refname,
       			struct object_id *oid)
       {
       	struct ref_store *refs;
      -	int flags;
     -+	unsigned int unused_flags;
     - 	int ignore_errno;
     ++	unsigned int flags;
       
       	refs = get_submodule_ref_store(submodule);
     -@@ refs.c: int resolve_gitlink_ref(const char *submodule, const char *refname,
     - 	if (!refs)
     - 		return -1;
       
     --	if (!refs_resolve_ref_unsafe(refs, refname, 0, oid, &flags,
     --				     &ignore_errno) || is_null_oid(oid))
     -+	if (!refs_resolve_ref_unsafe(refs, refname, 0, oid, &unused_flags,
     -+				     &ignore_errno) ||
     -+	    is_null_oid(oid))
     - 		return -1;
     - 	return 0;
     - }
      
       ## refs.h ##
      @@ refs.h: struct worktree;
     @@ refs.h: struct worktree;
      -				    const char *refname,
      -				    int resolve_flags,
      -				    struct object_id *oid,
     --				    int *flags, int *failure_errno);
     +-				    int *flags);
      -
      -const char *resolve_ref_unsafe(const char *refname, int resolve_flags,
      -			       struct object_id *oid, int *flags);
     @@ refs.h: struct worktree;
      -		  struct object_id *oid, int *flags);
      +const char *refs_resolve_ref_unsafe(struct ref_store *refs, const char *refname,
      +				    unsigned int resolve_flags,
     -+				    struct object_id *oid, unsigned int *flags,
     -+				    int *failure_errno);
     ++				    struct object_id *oid, unsigned int *flags);
      +
      +const char *resolve_ref_unsafe(const char *refname, unsigned int resolve_flags,
      +			       struct object_id *oid, unsigned int *flags);
     @@ refs/files-backend.c: static void loose_fill_ref_dir(struct ref_store *ref_store
       		struct object_id oid;
       		struct stat st;
      -		int flag;
     ++		unsigned int flag;
       
       		if (de->d_name[0] == '.')
       			continue;
     -@@ refs/files-backend.c: static void loose_fill_ref_dir(struct ref_store *ref_store,
     - 							  refname.len));
     - 		} else {
     - 			int ignore_errno;
     --			if (!refs_resolve_ref_unsafe(&refs->base,
     --						     refname.buf,
     --						     RESOLVE_REF_READING,
     --						     &oid, &flag, &ignore_errno)) {
     -+			unsigned int flags;
     -+			if (!refs_resolve_ref_unsafe(&refs->base, refname.buf,
     -+						     RESOLVE_REF_READING, &oid,
     -+						     &flags, &ignore_errno)) {
     - 				oidclr(&oid);
     --				flag |= REF_ISBROKEN;
     -+				flags |= REF_ISBROKEN;
     - 			} else if (is_null_oid(&oid)) {
     - 				/*
     - 				 * It is so astronomically unlikely
     -@@ refs/files-backend.c: static void loose_fill_ref_dir(struct ref_store *ref_store,
     - 				 * file to be repo corruption
     - 				 * (probably due to a software bug).
     - 				 */
     --				flag |= REF_ISBROKEN;
     -+				flags |= REF_ISBROKEN;
     - 			}
     - 
     - 			if (check_refname_format(refname.buf,
     -@@ refs/files-backend.c: static void loose_fill_ref_dir(struct ref_store *ref_store,
     - 				if (!refname_is_safe(refname.buf))
     - 					die("loose refname is dangerous: %s", refname.buf);
     - 				oidclr(&oid);
     --				flag |= REF_BAD_NAME | REF_ISBROKEN;
     -+				flags |= REF_BAD_NAME | REF_ISBROKEN;
     - 			}
     --			add_entry_to_dir(dir,
     --					 create_ref_entry(refname.buf, &oid, flag));
     -+			add_entry_to_dir(dir, create_ref_entry(refname.buf,
     -+							       &oid, flags));
     - 		}
     - 		strbuf_setlen(&refname, dirnamelen);
     - 		strbuf_setlen(&path, path_baselen);
      @@ refs/files-backend.c: static int files_copy_or_rename_ref(struct ref_store *ref_store,
       	struct files_ref_store *refs =
       		files_downcast(ref_store, REF_STORE_WRITE, "rename_ref");
       	struct object_id orig_oid;
      -	int flag = 0, logmoved = 0;
      +	int logmoved = 0;
     -+	unsigned int flags = 0;
     ++	unsigned int flag = 0;
       	struct ref_lock *lock;
       	struct stat loginfo;
       	struct strbuf sb_oldref = STRBUF_INIT;
     -@@ refs/files-backend.c: static int files_copy_or_rename_ref(struct ref_store *ref_store,
     - 	}
     - 
     - 	if (!refs_resolve_ref_unsafe(&refs->base, oldrefname,
     --				     RESOLVE_REF_READING | RESOLVE_REF_NO_RECURSE,
     --				     &orig_oid, &flag, &ignore_errno)) {
     -+				     RESOLVE_REF_READING |
     -+					     RESOLVE_REF_NO_RECURSE,
     -+				     &orig_oid, &flags, &ignore_errno)) {
     - 		ret = error("refname %s not found", oldrefname);
     - 		goto out;
     - 	}
     - 
     --	if (flag & REF_ISSYMREF) {
     -+	if (flags & REF_ISSYMREF) {
     - 		if (copy)
     - 			ret = error("refname %s is a symbolic ref, copying it is not supported",
     - 				    oldrefname);
     -@@ refs/files-backend.c: static int files_copy_or_rename_ref(struct ref_store *ref_store,
     - 		goto rollbacklog;
     - 	}
     - 
     --	flag = log_all_ref_updates;
     -+	flags = log_all_ref_updates;
     - 	log_all_ref_updates = LOG_REFS_NONE;
     - 	if (write_ref_to_lockfile(lock, &orig_oid, 0, &err) ||
     - 	    commit_ref_update(refs, lock, &orig_oid, NULL, &err)) {
     - 		error("unable to write current sha1 into %s: %s", oldrefname, err.buf);
     - 		strbuf_release(&err);
     - 	}
     --	log_all_ref_updates = flag;
     -+	log_all_ref_updates = flags;
     - 
     -  rollbacklog:
     - 	if (logmoved && rename(sb_newref.buf, sb_oldref.buf))
     -@@ refs/files-backend.c: static int log_ref_write_fd(int fd, const struct object_id *old_oid,
     - }
     - 
     - static int files_log_ref_write(struct files_ref_store *refs,
     --			       const char *refname, const struct object_id *old_oid,
     -+			       const char *refname,
     -+			       const struct object_id *old_oid,
     - 			       const struct object_id *new_oid, const char *msg,
     --			       int flags, struct strbuf *err)
     -+			       unsigned int flags, struct strbuf *err)
     - {
     - 	int logfd, result;
     - 
      @@ refs/files-backend.c: static int commit_ref_update(struct files_ref_store *refs,
       		 * check with HEAD only which should cover 99% of all usage
       		 * scenarios (even 100% of the default ones).
       		 */
      -		int head_flag;
     -+		unsigned int head_flags;
     ++		unsigned int head_flag;
       		const char *head_ref;
     - 		int ignore_errno;
       
       		head_ref = refs_resolve_ref_unsafe(&refs->base, "HEAD",
     --						   RESOLVE_REF_READING,
     --						   NULL, &head_flag,
     --						   &ignore_errno);
     --		if (head_ref && (head_flag & REF_ISSYMREF) &&
     -+						   RESOLVE_REF_READING, NULL,
     -+						   &head_flags, &ignore_errno);
     -+		if (head_ref && (head_flags & REF_ISSYMREF) &&
     - 		    !strcmp(head_ref, lock->ref_name)) {
     - 			struct strbuf log_err = STRBUF_INIT;
     - 			if (files_log_ref_write(refs, "HEAD",
      @@ refs/files-backend.c: static int files_reflog_iterator_advance(struct ref_iterator *ref_iterator)
     - 	int ignore_errno;
     + 	int ok;
       
       	while ((ok = dir_iterator_advance(diter)) == ITER_OK) {
      -		int flags;
     @@ refs/files-backend.c: static int files_transaction_abort(struct ref_store *ref_s
      -static int ref_present(const char *refname,
      -		       const struct object_id *oid, int flags, void *cb_data)
      +static int ref_present(const char *refname, const struct object_id *oid,
     -+		       unsigned int unused_flags, void *cb_data)
     ++		       unsigned int flags, void *cb_data)
       {
       	struct string_list *affected_refnames = cb_data;
       
      @@ refs/files-backend.c: static int files_reflog_expire(struct ref_store *ref_store,
     + 
       		if ((expire_flags & EXPIRE_REFLOGS_UPDATE_REF) &&
       		    !is_null_oid(&cb.last_kept_oid)) {
     - 			int ignore_errno;
      -			int type;
      +			unsigned int type;
       			const char *ref;
     @@ remote.c: static void alias_all_urls(struct remote_state *remote_state)
       static void read_config(struct repository *repo)
       {
      -	int flag;
     -+	unsigned int flags;
     ++	unsigned int flag;
       
       	if (repo->remote_state->initialized)
       		return;
     -@@ remote.c: static void read_config(struct repository *repo)
     - 	if (startup_info->have_repository) {
     - 		int ignore_errno;
     - 		const char *head_ref = refs_resolve_ref_unsafe(
     --			get_main_ref_store(repo), "HEAD", 0, NULL, &flag, &ignore_errno);
     --		if (head_ref && (flag & REF_ISSYMREF) &&
     -+			get_main_ref_store(repo), "HEAD", 0, NULL, &flags,
     -+			&ignore_errno);
     -+		if (head_ref && (flags & REF_ISSYMREF) &&
     - 		    skip_prefix(head_ref, "refs/heads/", &head_ref)) {
     - 			repo->remote_state->current_branch = make_branch(
     - 				repo->remote_state, head_ref, strlen(head_ref));
      @@ remote.c: static int match_explicit(struct ref *src, struct ref *dst,
       		return -1;
       
       	if (!dst_value) {
      -		int flag;
     --
     --		dst_value = resolve_ref_unsafe(matched_src->name,
     --					       RESOLVE_REF_READING,
     --					       NULL, &flag);
     --		if (!dst_value ||
     --		    ((flag & REF_ISSYMREF) &&
     --		     !starts_with(dst_value, "refs/heads/")))
     -+		unsigned int flags;
     -+
     -+		dst_value = resolve_ref_unsafe(
     -+			matched_src->name, RESOLVE_REF_READING, NULL, &flags);
     -+		if (!dst_value || ((flags & REF_ISSYMREF) &&
     -+				   !starts_with(dst_value, "refs/heads/")))
     - 			die(_("%s cannot be resolved to branch"),
     - 			    matched_src->name);
     - 	}
     ++		unsigned int flag;
     + 
     + 		dst_value = resolve_ref_unsafe(matched_src->name,
     + 					       RESOLVE_REF_READING,
      @@ remote.c: const char *branch_get_push(struct branch *branch, struct strbuf *err)
       
       static int ignore_symref_update(const char *refname)
       {
      -	int flag;
     -+	unsigned int flags;
     ++	unsigned int flag;
       
     --	if (!resolve_ref_unsafe(refname, 0, NULL, &flag))
     -+	if (!resolve_ref_unsafe(refname, 0, NULL, &flags))
     + 	if (!resolve_ref_unsafe(refname, 0, NULL, &flag))
       		return 0; /* non-existing refs are OK */
     --	return (flag & REF_ISSYMREF);
     -+	return (flags & REF_ISSYMREF);
     - }
     - 
     - /*
      @@ remote.c: int format_tracking_info(struct branch *branch, struct strbuf *sb,
       }
       
     @@ replace-object.c
       
      -static int register_replace_ref(struct repository *r,
      -				const char *refname,
     -+static int register_replace_ref(struct repository *r, const char *refname,
     - 				const struct object_id *oid,
     +-				const struct object_id *oid,
      -				int flag, void *cb_data)
     -+				unsigned int unused_flags, void *cb_data)
     ++static int register_replace_ref(struct repository *r, const char *refname,
     ++				const struct object_id *oid, unsigned int flag,
     ++				void *cb_data)
       {
       	/* Get sha1 from refname */
       	const char *slash = strrchr(refname, '/');
     @@ revision.c: int ref_excluded(struct string_list *ref_excludes, const char *path)
       
       static int handle_one_ref(const char *path, const struct object_id *oid,
      -			  int flag, void *cb_data)
     -+			  unsigned int unused_flags, void *cb_data)
     ++			  unsigned int flag, void *cb_data)
       {
       	struct all_refs_cb *cb = cb_data;
       	struct object *object;
      @@ revision.c: static int handle_one_reflog_ent(struct object_id *ooid, struct object_id *noid,
     + }
       
       static int handle_one_reflog(const char *refname_in_wt,
     - 			     const struct object_id *oid,
     +-			     const struct object_id *oid,
      -			     int flag, void *cb_data)
     -+			     unsigned int unused_flags, void *cb_data)
     ++			     const struct object_id *oid, unsigned int flag,
     ++			     void *cb_data)
       {
       	struct all_refs_cb *cb = cb_data;
       	struct strbuf refname = STRBUF_INIT;
     @@ server-info.c: out:
       
       static int add_info_ref(const char *path, const struct object_id *oid,
      -			int flag, void *cb_data)
     -+			unsigned int unused_flags, void *cb_data)
     ++			unsigned int flag, void *cb_data)
       {
       	struct update_info_ctx *uic = cb_data;
       	struct object *o = parse_object(the_repository, oid);
     @@ shallow.c: static void paint_down(struct paint_info *info, const struct object_i
       
       static int mark_uninteresting(const char *refname, const struct object_id *oid,
      -			      int flags, void *cb_data)
     -+			      unsigned int unused_flags, void *cb_data)
     ++			      unsigned int flags, void *cb_data)
       {
       	struct commit *commit = lookup_commit_reference_gently(the_repository,
       							       oid, 1);
     @@ shallow.c: struct commit_array {
       
       static int add_ref(const char *refname, const struct object_id *oid,
      -		   int flags, void *cb_data)
     -+		   unsigned int unused_flags, void *cb_data)
     ++		   unsigned int flags, void *cb_data)
       {
       	struct commit_array *ca = cb_data;
       	ALLOC_GROW(ca->commits, ca->nr + 1, ca->alloc);
     @@ submodule.c: static void free_submodules_oids(struct string_list *submodules)
       
       static int has_remote(const char *refname, const struct object_id *oid,
      -		      int flags, void *cb_data)
     -+		      unsigned int unused_flags, void *cb_data)
     ++		      unsigned int flags, void *cb_data)
       {
       	return 1;
       }
     @@ submodule.c: int push_unpushed_submodules(struct repository *r,
       
       static int append_oid_to_array(const char *ref, const struct object_id *oid,
      -			       int flags, void *data)
     -+			       unsigned int unused_flags, void *data)
     ++			       unsigned int flags, void *data)
       {
       	struct oid_array *array = data;
       	oid_array_append(array, oid);
     @@ t/helper/test-ref-store.c: static int cmd_resolve_ref(struct ref_store *refs, co
      -	int flags;
      +	unsigned int flags;
       	const char *ref;
     - 	int ignore_errno;
       
     + 	ref = refs_resolve_ref_unsafe(refs, refname, resolve_flags,
      
       ## transport-helper.c ##
      @@ transport-helper.c: static int push_refs_with_export(struct transport *transport,
     @@ transport-helper.c: static int push_refs_with_export(struct transport *transport
       				if (!ref->deletion) {
       					const char *name;
      -					int flag;
     -+					unsigned int ref_flags;
     ++					unsigned int flag;
       
       					/* Follow symbolic refs (mainly for HEAD). */
     --					name = resolve_ref_unsafe(ref->peer_ref->name,
     --								  RESOLVE_REF_READING,
     --								  &oid, &flag);
     --					if (!name || !(flag & REF_ISSYMREF))
     -+					name = resolve_ref_unsafe(
     -+						ref->peer_ref->name,
     -+						RESOLVE_REF_READING, &oid,
     -+						&ref_flags);
     -+					if (!name ||
     -+					    !(ref_flags & REF_ISSYMREF))
     - 						name = ref->peer_ref->name;
     - 
     - 					strbuf_addf(&buf, "%s:%s", name, ref->name);
     + 					name = resolve_ref_unsafe(ref->peer_ref->name,
      
       ## transport.c ##
      @@ transport.c: static void set_upstreams(struct transport *transport, struct ref *refs,
     @@ transport.c: static void set_upstreams(struct transport *transport, struct ref *
       		const char *tmp;
       		const char *remotename;
      -		int flag = 0;
     -+		unsigned int ref_flags = 0;
     ++		unsigned int flag = 0;
       		/*
       		 * Check suitability for tracking. Must be successful /
       		 * already up-to-date ref create/modify (not delete).
     -@@ transport.c: static void set_upstreams(struct transport *transport, struct ref *refs,
     - 		/* Follow symbolic refs (mainly for HEAD). */
     - 		localname = ref->peer_ref->name;
     - 		remotename = ref->name;
     --		tmp = resolve_ref_unsafe(localname, RESOLVE_REF_READING,
     --					 NULL, &flag);
     --		if (tmp && flag & REF_ISSYMREF &&
     --			starts_with(tmp, "refs/heads/"))
     -+		tmp = resolve_ref_unsafe(localname, RESOLVE_REF_READING, NULL,
     -+					 &ref_flags);
     -+		if (tmp && ref_flags & REF_ISSYMREF &&
     -+		    starts_with(tmp, "refs/heads/"))
     - 			localname = tmp;
     - 
     - 		/* Both source and destination must be local branches. */
      
       ## upload-pack.c ##
      @@ upload-pack.c: static void send_unshallow(struct upload_pack_data *data)
     @@ upload-pack.c: static int mark_our_ref(const char *refname, const char *refname_
       
       static int check_ref(const char *refname_full, const struct object_id *oid,
      -		     int flag, void *cb_data)
     -+		     unsigned int unused_flags, void *cb_data)
     ++		     unsigned int flag, void *cb_data)
       {
       	const char *refname = strip_namespace(refname_full);
       
     @@ upload-pack.c: static void format_session_id(struct strbuf *buf, struct upload_p
       
       static int send_ref(const char *refname, const struct object_id *oid,
      -		    int flag, void *cb_data)
     -+		    unsigned int unused_flags, void *cb_data)
     ++		    unsigned int flag, void *cb_data)
       {
       	static const char *capabilities = "multi_ack thin-pack side-band"
       		" side-band-64k ofs-delta shallow deepen-since deepen-not"
     @@ upload-pack.c: static int send_ref(const char *refname, const struct object_id *
       
       static int find_symref(const char *refname, const struct object_id *oid,
      -		       int flag, void *cb_data)
     -+		       unsigned int flags, void *cb_data)
     ++		       unsigned int flag, void *cb_data)
       {
       	const char *symref_target;
       	struct string_list_item *item;
     - 
     --	if ((flag & REF_ISSYMREF) == 0)
     -+	if ((flags & REF_ISSYMREF) == 0)
     - 		return 0;
     --	symref_target = resolve_ref_unsafe(refname, 0, NULL, &flag);
     --	if (!symref_target || (flag & REF_ISSYMREF) == 0)
     -+	symref_target = resolve_ref_unsafe(refname, 0, NULL, &flags);
     -+	if (!symref_target || (flags & REF_ISSYMREF) == 0)
     - 		die("'%s' is a symref but it is not?", refname);
     - 	item = string_list_append(cb_data, strip_namespace(refname));
     - 	item->util = xstrdup(strip_namespace(symref_target));
      
       ## walker.c ##
      @@ walker.c: static int interpret_target(struct walker *walker, char *target, struct object_i
     @@ walker.c: static int interpret_target(struct walker *walker, char *target, struc
       
       static int mark_complete(const char *path, const struct object_id *oid,
      -			 int flag, void *cb_data)
     -+			 unsigned int unused_flags, void *cb_data)
     ++			 unsigned int flag, void *cb_data)
       {
       	struct commit *commit = lookup_commit_reference_gently(the_repository,
       							       oid, 1);
     @@ worktree.c: void free_worktrees(struct worktree **worktrees)
      -	int flags;
      +	unsigned int flags;
       	const char *target;
     - 	int ignore_errno;
       
     + 	target = refs_resolve_ref_unsafe(get_worktree_ref_store(wt),
      @@ worktree.c: const struct worktree *find_shared_symref(struct worktree **worktrees,
       		struct worktree *wt = worktrees[i];
       		const char *symref_target;
       		struct ref_store *refs;
      -		int flags;
      +		unsigned int flags;
     - 		int ignore_errno;
       
       		if (wt->is_bare)
     + 			continue;
      @@ worktree.c: int other_head_refs(each_ref_fn fn, void *cb_data)
       	for (p = worktrees; *p; p++) {
       		struct worktree *wt = *p;
       		struct object_id oid;
      -		int flag;
     -+		unsigned int flags;
     - 		int ignore_errno;
     ++		unsigned int flag;
       
       		if (wt->is_current)
     -@@ worktree.c: int other_head_refs(each_ref_fn fn, void *cb_data)
     - 		strbuf_reset(&refname);
     - 		strbuf_worktree_ref(wt, &refname, "HEAD");
     - 		if (refs_resolve_ref_unsafe(get_main_ref_store(the_repository),
     --					    refname.buf,
     --					    RESOLVE_REF_READING,
     --					    &oid, &flag, &ignore_errno))
     --			ret = fn(refname.buf, &oid, flag, cb_data);
     -+					    refname.buf, RESOLVE_REF_READING,
     -+					    &oid, &flags, &ignore_errno))
     -+			ret = fn(refname.buf, &oid, flags, cb_data);
     - 		if (ret)
     - 			break;
     - 	}
     + 			continue;
 -:  ----------- > 2:  e94a923a647 Uniformize flag argument naming to `flags` or `unused_flags`

-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v3 1/2] refs.h: make all flags arguments unsigned
  2022-02-03 14:26   ` [PATCH v3 0/2] " Han-Wen Nienhuys via GitGitGadget
@ 2022-02-03 14:26     ` Han-Wen Nienhuys via GitGitGadget
  2022-02-03 14:26     ` [PATCH v3 2/2] Uniformize flag argument naming to `flags` or `unused_flags` Han-Wen Nienhuys via GitGitGadget
  1 sibling, 0 replies; 17+ messages in thread
From: Han-Wen Nienhuys via GitGitGadget @ 2022-02-03 14:26 UTC (permalink / raw)
  To: git
  Cc: Han-Wen Nienhuys, Ævar Arnfjörð Bjarmason,
	Han-Wen Nienhuys, Han-Wen Nienhuys

From: Han-Wen Nienhuys <hanwen@google.com>

As discussed in
https://lore.kernel.org/git/xmqqbkzrkevo.fsf@gitster.g/ , we don't
want to treat the sign bit specially, so make all flags in refs.h
unsigned.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
---
 bisect.c                    |  4 +--
 builtin/bisect--helper.c    |  7 ++---
 builtin/branch.c            |  4 +--
 builtin/checkout.c          |  9 ++++---
 builtin/describe.c          |  3 ++-
 builtin/fetch.c             | 10 +++----
 builtin/fsck.c              |  4 +--
 builtin/gc.c                |  5 ++--
 builtin/name-rev.c          |  3 ++-
 builtin/pack-objects.c      | 11 ++++----
 builtin/rebase.c            |  5 ++--
 builtin/receive-pack.c      |  4 +--
 builtin/reflog.c            |  5 ++--
 builtin/remote.c            | 13 +++++----
 builtin/repack.c            |  4 +--
 builtin/replace.c           |  4 +--
 builtin/rev-parse.c         |  6 +++--
 builtin/show-branch.c       |  6 ++---
 builtin/show-ref.c          |  4 +--
 builtin/stash.c             |  2 +-
 builtin/submodule--helper.c |  4 +--
 builtin/symbolic-ref.c      |  2 +-
 bundle.c                    |  2 +-
 commit-graph.c              |  5 ++--
 config.c                    |  2 +-
 delta-islands.c             |  2 +-
 fetch-pack.c                |  7 ++---
 help.c                      |  2 +-
 http-backend.c              |  4 +--
 log-tree.c                  |  4 +--
 ls-refs.c                   |  4 +--
 midx.c                      |  5 ++--
 negotiator/default.c        |  2 +-
 negotiator/skipping.c       |  2 +-
 notes.c                     |  5 ++--
 object-name.c               |  2 +-
 reachable.c                 |  2 +-
 ref-filter.c                |  3 ++-
 refs.c                      | 54 ++++++++++++++++++-------------------
 refs.h                      | 46 +++++++++++++++----------------
 refs/files-backend.c        | 17 ++++++------
 remote.c                    | 10 +++----
 replace-object.c            |  7 +++--
 revision.c                  |  8 +++---
 server-info.c               |  2 +-
 shallow.c                   |  4 +--
 submodule.c                 |  4 +--
 t/helper/test-ref-store.c   |  4 +--
 transport-helper.c          |  2 +-
 transport.c                 |  2 +-
 upload-pack.c               |  8 +++---
 walker.c                    |  2 +-
 worktree.c                  |  6 ++---
 53 files changed, 176 insertions(+), 172 deletions(-)

diff --git a/bisect.c b/bisect.c
index 9e6a2b7f201..44af2081987 100644
--- a/bisect.c
+++ b/bisect.c
@@ -441,7 +441,7 @@ void find_bisection(struct commit_list **commit_list, int *reaches,
 }
 
 static int register_ref(const char *refname, const struct object_id *oid,
-			int flags, void *cb_data)
+			unsigned int flags, void *cb_data)
 {
 	struct strbuf good_prefix = STRBUF_INIT;
 	strbuf_addstr(&good_prefix, term_good);
@@ -1147,7 +1147,7 @@ int estimate_bisect_steps(int all)
 }
 
 static int mark_for_removal(const char *refname, const struct object_id *oid,
-			    int flag, void *cb_data)
+			    unsigned int flag, void *cb_data)
 {
 	struct string_list *refs = cb_data;
 	char *ref = xstrfmt("refs/bisect%s", refname);
diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c
index 36143ac0261..e8b0c049f34 100644
--- a/builtin/bisect--helper.c
+++ b/builtin/bisect--helper.c
@@ -330,7 +330,7 @@ static int check_and_set_terms(struct bisect_terms *terms, const char *cmd)
 }
 
 static int mark_good(const char *refname, const struct object_id *oid,
-		     int flag, void *cb_data)
+		     unsigned int flag, void *cb_data)
 {
 	int *m_good = (int *)cb_data;
 	*m_good = 0;
@@ -477,7 +477,7 @@ finish:
 }
 
 static int add_bisect_ref(const char *refname, const struct object_id *oid,
-			  int flags, void *cb)
+			  unsigned int flags, void *cb)
 {
 	struct add_bisect_ref_data *data = cb;
 
@@ -617,7 +617,8 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, const char **a
 	int no_checkout = 0;
 	int first_parent_only = 0;
 	int i, has_double_dash = 0, must_write_terms = 0, bad_seen = 0;
-	int flags, pathspec_pos;
+	int pathspec_pos;
+	unsigned int flags;
 	enum bisect_error res = BISECT_OK;
 	struct string_list revs = STRING_LIST_INIT_DUP;
 	struct string_list states = STRING_LIST_INIT_DUP;
diff --git a/builtin/branch.c b/builtin/branch.c
index 5d00d0b8d32..623ace2f917 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -246,7 +246,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
 
 	for (i = 0; i < argc; i++, strbuf_reset(&bname)) {
 		char *target = NULL;
-		int flags = 0;
+		unsigned int flags = 0;
 
 		strbuf_branchname(&bname, argv[i], allowed_interpret);
 		free(name);
@@ -481,7 +481,7 @@ static void print_ref_list(struct ref_filter *filter, struct ref_sorting *sortin
 
 static void print_current_branch_name(void)
 {
-	int flags;
+	unsigned int flags;
 	const char *refname = resolve_ref_unsafe("HEAD", 0, NULL, &flags);
 	const char *shortname;
 	if (!refname)
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 24c85157ae9..742c4ac2ab7 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -974,7 +974,7 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
 
 static int add_pending_uninteresting_ref(const char *refname,
 					 const struct object_id *oid,
-					 int flags, void *cb_data)
+					 unsigned int flags, void *cb_data)
 {
 	add_pending_oid(cb_data, refname, oid, UNINTERESTING);
 	return 0;
@@ -1083,7 +1083,8 @@ static int switch_branches(const struct checkout_opts *opts,
 	int ret = 0;
 	struct branch_info old_branch_info = { 0 };
 	struct object_id rev;
-	int flag, writeout_error = 0;
+	int writeout_error = 0;
+	unsigned int flag;
 	int do_merge = 1;
 
 	trace2_cmd_mode("branch");
@@ -1509,7 +1510,7 @@ static int checkout_branch(struct checkout_opts *opts,
 
 	if (new_branch_info->path && !opts->force_detach && !opts->new_branch &&
 	    !opts->ignore_other_worktrees) {
-		int flag;
+		unsigned int flag;
 		char *head_ref = resolve_refdup("HEAD", 0, NULL, &flag);
 		if (head_ref &&
 		    (!(flag & REF_ISSYMREF) || strcmp(head_ref, new_branch_info->path)))
@@ -1519,7 +1520,7 @@ static int checkout_branch(struct checkout_opts *opts,
 
 	if (!new_branch_info->commit && opts->new_branch) {
 		struct object_id rev;
-		int flag;
+		unsigned int flag;
 
 		if (!read_ref_full("HEAD", 0, &rev, &flag) &&
 		    (flag & REF_ISSYMREF) && is_null_oid(&rev))
diff --git a/builtin/describe.c b/builtin/describe.c
index 42159cd26bd..5fa5b0bb424 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -140,7 +140,8 @@ static void add_to_known_names(const char *path,
 	}
 }
 
-static int get_name(const char *path, const struct object_id *oid, int flag, void *cb_data)
+static int get_name(const char *path, const struct object_id *oid,
+		    unsigned int flag, void *cb_data)
 {
 	int is_tag = 0;
 	struct object_id peeled;
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 911c9fa0905..0d2eab174c4 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -324,9 +324,8 @@ static struct refname_hash_entry *refname_hash_add(struct hashmap *map,
 	return ent;
 }
 
-static int add_one_refname(const char *refname,
-			   const struct object_id *oid,
-			   int flag, void *cbdata)
+static int add_one_refname(const char *refname, const struct object_id *oid,
+			   unsigned int flag, void *cbdata)
 {
 	struct hashmap *refname_map = cbdata;
 
@@ -1430,9 +1429,8 @@ static void set_option(struct transport *transport, const char *name, const char
 			name, transport->url);
 }
 
-
-static int add_oid(const char *refname, const struct object_id *oid, int flags,
-		   void *cb_data)
+static int add_oid(const char *refname, const struct object_id *oid,
+		   unsigned int flags, void *cb_data)
 {
 	struct oid_array *oids = cb_data;
 
diff --git a/builtin/fsck.c b/builtin/fsck.c
index 9e54892311d..8e3f773e3dd 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -502,7 +502,7 @@ static int fsck_handle_reflog_ent(struct object_id *ooid, struct object_id *noid
 }
 
 static int fsck_handle_reflog(const char *logname, const struct object_id *oid,
-			      int flag, void *cb_data)
+			      unsigned int flag, void *cb_data)
 {
 	struct strbuf refname = STRBUF_INIT;
 
@@ -513,7 +513,7 @@ static int fsck_handle_reflog(const char *logname, const struct object_id *oid,
 }
 
 static int fsck_handle_ref(const char *refname, const struct object_id *oid,
-			   int flag, void *cb_data)
+			   unsigned int flag, void *cb_data)
 {
 	struct object *obj;
 
diff --git a/builtin/gc.c b/builtin/gc.c
index ffaf0daf5d9..1c045962766 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -769,9 +769,8 @@ struct cg_auto_data {
 	int limit;
 };
 
-static int dfs_on_ref(const char *refname,
-		      const struct object_id *oid, int flags,
-		      void *cb_data)
+static int dfs_on_ref(const char *refname, const struct object_id *oid,
+		      unsigned int flags, void *cb_data)
 {
 	struct cg_auto_data *data = (struct cg_auto_data *)cb_data;
 	int result = 0;
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index 138e3c30a2b..93f622331fb 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -305,7 +305,8 @@ static int cmp_by_tag_and_age(const void *a_, const void *b_)
 	return a->taggerdate != b->taggerdate;
 }
 
-static int name_ref(const char *path, const struct object_id *oid, int flags, void *cb_data)
+static int name_ref(const char *path, const struct object_id *oid,
+		    unsigned int flags, void *cb_data)
 {
 	struct object *o = parse_object(the_repository, oid);
 	struct name_ref_data *data = cb_data;
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 47358ee1a81..7af3cbf9688 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -758,8 +758,8 @@ static enum write_one_status write_one(struct hashfile *f,
 	return WRITE_ONE_WRITTEN;
 }
 
-static int mark_tagged(const char *path, const struct object_id *oid, int flag,
-		       void *cb_data)
+static int mark_tagged(const char *path, const struct object_id *oid,
+		       unsigned int flag, void *cb_data)
 {
 	struct object_id peeled;
 	struct object_entry *entry = packlist_find(&to_pack, oid);
@@ -3012,7 +3012,8 @@ static void add_tag_chain(const struct object_id *oid)
 	}
 }
 
-static int add_ref_tag(const char *tag, const struct object_id *oid, int flag, void *cb_data)
+static int add_ref_tag(const char *tag, const struct object_id *oid,
+		       unsigned int flag, void *cb_data)
 {
 	struct object_id peeled;
 
@@ -3684,8 +3685,8 @@ static void record_recent_commit(struct commit *commit, void *data)
 }
 
 static int mark_bitmap_preferred_tip(const char *refname,
-				     const struct object_id *oid, int flags,
-				     void *_data)
+				     const struct object_id *oid,
+				     unsigned int flags, void *_data)
 {
 	struct object_id peeled;
 	struct object *object;
diff --git a/builtin/rebase.c b/builtin/rebase.c
index b29ad2b65e7..d4015b72610 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -1024,7 +1024,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 {
 	struct rebase_options options = REBASE_OPTIONS_INIT;
 	const char *branch_name;
-	int ret, flags, total_argc, in_progress = 0;
+	int ret, total_argc, in_progress = 0;
+	unsigned int flags;
 	int keep_base = 0;
 	int ok_to_skip_pre_rebase = 0;
 	struct strbuf msg = STRBUF_INIT;
@@ -1695,7 +1696,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 	if (can_fast_forward(options.onto, options.upstream, options.restrict_revision,
 		    &options.orig_head, &merge_base) &&
 	    allow_preemptive_ff) {
-		int flag;
+		unsigned int flag;
 
 		if (!(options.flags & REBASE_FORCE)) {
 			/* Lazily switch to the target branch if needed... */
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index b8a7a69c004..b189487a17b 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -291,7 +291,7 @@ static void show_ref(const char *path, const struct object_id *oid)
 }
 
 static int show_ref_cb(const char *path_full, const struct object_id *oid,
-		       int flag, void *data)
+		       unsigned int flag, void *data)
 {
 	struct oidset *seen = data;
 	const char *path = strip_namespace(path_full);
@@ -1691,7 +1691,7 @@ static void check_aliased_update(struct command *cmd, struct string_list *list)
 {
 	struct strbuf buf = STRBUF_INIT;
 	const char *dst_name;
-	int flag;
+	unsigned int flag;
 
 	strbuf_addf(&buf, "%s%s", get_git_namespace(), cmd->ref_name);
 	dst_name = resolve_ref_unsafe(buf.buf, 0, NULL, &flag);
diff --git a/builtin/reflog.c b/builtin/reflog.c
index c8f2b318731..278e895cc57 100644
--- a/builtin/reflog.c
+++ b/builtin/reflog.c
@@ -335,7 +335,7 @@ static int should_expire_reflog_ent_verbose(struct object_id *ooid,
 }
 
 static int push_tip_to_list(const char *refname, const struct object_id *oid,
-			    int flags, void *cb_data)
+			    unsigned int flags, void *cb_data)
 {
 	struct commit_list **list = cb_data;
 	struct commit *tip_commit;
@@ -416,7 +416,8 @@ static void reflog_expiry_cleanup(void *cb_data)
 	}
 }
 
-static int collect_reflog(const char *ref, const struct object_id *oid, int unused, void *cb_data)
+static int collect_reflog(const char *ref, const struct object_id *oid,
+			  unsigned int unused, void *cb_data)
 {
 	struct worktree_reflogs *cb = cb_data;
 	struct worktree *worktree = cb->worktree;
diff --git a/builtin/remote.c b/builtin/remote.c
index 6f27ddc47bd..92ac729aeab 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -533,7 +533,8 @@ struct branches_for_remote {
 };
 
 static int add_branch_for_removal(const char *refname,
-	const struct object_id *oid, int flags, void *cb_data)
+				  const struct object_id *oid,
+				  unsigned int flags, void *cb_data)
 {
 	struct branches_for_remote *branches = cb_data;
 	struct refspec_item refspec;
@@ -574,12 +575,13 @@ struct rename_info {
 };
 
 static int read_remote_branches(const char *refname,
-	const struct object_id *oid, int flags, void *cb_data)
+				const struct object_id *oid, unsigned int flags,
+				void *cb_data)
 {
 	struct rename_info *rename = cb_data;
 	struct strbuf buf = STRBUF_INIT;
 	struct string_list_item *item;
-	int flag;
+	unsigned int flag;
 	const char *symref;
 
 	strbuf_addf(&buf, "refs/remotes/%s/", rename->old_name);
@@ -766,7 +768,7 @@ static int mv(int argc, const char **argv)
 	for_each_ref(read_remote_branches, &rename);
 	for (i = 0; i < remote_branches.nr; i++) {
 		struct string_list_item *item = remote_branches.items + i;
-		int flag = 0;
+		unsigned int flag = 0;
 
 		read_ref_full(item->string, RESOLVE_REF_READING, NULL, &flag);
 		if (!(flag & REF_ISSYMREF))
@@ -923,7 +925,8 @@ static void free_remote_ref_states(struct ref_states *states)
 }
 
 static int append_ref_to_tracked_list(const char *refname,
-	const struct object_id *oid, int flags, void *cb_data)
+				      const struct object_id *oid,
+				      unsigned int flags, void *cb_data)
 {
 	struct ref_states *states = cb_data;
 	struct refspec_item refspec;
diff --git a/builtin/repack.c b/builtin/repack.c
index da1e364a756..ff6ddc0f357 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -464,8 +464,8 @@ struct midx_snapshot_ref_data {
 };
 
 static int midx_snapshot_ref_one(const char *refname,
-				 const struct object_id *oid,
-				 int flag, void *_data)
+				 const struct object_id *oid, unsigned int flag,
+				 void *_data)
 {
 	struct midx_snapshot_ref_data *data = _data;
 	struct object_id peeled;
diff --git a/builtin/replace.c b/builtin/replace.c
index 5068f4f0b2a..26bc9daba35 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -40,8 +40,8 @@ struct show_data {
 };
 
 static int show_reference(struct repository *r, const char *refname,
-			  const struct object_id *oid,
-			  int flag, void *cb_data)
+			  const struct object_id *oid, unsigned int flag,
+			  void *cb_data)
 {
 	struct show_data *data = cb_data;
 
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 8480a59f573..b842c958f20 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -195,7 +195,8 @@ static int show_default(void)
 	return 0;
 }
 
-static int show_reference(const char *refname, const struct object_id *oid, int flag, void *cb_data)
+static int show_reference(const char *refname, const struct object_id *oid,
+			  unsigned int flag, void *cb_data)
 {
 	if (ref_excluded(ref_excludes, refname))
 		return 0;
@@ -203,7 +204,8 @@ static int show_reference(const char *refname, const struct object_id *oid, int
 	return 0;
 }
 
-static int anti_reference(const char *refname, const struct object_id *oid, int flag, void *cb_data)
+static int anti_reference(const char *refname, const struct object_id *oid,
+			  unsigned int flag, void *cb_data)
 {
 	show_rev(REVERSED, oid, refname);
 	return 0;
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index e12c5e80e3e..625ba0c28ce 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -403,7 +403,7 @@ static int append_ref(const char *refname, const struct object_id *oid,
 }
 
 static int append_head_ref(const char *refname, const struct object_id *oid,
-			   int flag, void *cb_data)
+			   unsigned int flag, void *cb_data)
 {
 	struct object_id tmp;
 	int ofs = 11;
@@ -418,7 +418,7 @@ static int append_head_ref(const char *refname, const struct object_id *oid,
 }
 
 static int append_remote_ref(const char *refname, const struct object_id *oid,
-			     int flag, void *cb_data)
+			     unsigned int flag, void *cb_data)
 {
 	struct object_id tmp;
 	int ofs = 13;
@@ -444,7 +444,7 @@ static const char *match_ref_pattern = NULL;
 static int match_ref_slash = 0;
 
 static int append_matching_ref(const char *refname, const struct object_id *oid,
-			       int flag, void *cb_data)
+			       unsigned int flag, void *cb_data)
 {
 	/* we want to allow pattern hold/<asterisk> to show all
 	 * branches under refs/heads/hold/, and v0.99.9? to show
diff --git a/builtin/show-ref.c b/builtin/show-ref.c
index 7f8a5332f83..09b708daf5b 100644
--- a/builtin/show-ref.c
+++ b/builtin/show-ref.c
@@ -47,7 +47,7 @@ static void show_one(const char *refname, const struct object_id *oid)
 }
 
 static int show_ref(const char *refname, const struct object_id *oid,
-		    int flag, void *cbdata)
+		    unsigned int flag, void *cbdata)
 {
 	if (show_head && !strcmp(refname, "HEAD"))
 		goto match;
@@ -86,7 +86,7 @@ match:
 }
 
 static int add_existing(const char *refname, const struct object_id *oid,
-			int flag, void *cbdata)
+			unsigned int flag, void *cbdata)
 {
 	struct string_list *list = (struct string_list *)cbdata;
 	string_list_insert(list, refname);
diff --git a/builtin/stash.c b/builtin/stash.c
index 5897febfbec..057cab984dd 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -1291,7 +1291,7 @@ static int do_create_stash(const struct pathspec *ps, struct strbuf *stash_msg_b
 			   int quiet)
 {
 	int ret = 0;
-	int flags = 0;
+	unsigned int flags = 0;
 	int untracked_commit_option = 0;
 	const char *head_short_sha1 = NULL;
 	const char *branch_ref = NULL;
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index c380d64e99f..320ecd04117 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -740,8 +740,8 @@ static void print_status(unsigned int flags, char state, const char *path,
 }
 
 static int handle_submodule_head_ref(const char *refname,
-				     const struct object_id *oid, int flags,
-				     void *cb_data)
+				     const struct object_id *oid,
+				     unsigned int flags, void *cb_data)
 {
 	struct object_id *output = cb_data;
 	if (oid)
diff --git a/builtin/symbolic-ref.c b/builtin/symbolic-ref.c
index e547a08d6c7..1ad2997e979 100644
--- a/builtin/symbolic-ref.c
+++ b/builtin/symbolic-ref.c
@@ -12,7 +12,7 @@ static const char * const git_symbolic_ref_usage[] = {
 
 static int check_symref(const char *HEAD, int quiet, int shorten, int print)
 {
-	int flag;
+	unsigned int flag;
 	const char *refname = resolve_ref_unsafe(HEAD, 0, NULL, &flag);
 
 	if (!refname)
diff --git a/bundle.c b/bundle.c
index a0bb687b0f4..da4442d4f1a 100644
--- a/bundle.c
+++ b/bundle.c
@@ -371,7 +371,7 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
 		struct object_id oid;
 		char *ref;
 		const char *display_ref;
-		int flag;
+		unsigned int flag;
 
 		if (e->item->flags & UNINTERESTING)
 			continue;
diff --git a/commit-graph.c b/commit-graph.c
index 265c010122e..1a7d1bb154d 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -1636,9 +1636,8 @@ struct refs_cb_data {
 	struct progress *progress;
 };
 
-static int add_ref_to_set(const char *refname,
-			  const struct object_id *oid,
-			  int flags, void *cb_data)
+static int add_ref_to_set(const char *refname, const struct object_id *oid,
+			  unsigned int flags, void *cb_data)
 {
 	struct object_id peeled;
 	struct refs_cb_data *data = (struct refs_cb_data *)cb_data;
diff --git a/config.c b/config.c
index 3f6a30a7db7..db33ab06899 100644
--- a/config.c
+++ b/config.c
@@ -293,7 +293,7 @@ done:
 
 static int include_by_branch(const char *cond, size_t cond_len)
 {
-	int flags;
+	unsigned int flags;
 	int ret;
 	struct strbuf pattern = STRBUF_INIT;
 	const char *refname = !the_repository->gitdir ?
diff --git a/delta-islands.c b/delta-islands.c
index aa98b2e5414..dba5454ba01 100644
--- a/delta-islands.c
+++ b/delta-islands.c
@@ -365,7 +365,7 @@ static void add_ref_to_island(const char *island_name, const struct object_id *o
 }
 
 static int find_island_for_ref(const char *refname, const struct object_id *oid,
-			       int flags, void *data)
+			       unsigned int flags, void *data)
 {
 	/*
 	 * We should advertise 'ARRAY_SIZE(matches) - 2' as the max,
diff --git a/fetch-pack.c b/fetch-pack.c
index dbcaaf4dbb2..19671a30089 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -164,8 +164,9 @@ static int rev_list_insert_ref(struct fetch_negotiator *negotiator,
 	return 0;
 }
 
-static int rev_list_insert_ref_oid(const char *refname, const struct object_id *oid,
-				   int flag, void *cb_data)
+static int rev_list_insert_ref_oid(const char *refname,
+				   const struct object_id *oid,
+				   unsigned int flag, void *cb_data)
 {
 	return rev_list_insert_ref(cb_data, oid);
 }
@@ -548,7 +549,7 @@ static int mark_complete(const struct object_id *oid)
 }
 
 static int mark_complete_oid(const char *refname, const struct object_id *oid,
-			     int flag, void *cb_data)
+			     unsigned int flag, void *cb_data)
 {
 	return mark_complete(oid);
 }
diff --git a/help.c b/help.c
index 9112a51e84b..e79f45c1b1c 100644
--- a/help.c
+++ b/help.c
@@ -732,7 +732,7 @@ struct similar_ref_cb {
 };
 
 static int append_similar_ref(const char *refname, const struct object_id *oid,
-			      int flags, void *cb_data)
+			      unsigned int flags, void *cb_data)
 {
 	struct similar_ref_cb *cb = (struct similar_ref_cb *)(cb_data);
 	char *branch = strrchr(refname, '/') + 1;
diff --git a/http-backend.c b/http-backend.c
index 807fb8839e7..c8757e601d1 100644
--- a/http-backend.c
+++ b/http-backend.c
@@ -504,7 +504,7 @@ static void run_service(const char **argv, int buffer_input)
 }
 
 static int show_text_ref(const char *name, const struct object_id *oid,
-			 int flag, void *cb_data)
+			 unsigned int flag, void *cb_data)
 {
 	const char *name_nons = strip_namespace(name);
 	struct strbuf *buf = cb_data;
@@ -559,7 +559,7 @@ static void get_info_refs(struct strbuf *hdr, char *arg)
 }
 
 static int show_head_ref(const char *refname, const struct object_id *oid,
-			 int flag, void *cb_data)
+			 unsigned int flag, void *cb_data)
 {
 	struct strbuf *buf = cb_data;
 
diff --git a/log-tree.c b/log-tree.c
index 38e5cccc1a1..555a08b45c0 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -135,7 +135,7 @@ static int ref_filter_match(const char *refname,
 }
 
 static int add_ref_decoration(const char *refname, const struct object_id *oid,
-			      int flags, void *cb_data)
+			      unsigned int flags, void *cb_data)
 {
 	struct object *obj;
 	enum object_type objtype;
@@ -245,7 +245,7 @@ static const struct name_decoration *current_pointed_by_HEAD(const struct name_d
 {
 	const struct name_decoration *list, *head = NULL;
 	const char *branch_name = NULL;
-	int rru_flags;
+	unsigned int rru_flags;
 
 	/* First find HEAD */
 	for (list = decoration; list; list = list->next)
diff --git a/ls-refs.c b/ls-refs.c
index 98e69373c84..42ba85b371b 100644
--- a/ls-refs.c
+++ b/ls-refs.c
@@ -77,7 +77,7 @@ struct ls_refs_data {
 };
 
 static int send_ref(const char *refname, const struct object_id *oid,
-		    int flag, void *cb_data)
+		    unsigned int flag, void *cb_data)
 {
 	struct ls_refs_data *data = cb_data;
 	const char *refname_nons = strip_namespace(refname);
@@ -123,7 +123,7 @@ static void send_possibly_unborn_head(struct ls_refs_data *data)
 {
 	struct strbuf namespaced = STRBUF_INIT;
 	struct object_id oid;
-	int flag;
+	unsigned int flag;
 	int oid_is_null;
 
 	strbuf_addf(&namespaced, "%sHEAD", get_git_namespace());
diff --git a/midx.c b/midx.c
index 6e6cb0eb049..41cad25e099 100644
--- a/midx.c
+++ b/midx.c
@@ -938,9 +938,8 @@ static void prepare_midx_packing_data(struct packing_data *pdata,
 	}
 }
 
-static int add_ref_to_pending(const char *refname,
-			      const struct object_id *oid,
-			      int flag, void *cb_data)
+static int add_ref_to_pending(const char *refname, const struct object_id *oid,
+			      unsigned int flag, void *cb_data)
 {
 	struct rev_info *revs = (struct rev_info*)cb_data;
 	struct object *object;
diff --git a/negotiator/default.c b/negotiator/default.c
index 434189ae5dc..3f911f6b633 100644
--- a/negotiator/default.c
+++ b/negotiator/default.c
@@ -36,7 +36,7 @@ static void rev_list_push(struct negotiation_state *ns,
 }
 
 static int clear_marks(const char *refname, const struct object_id *oid,
-		       int flag, void *cb_data)
+		       unsigned int flag, void *cb_data)
 {
 	struct object *o = deref_tag(the_repository, parse_object(the_repository, oid), refname, 0);
 
diff --git a/negotiator/skipping.c b/negotiator/skipping.c
index 1236e792248..0e6f72987c1 100644
--- a/negotiator/skipping.c
+++ b/negotiator/skipping.c
@@ -72,7 +72,7 @@ static struct entry *rev_list_push(struct data *data, struct commit *commit, int
 }
 
 static int clear_marks(const char *refname, const struct object_id *oid,
-		       int flag, void *cb_data)
+		       unsigned int flag, void *cb_data)
 {
 	struct object *o = deref_tag(the_repository, parse_object(the_repository, oid), refname, 0);
 
diff --git a/notes.c b/notes.c
index 7452e71cc8d..e9638a40f0e 100644
--- a/notes.c
+++ b/notes.c
@@ -924,8 +924,9 @@ out:
 	return ret;
 }
 
-static int string_list_add_one_ref(const char *refname, const struct object_id *oid,
-				   int flag, void *cb)
+static int string_list_add_one_ref(const char *refname,
+				   const struct object_id *oid,
+				   unsigned int flag, void *cb)
 {
 	struct string_list *refs = cb;
 	if (!unsorted_string_list_has_string(refs, refname))
diff --git a/object-name.c b/object-name.c
index 0230a874166..5561365c9a1 100644
--- a/object-name.c
+++ b/object-name.c
@@ -1305,7 +1305,7 @@ struct handle_one_ref_cb {
 };
 
 static int handle_one_ref(const char *path, const struct object_id *oid,
-			  int flag, void *cb_data)
+			  unsigned int flag, void *cb_data)
 {
 	struct handle_one_ref_cb *cb = cb_data;
 	struct commit_list **list = cb->list;
diff --git a/reachable.c b/reachable.c
index 84e3d0d75ed..74e8ee81bbe 100644
--- a/reachable.c
+++ b/reachable.c
@@ -27,7 +27,7 @@ static void update_progress(struct connectivity_progress *cp)
 }
 
 static int add_one_ref(const char *path, const struct object_id *oid,
-		       int flag, void *cb_data)
+		       unsigned int flag, void *cb_data)
 {
 	struct rev_info *revs = (struct rev_info *)cb_data;
 	struct object *object;
diff --git a/ref-filter.c b/ref-filter.c
index f7a2f17bfd9..f51779bd725 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -2233,7 +2233,8 @@ struct ref_filter_cbdata {
  * A call-back given to for_each_ref().  Filter refs and keep them for
  * later object processing.
  */
-static int ref_filter_handler(const char *refname, const struct object_id *oid, int flag, void *cb_data)
+static int ref_filter_handler(const char *refname, const struct object_id *oid,
+			      unsigned int flag, void *cb_data)
 {
 	struct ref_filter_cbdata *ref_cbdata = cb_data;
 	struct ref_filter *filter = ref_cbdata->filter;
diff --git a/refs.c b/refs.c
index d680de3bc04..2ca398b8527 100644
--- a/refs.c
+++ b/refs.c
@@ -74,7 +74,7 @@ static unsigned char refname_disposition[256] = {
  * as an error, try to come up with a usable replacement for the input
  * refname in it.
  */
-static int check_refname_component(const char *refname, int *flags,
+static int check_refname_component(const char *refname, unsigned int *flags,
 				   struct strbuf *sanitized)
 {
 	const char *cp;
@@ -158,7 +158,7 @@ out:
 	return cp - refname;
 }
 
-static int check_or_sanitize_refname(const char *refname, int flags,
+static int check_or_sanitize_refname(const char *refname, unsigned int flags,
 				     struct strbuf *sanitized)
 {
 	int component_len, component_count = 0;
@@ -202,7 +202,7 @@ static int check_or_sanitize_refname(const char *refname, int flags,
 	return 0;
 }
 
-int check_refname_format(const char *refname, int flags)
+int check_refname_format(const char *refname, unsigned int flags)
 {
 	return check_or_sanitize_refname(refname, flags, NULL);
 }
@@ -264,9 +264,9 @@ int ref_resolves_to_object(const char *refname,
 	return 1;
 }
 
-char *refs_resolve_refdup(struct ref_store *refs,
-			  const char *refname, int resolve_flags,
-			  struct object_id *oid, int *flags)
+char *refs_resolve_refdup(struct ref_store *refs, const char *refname,
+			  unsigned int resolve_flags, struct object_id *oid,
+			  unsigned int *flags)
 {
 	const char *result;
 
@@ -275,8 +275,8 @@ char *refs_resolve_refdup(struct ref_store *refs,
 	return xstrdup_or_null(result);
 }
 
-char *resolve_refdup(const char *refname, int resolve_flags,
-		     struct object_id *oid, int *flags)
+char *resolve_refdup(const char *refname, unsigned int resolve_flags,
+		     struct object_id *oid, unsigned int *flags)
 {
 	return refs_resolve_refdup(get_main_ref_store(the_repository),
 				   refname, resolve_flags,
@@ -291,7 +291,8 @@ struct ref_filter {
 	void *cb_data;
 };
 
-int read_ref_full(const char *refname, int resolve_flags, struct object_id *oid, int *flags)
+int read_ref_full(const char *refname, unsigned int resolve_flags,
+		  struct object_id *oid, unsigned int *flags)
 {
 	struct ref_store *refs = get_main_ref_store(the_repository);
 
@@ -318,7 +319,7 @@ int ref_exists(const char *refname)
 }
 
 static int filter_refs(const char *refname, const struct object_id *oid,
-			   int flags, void *data)
+		       unsigned int flags, void *data)
 {
 	struct ref_filter *filter = (struct ref_filter *)data;
 
@@ -357,8 +358,9 @@ struct warn_if_dangling_data {
 	const char *msg_fmt;
 };
 
-static int warn_if_dangling_symref(const char *refname, const struct object_id *oid,
-				   int flags, void *cb_data)
+static int warn_if_dangling_symref(const char *refname,
+				   const struct object_id *oid,
+				   unsigned int flags, void *cb_data)
 {
 	struct warn_if_dangling_data *d = cb_data;
 	const char *resolves_to;
@@ -436,7 +438,7 @@ int head_ref_namespaced(each_ref_fn fn, void *cb_data)
 	struct strbuf buf = STRBUF_INIT;
 	int ret = 0;
 	struct object_id oid;
-	int flag;
+	unsigned int flag;
 
 	strbuf_addf(&buf, "%sHEAD", get_git_namespace());
 	if (!read_ref_full(buf.buf, RESOLVE_REF_READING, &oid, &flag))
@@ -651,7 +653,7 @@ int expand_ref(struct repository *repo, const char *str, int len,
 	for (p = ref_rev_parse_rules; *p; p++) {
 		struct object_id oid_from_ref;
 		struct object_id *this_result;
-		int flag;
+		unsigned int flag;
 		struct ref_store *refs = get_main_ref_store(repo);
 
 		this_result = refs_found ? &oid_from_ref : oid;
@@ -1384,7 +1386,7 @@ const char *find_descendant_ref(const char *dirname,
 int refs_head_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
 {
 	struct object_id oid;
-	int flag;
+	unsigned int flag;
 
 	if (refs_resolve_ref_unsafe(refs, "HEAD", RESOLVE_REF_READING,
 				    &oid, &flag))
@@ -1461,11 +1463,9 @@ struct do_for_each_ref_help {
 	void *cb_data;
 };
 
-static int do_for_each_ref_helper(struct repository *r,
-				  const char *refname,
+static int do_for_each_ref_helper(struct repository *r, const char *refname,
 				  const struct object_id *oid,
-				  int flags,
-				  void *cb_data)
+				  unsigned int flags, void *cb_data)
 {
 	struct do_for_each_ref_help *hp = cb_data;
 
@@ -1672,15 +1672,13 @@ int refs_read_raw_ref(struct ref_store *ref_store, const char *refname,
 					   type, failure_errno);
 }
 
-const char *refs_resolve_ref_unsafe(struct ref_store *refs,
-				    const char *refname,
-				    int resolve_flags,
-				    struct object_id *oid,
-				    int *flags)
+const char *refs_resolve_ref_unsafe(struct ref_store *refs, const char *refname,
+				    unsigned int resolve_flags,
+				    struct object_id *oid, unsigned int *flags)
 {
 	static struct strbuf sb_refname = STRBUF_INIT;
 	struct object_id unused_oid;
-	int unused_flags;
+	unsigned int unused_flags;
 	int symref_count;
 
 	if (!oid)
@@ -1769,8 +1767,8 @@ int refs_init_db(struct strbuf *err)
 	return refs->be->init_db(refs, err);
 }
 
-const char *resolve_ref_unsafe(const char *refname, int resolve_flags,
-			       struct object_id *oid, int *flags)
+const char *resolve_ref_unsafe(const char *refname, unsigned int resolve_flags,
+			       struct object_id *oid, unsigned int *flags)
 {
 	return refs_resolve_ref_unsafe(get_main_ref_store(the_repository), refname,
 				       resolve_flags, oid, flags);
@@ -1780,7 +1778,7 @@ int resolve_gitlink_ref(const char *submodule, const char *refname,
 			struct object_id *oid)
 {
 	struct ref_store *refs;
-	int flags;
+	unsigned int flags;
 
 	refs = get_submodule_ref_store(submodule);
 
diff --git a/refs.h b/refs.h
index ff859d59513..82c3ba1fc56 100644
--- a/refs.h
+++ b/refs.h
@@ -63,23 +63,21 @@ struct worktree;
 #define RESOLVE_REF_NO_RECURSE 0x02
 #define RESOLVE_REF_ALLOW_BAD_NAME 0x04
 
-const char *refs_resolve_ref_unsafe(struct ref_store *refs,
-				    const char *refname,
-				    int resolve_flags,
-				    struct object_id *oid,
-				    int *flags);
-
-const char *resolve_ref_unsafe(const char *refname, int resolve_flags,
-			       struct object_id *oid, int *flags);
-
-char *refs_resolve_refdup(struct ref_store *refs,
-			  const char *refname, int resolve_flags,
-			  struct object_id *oid, int *flags);
-char *resolve_refdup(const char *refname, int resolve_flags,
-		     struct object_id *oid, int *flags);
-
-int read_ref_full(const char *refname, int resolve_flags,
-		  struct object_id *oid, int *flags);
+const char *refs_resolve_ref_unsafe(struct ref_store *refs, const char *refname,
+				    unsigned int resolve_flags,
+				    struct object_id *oid, unsigned int *flags);
+
+const char *resolve_ref_unsafe(const char *refname, unsigned int resolve_flags,
+			       struct object_id *oid, unsigned int *flags);
+
+char *refs_resolve_refdup(struct ref_store *refs, const char *refname,
+			  unsigned int resolve_flags, struct object_id *oid,
+			  unsigned int *flags);
+char *resolve_refdup(const char *refname, unsigned int resolve_flags,
+		     struct object_id *oid, unsigned int *flags);
+
+int read_ref_full(const char *refname, unsigned int resolve_flags,
+		  struct object_id *oid, unsigned int *flags);
 int read_ref(const char *refname, struct object_id *oid);
 
 /*
@@ -293,17 +291,15 @@ struct ref_transaction;
  * arguments is only guaranteed to be valid for the duration of a
  * single callback invocation.
  */
-typedef int each_ref_fn(const char *refname,
-			const struct object_id *oid, int flags, void *cb_data);
+typedef int each_ref_fn(const char *refname, const struct object_id *oid,
+			unsigned int flags, void *cb_data);
 
 /*
  * The same as each_ref_fn, but also with a repository argument that
  * contains the repository associated with the callback.
  */
-typedef int each_repo_ref_fn(struct repository *r,
-			     const char *refname,
-			     const struct object_id *oid,
-			     int flags,
+typedef int each_repo_ref_fn(struct repository *r, const char *refname,
+			     const struct object_id *oid, unsigned int flags,
 			     void *cb_data);
 
 /*
@@ -527,7 +523,7 @@ int for_each_reflog(each_ref_fn fn, void *cb_data);
  * allow a single "*" wildcard character in the refspec. No leading or
  * repeated slashes are accepted.
  */
-int check_refname_format(const char *refname, int flags);
+int check_refname_format(const char *refname, unsigned int flags);
 
 /*
  * Apply the rules from check_refname_format, but mutate the result until it
@@ -897,7 +893,7 @@ struct ref_store *get_main_ref_store(struct repository *r);
  *
  * ----
  * static int handle_remote_ref(const char *refname,
- * 		const unsigned char *sha1, int flags, void *cb_data)
+ * 		const unsigned char *sha1, unsigned int flags, void *cb_data)
  * {
  * 	struct strbuf *output = cb_data;
  * 	strbuf_addf(output, "%s\n", refname);
diff --git a/refs/files-backend.c b/refs/files-backend.c
index f59589d6cce..b3149ca493b 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -261,7 +261,7 @@ static void loose_fill_ref_dir(struct ref_store *ref_store,
 	while ((de = readdir(d)) != NULL) {
 		struct object_id oid;
 		struct stat st;
-		int flag;
+		unsigned int flag;
 
 		if (de->d_name[0] == '.')
 			continue;
@@ -1399,7 +1399,8 @@ static int files_copy_or_rename_ref(struct ref_store *ref_store,
 	struct files_ref_store *refs =
 		files_downcast(ref_store, REF_STORE_WRITE, "rename_ref");
 	struct object_id orig_oid;
-	int flag = 0, logmoved = 0;
+	int logmoved = 0;
+	unsigned int flag = 0;
 	struct ref_lock *lock;
 	struct stat loginfo;
 	struct strbuf sb_oldref = STRBUF_INIT;
@@ -1833,7 +1834,7 @@ static int commit_ref_update(struct files_ref_store *refs,
 		 * check with HEAD only which should cover 99% of all usage
 		 * scenarios (even 100% of the default ones).
 		 */
-		int head_flag;
+		unsigned int head_flag;
 		const char *head_ref;
 
 		head_ref = refs_resolve_ref_unsafe(&refs->base, "HEAD",
@@ -2161,7 +2162,7 @@ static int files_reflog_iterator_advance(struct ref_iterator *ref_iterator)
 	int ok;
 
 	while ((ok = dir_iterator_advance(diter)) == ITER_OK) {
-		int flags;
+		unsigned int flags;
 
 		if (!S_ISREG(diter->st.st_mode))
 			continue;
@@ -2668,7 +2669,7 @@ static int files_transaction_prepare(struct ref_store *ref_store,
 	int ret = 0;
 	struct string_list affected_refnames = STRING_LIST_INIT_NODUP;
 	char *head_ref = NULL;
-	int head_type;
+	unsigned int head_type;
 	struct files_transaction_backend_data *backend_data;
 	struct ref_transaction *packed_transaction = NULL;
 
@@ -2982,8 +2983,8 @@ static int files_transaction_abort(struct ref_store *ref_store,
 	return 0;
 }
 
-static int ref_present(const char *refname,
-		       const struct object_id *oid, int flags, void *cb_data)
+static int ref_present(const char *refname, const struct object_id *oid,
+		       unsigned int flags, void *cb_data)
 {
 	struct string_list *affected_refnames = cb_data;
 
@@ -3209,7 +3210,7 @@ static int files_reflog_expire(struct ref_store *ref_store,
 
 		if ((expire_flags & EXPIRE_REFLOGS_UPDATE_REF) &&
 		    !is_null_oid(&cb.last_kept_oid)) {
-			int type;
+			unsigned int type;
 			const char *ref;
 
 			ref = refs_resolve_ref_unsafe(&refs->base, refname,
diff --git a/remote.c b/remote.c
index c97c626eaa8..ff21b77f643 100644
--- a/remote.c
+++ b/remote.c
@@ -500,7 +500,7 @@ static void alias_all_urls(struct remote_state *remote_state)
 
 static void read_config(struct repository *repo)
 {
-	int flag;
+	unsigned int flag;
 
 	if (repo->remote_state->initialized)
 		return;
@@ -1271,7 +1271,7 @@ static int match_explicit(struct ref *src, struct ref *dst,
 		return -1;
 
 	if (!dst_value) {
-		int flag;
+		unsigned int flag;
 
 		dst_value = resolve_ref_unsafe(matched_src->name,
 					       RESOLVE_REF_READING,
@@ -1947,7 +1947,7 @@ const char *branch_get_push(struct branch *branch, struct strbuf *err)
 
 static int ignore_symref_update(const char *refname)
 {
-	int flag;
+	unsigned int flag;
 
 	if (!resolve_ref_unsafe(refname, 0, NULL, &flag))
 		return 0; /* non-existing refs are OK */
@@ -2287,7 +2287,7 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb,
 }
 
 static int one_local_ref(const char *refname, const struct object_id *oid,
-			 int flag, void *cb_data)
+			 unsigned int flag, void *cb_data)
 {
 	struct ref ***local_tail = cb_data;
 	struct ref *ref;
@@ -2368,7 +2368,7 @@ struct stale_heads_info {
 };
 
 static int get_stale_heads_cb(const char *refname, const struct object_id *oid,
-			      int flags, void *cb_data)
+			      unsigned int flags, void *cb_data)
 {
 	struct stale_heads_info *info = cb_data;
 	struct string_list matches = STRING_LIST_INIT_DUP;
diff --git a/replace-object.c b/replace-object.c
index 7bd9aba6ee6..1a9ed348661 100644
--- a/replace-object.c
+++ b/replace-object.c
@@ -6,10 +6,9 @@
 #include "repository.h"
 #include "commit.h"
 
-static int register_replace_ref(struct repository *r,
-				const char *refname,
-				const struct object_id *oid,
-				int flag, void *cb_data)
+static int register_replace_ref(struct repository *r, const char *refname,
+				const struct object_id *oid, unsigned int flag,
+				void *cb_data)
 {
 	/* Get sha1 from refname */
 	const char *slash = strrchr(refname, '/');
diff --git a/revision.c b/revision.c
index 648f63fbb26..ccdb069af1a 100644
--- a/revision.c
+++ b/revision.c
@@ -1535,7 +1535,7 @@ int ref_excluded(struct string_list *ref_excludes, const char *path)
 }
 
 static int handle_one_ref(const char *path, const struct object_id *oid,
-			  int flag, void *cb_data)
+			  unsigned int flag, void *cb_data)
 {
 	struct all_refs_cb *cb = cb_data;
 	struct object *object;
@@ -1619,8 +1619,8 @@ static int handle_one_reflog_ent(struct object_id *ooid, struct object_id *noid,
 }
 
 static int handle_one_reflog(const char *refname_in_wt,
-			     const struct object_id *oid,
-			     int flag, void *cb_data)
+			     const struct object_id *oid, unsigned int flag,
+			     void *cb_data)
 {
 	struct all_refs_cb *cb = cb_data;
 	struct strbuf refname = STRBUF_INIT;
@@ -2688,7 +2688,7 @@ static int handle_revision_pseudo_opt(struct rev_info *revs,
 
 static void NORETURN diagnose_missing_default(const char *def)
 {
-	int flags;
+	unsigned int flags;
 	const char *refname;
 
 	refname = resolve_ref_unsafe(def, 0, NULL, &flags);
diff --git a/server-info.c b/server-info.c
index 7701d7c20a1..78119897d30 100644
--- a/server-info.c
+++ b/server-info.c
@@ -147,7 +147,7 @@ out:
 }
 
 static int add_info_ref(const char *path, const struct object_id *oid,
-			int flag, void *cb_data)
+			unsigned int flag, void *cb_data)
 {
 	struct update_info_ctx *uic = cb_data;
 	struct object *o = parse_object(the_repository, oid);
diff --git a/shallow.c b/shallow.c
index 71e5876f377..da9f1e28e93 100644
--- a/shallow.c
+++ b/shallow.c
@@ -596,7 +596,7 @@ static void paint_down(struct paint_info *info, const struct object_id *oid,
 }
 
 static int mark_uninteresting(const char *refname, const struct object_id *oid,
-			      int flags, void *cb_data)
+			      unsigned int flags, void *cb_data)
 {
 	struct commit *commit = lookup_commit_reference_gently(the_repository,
 							       oid, 1);
@@ -707,7 +707,7 @@ struct commit_array {
 };
 
 static int add_ref(const char *refname, const struct object_id *oid,
-		   int flags, void *cb_data)
+		   unsigned int flags, void *cb_data)
 {
 	struct commit_array *ca = cb_data;
 	ALLOC_GROW(ca->commits, ca->nr + 1, ca->alloc);
diff --git a/submodule.c b/submodule.c
index 95af84347d7..e5c5d9aa6be 100644
--- a/submodule.c
+++ b/submodule.c
@@ -916,7 +916,7 @@ static void free_submodules_oids(struct string_list *submodules)
 }
 
 static int has_remote(const char *refname, const struct object_id *oid,
-		      int flags, void *cb_data)
+		      unsigned int flags, void *cb_data)
 {
 	return 1;
 }
@@ -1223,7 +1223,7 @@ int push_unpushed_submodules(struct repository *r,
 }
 
 static int append_oid_to_array(const char *ref, const struct object_id *oid,
-			       int flags, void *data)
+			       unsigned int flags, void *data)
 {
 	struct oid_array *array = data;
 	oid_array_append(array, oid);
diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c
index 9646d85fc84..5859f8941d5 100644
--- a/t/helper/test-ref-store.c
+++ b/t/helper/test-ref-store.c
@@ -160,7 +160,7 @@ static int cmd_rename_ref(struct ref_store *refs, const char **argv)
 }
 
 static int each_ref(const char *refname, const struct object_id *oid,
-		    int flags, void *cb_data)
+		    unsigned int flags, void *cb_data)
 {
 	printf("%s %s 0x%x\n", oid_to_hex(oid), refname, flags);
 	return 0;
@@ -178,7 +178,7 @@ static int cmd_resolve_ref(struct ref_store *refs, const char **argv)
 	struct object_id oid = *null_oid();
 	const char *refname = notnull(*argv++, "refname");
 	int resolve_flags = arg_flags(*argv++, "resolve-flags", empty_flags);
-	int flags;
+	unsigned int flags;
 	const char *ref;
 
 	ref = refs_resolve_ref_unsafe(refs, refname, resolve_flags,
diff --git a/transport-helper.c b/transport-helper.c
index a0297b0986c..c207103aaff 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -1090,7 +1090,7 @@ static int push_refs_with_export(struct transport *transport,
 			if (strcmp(ref->name, ref->peer_ref->name)) {
 				if (!ref->deletion) {
 					const char *name;
-					int flag;
+					unsigned int flag;
 
 					/* Follow symbolic refs (mainly for HEAD). */
 					name = resolve_ref_unsafe(ref->peer_ref->name,
diff --git a/transport.c b/transport.c
index 2a3e3241545..5b6d5d29388 100644
--- a/transport.c
+++ b/transport.c
@@ -80,7 +80,7 @@ static void set_upstreams(struct transport *transport, struct ref *refs,
 		const char *localname;
 		const char *tmp;
 		const char *remotename;
-		int flag = 0;
+		unsigned int flag = 0;
 		/*
 		 * Check suitability for tracking. Must be successful /
 		 * already up-to-date ref create/modify (not delete).
diff --git a/upload-pack.c b/upload-pack.c
index 8acc98741bb..cb652db4f78 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -822,7 +822,7 @@ static void send_unshallow(struct upload_pack_data *data)
 }
 
 static int check_ref(const char *refname_full, const struct object_id *oid,
-		     int flag, void *cb_data);
+		     unsigned int flag, void *cb_data);
 static void deepen(struct upload_pack_data *data, int depth)
 {
 	if (depth == INFINITE_DEPTH && !is_repository_shallow(the_repository)) {
@@ -1169,7 +1169,7 @@ static int mark_our_ref(const char *refname, const char *refname_full,
 }
 
 static int check_ref(const char *refname_full, const struct object_id *oid,
-		     int flag, void *cb_data)
+		     unsigned int flag, void *cb_data)
 {
 	const char *refname = strip_namespace(refname_full);
 
@@ -1193,7 +1193,7 @@ static void format_session_id(struct strbuf *buf, struct upload_pack_data *d) {
 }
 
 static int send_ref(const char *refname, const struct object_id *oid,
-		    int flag, void *cb_data)
+		    unsigned int flag, void *cb_data)
 {
 	static const char *capabilities = "multi_ack thin-pack side-band"
 		" side-band-64k ofs-delta shallow deepen-since deepen-not"
@@ -1236,7 +1236,7 @@ static int send_ref(const char *refname, const struct object_id *oid,
 }
 
 static int find_symref(const char *refname, const struct object_id *oid,
-		       int flag, void *cb_data)
+		       unsigned int flag, void *cb_data)
 {
 	const char *symref_target;
 	struct string_list_item *item;
diff --git a/walker.c b/walker.c
index c5e29219795..c1b82504f51 100644
--- a/walker.c
+++ b/walker.c
@@ -216,7 +216,7 @@ static int interpret_target(struct walker *walker, char *target, struct object_i
 }
 
 static int mark_complete(const char *path, const struct object_id *oid,
-			 int flag, void *cb_data)
+			 unsigned int flag, void *cb_data)
 {
 	struct commit *commit = lookup_commit_reference_gently(the_repository,
 							       oid, 1);
diff --git a/worktree.c b/worktree.c
index e392c7af674..58c958e055a 100644
--- a/worktree.c
+++ b/worktree.c
@@ -27,7 +27,7 @@ void free_worktrees(struct worktree **worktrees)
  */
 static void add_head_info(struct worktree *wt)
 {
-	int flags;
+	unsigned int flags;
 	const char *target;
 
 	target = refs_resolve_ref_unsafe(get_worktree_ref_store(wt),
@@ -414,7 +414,7 @@ const struct worktree *find_shared_symref(struct worktree **worktrees,
 		struct worktree *wt = worktrees[i];
 		const char *symref_target;
 		struct ref_store *refs;
-		int flags;
+		unsigned int flags;
 
 		if (wt->is_bare)
 			continue;
@@ -559,7 +559,7 @@ int other_head_refs(each_ref_fn fn, void *cb_data)
 	for (p = worktrees; *p; p++) {
 		struct worktree *wt = *p;
 		struct object_id oid;
-		int flag;
+		unsigned int flag;
 
 		if (wt->is_current)
 			continue;
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v3 2/2] Uniformize flag argument naming to `flags` or `unused_flags`
  2022-02-03 14:26   ` [PATCH v3 0/2] " Han-Wen Nienhuys via GitGitGadget
  2022-02-03 14:26     ` [PATCH v3 1/2] " Han-Wen Nienhuys via GitGitGadget
@ 2022-02-03 14:26     ` Han-Wen Nienhuys via GitGitGadget
  1 sibling, 0 replies; 17+ messages in thread
From: Han-Wen Nienhuys via GitGitGadget @ 2022-02-03 14:26 UTC (permalink / raw)
  To: git
  Cc: Han-Wen Nienhuys, Ævar Arnfjörð Bjarmason,
	Han-Wen Nienhuys, Han-Wen Nienhuys

From: Han-Wen Nienhuys <hanwen@google.com>

In a couple of shadowing cases, use `ref_flags` for
clarity.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
---
 bisect.c                    |  4 ++--
 builtin/bisect--helper.c    | 10 ++++----
 builtin/checkout.c          | 23 +++++++++---------
 builtin/describe.c          |  2 +-
 builtin/fetch.c             |  4 ++--
 builtin/fsck.c              |  4 ++--
 builtin/gc.c                |  2 +-
 builtin/name-rev.c          |  2 +-
 builtin/pack-objects.c      |  4 ++--
 builtin/rebase.c            |  9 +++----
 builtin/receive-pack.c      | 13 +++++-----
 builtin/reflog.c            |  2 +-
 builtin/remote.c            | 20 ++++++++--------
 builtin/repack.c            |  4 ++--
 builtin/replace.c           |  4 ++--
 builtin/rev-parse.c         |  4 ++--
 builtin/show-branch.c       | 12 +++++-----
 builtin/show-ref.c          |  2 +-
 builtin/submodule--helper.c |  2 +-
 builtin/symbolic-ref.c      |  6 ++---
 bundle.c                    |  8 +++----
 delta-islands.c             |  2 +-
 fetch-pack.c                |  4 ++--
 http-backend.c              |  4 ++--
 log-tree.c                  |  2 +-
 ls-refs.c                   | 18 +++++++-------
 midx.c                      |  4 ++--
 negotiator/default.c        |  2 +-
 negotiator/skipping.c       |  2 +-
 notes.c                     |  2 +-
 object-name.c               |  2 +-
 reachable.c                 |  4 ++--
 ref-filter.c                |  8 +++----
 refs.c                      | 29 ++++++++++++-----------
 refs/files-backend.c        | 47 +++++++++++++++++++------------------
 remote.c                    | 26 ++++++++++----------
 replace-object.c            |  4 ++--
 revision.c                  |  6 ++---
 server-info.c               |  2 +-
 shallow.c                   |  4 ++--
 submodule.c                 |  4 ++--
 transport-helper.c          | 12 ++++++----
 transport.c                 | 10 ++++----
 upload-pack.c               | 12 +++++-----
 walker.c                    |  2 +-
 worktree.c                  |  9 ++++---
 46 files changed, 183 insertions(+), 179 deletions(-)

diff --git a/bisect.c b/bisect.c
index 44af2081987..c062209c439 100644
--- a/bisect.c
+++ b/bisect.c
@@ -441,7 +441,7 @@ void find_bisection(struct commit_list **commit_list, int *reaches,
 }
 
 static int register_ref(const char *refname, const struct object_id *oid,
-			unsigned int flags, void *cb_data)
+			unsigned int unused_flags, void *cb_data)
 {
 	struct strbuf good_prefix = STRBUF_INIT;
 	strbuf_addstr(&good_prefix, term_good);
@@ -1147,7 +1147,7 @@ int estimate_bisect_steps(int all)
 }
 
 static int mark_for_removal(const char *refname, const struct object_id *oid,
-			    unsigned int flag, void *cb_data)
+			    unsigned int unused_flags, void *cb_data)
 {
 	struct string_list *refs = cb_data;
 	char *ref = xstrfmt("refs/bisect%s", refname);
diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c
index e8b0c049f34..8eb4b8cc303 100644
--- a/builtin/bisect--helper.c
+++ b/builtin/bisect--helper.c
@@ -330,7 +330,7 @@ static int check_and_set_terms(struct bisect_terms *terms, const char *cmd)
 }
 
 static int mark_good(const char *refname, const struct object_id *oid,
-		     unsigned int flag, void *cb_data)
+		     unsigned int unused_flags, void *cb_data)
 {
 	int *m_good = (int *)cb_data;
 	*m_good = 0;
@@ -477,7 +477,7 @@ finish:
 }
 
 static int add_bisect_ref(const char *refname, const struct object_id *oid,
-			  unsigned int flags, void *cb)
+			  unsigned int unused_flags, void *cb)
 {
 	struct add_bisect_ref_data *data = cb;
 
@@ -618,7 +618,7 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, const char **a
 	int first_parent_only = 0;
 	int i, has_double_dash = 0, must_write_terms = 0, bad_seen = 0;
 	int pathspec_pos;
-	unsigned int flags;
+	unsigned int unused_flags;
 	enum bisect_error res = BISECT_OK;
 	struct string_list revs = STRING_LIST_INIT_DUP;
 	struct string_list states = STRING_LIST_INIT_DUP;
@@ -708,7 +708,7 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, const char **a
 	/*
 	 * Verify HEAD
 	 */
-	head = resolve_ref_unsafe("HEAD", 0, &head_oid, &flags);
+	head = resolve_ref_unsafe("HEAD", 0, &head_oid, &unused_flags);
 	if (!head)
 		if (get_oid("HEAD", &head_oid))
 			return error(_("bad HEAD - I need a HEAD"));
@@ -1091,7 +1091,7 @@ static int bisect_visualize(struct bisect_terms *terms, const char **argv, int a
 }
 
 static int get_first_good(const char *refname, const struct object_id *oid,
-			  int flag, void *cb_data)
+			  unsigned int flag, void *cb_data)
 {
 	oidcpy(cb_data, oid);
 	return 1;
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 742c4ac2ab7..761f9ac9483 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -974,7 +974,8 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
 
 static int add_pending_uninteresting_ref(const char *refname,
 					 const struct object_id *oid,
-					 unsigned int flags, void *cb_data)
+					 unsigned int unused_flags,
+					 void *cb_data)
 {
 	add_pending_oid(cb_data, refname, oid, UNINTERESTING);
 	return 0;
@@ -1084,16 +1085,16 @@ static int switch_branches(const struct checkout_opts *opts,
 	struct branch_info old_branch_info = { 0 };
 	struct object_id rev;
 	int writeout_error = 0;
-	unsigned int flag;
+	unsigned int flags;
 	int do_merge = 1;
 
 	trace2_cmd_mode("branch");
 
 	memset(&old_branch_info, 0, sizeof(old_branch_info));
-	old_branch_info.path = resolve_refdup("HEAD", 0, &rev, &flag);
+	old_branch_info.path = resolve_refdup("HEAD", 0, &rev, &flags);
 	if (old_branch_info.path)
 		old_branch_info.commit = lookup_commit_reference_gently(the_repository, &rev, 1);
-	if (!(flag & REF_ISSYMREF))
+	if (!(flags & REF_ISSYMREF))
 		FREE_AND_NULL(old_branch_info.path);
 
 	if (old_branch_info.path) {
@@ -1510,20 +1511,20 @@ static int checkout_branch(struct checkout_opts *opts,
 
 	if (new_branch_info->path && !opts->force_detach && !opts->new_branch &&
 	    !opts->ignore_other_worktrees) {
-		unsigned int flag;
-		char *head_ref = resolve_refdup("HEAD", 0, NULL, &flag);
-		if (head_ref &&
-		    (!(flag & REF_ISSYMREF) || strcmp(head_ref, new_branch_info->path)))
+		unsigned int flags;
+		char *head_ref = resolve_refdup("HEAD", 0, NULL, &flags);
+		if (head_ref && (!(flags & REF_ISSYMREF) ||
+				 strcmp(head_ref, new_branch_info->path)))
 			die_if_checked_out(new_branch_info->path, 1);
 		free(head_ref);
 	}
 
 	if (!new_branch_info->commit && opts->new_branch) {
 		struct object_id rev;
-		unsigned int flag;
+		unsigned int flags;
 
-		if (!read_ref_full("HEAD", 0, &rev, &flag) &&
-		    (flag & REF_ISSYMREF) && is_null_oid(&rev))
+		if (!read_ref_full("HEAD", 0, &rev, &flags) &&
+		    (flags & REF_ISSYMREF) && is_null_oid(&rev))
 			return switch_unborn_to_new_branch(opts);
 	}
 	return switch_branches(opts, new_branch_info);
diff --git a/builtin/describe.c b/builtin/describe.c
index 5fa5b0bb424..c7b24390ca6 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -141,7 +141,7 @@ static void add_to_known_names(const char *path,
 }
 
 static int get_name(const char *path, const struct object_id *oid,
-		    unsigned int flag, void *cb_data)
+		    unsigned int unused_flags, void *cb_data)
 {
 	int is_tag = 0;
 	struct object_id peeled;
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 0d2eab174c4..2f341aef13a 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -325,7 +325,7 @@ static struct refname_hash_entry *refname_hash_add(struct hashmap *map,
 }
 
 static int add_one_refname(const char *refname, const struct object_id *oid,
-			   unsigned int flag, void *cbdata)
+			   unsigned int unused_flags, void *cbdata)
 {
 	struct hashmap *refname_map = cbdata;
 
@@ -1430,7 +1430,7 @@ static void set_option(struct transport *transport, const char *name, const char
 }
 
 static int add_oid(const char *refname, const struct object_id *oid,
-		   unsigned int flags, void *cb_data)
+		   unsigned int unused_flags, void *cb_data)
 {
 	struct oid_array *oids = cb_data;
 
diff --git a/builtin/fsck.c b/builtin/fsck.c
index 8e3f773e3dd..c52bd1843d1 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -502,7 +502,7 @@ static int fsck_handle_reflog_ent(struct object_id *ooid, struct object_id *noid
 }
 
 static int fsck_handle_reflog(const char *logname, const struct object_id *oid,
-			      unsigned int flag, void *cb_data)
+			      unsigned int unused_flags, void *cb_data)
 {
 	struct strbuf refname = STRBUF_INIT;
 
@@ -513,7 +513,7 @@ static int fsck_handle_reflog(const char *logname, const struct object_id *oid,
 }
 
 static int fsck_handle_ref(const char *refname, const struct object_id *oid,
-			   unsigned int flag, void *cb_data)
+			   unsigned int unused_flags, void *cb_data)
 {
 	struct object *obj;
 
diff --git a/builtin/gc.c b/builtin/gc.c
index 1c045962766..544aae1a7e8 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -770,7 +770,7 @@ struct cg_auto_data {
 };
 
 static int dfs_on_ref(const char *refname, const struct object_id *oid,
-		      unsigned int flags, void *cb_data)
+		      unsigned int unused_flags, void *cb_data)
 {
 	struct cg_auto_data *data = (struct cg_auto_data *)cb_data;
 	int result = 0;
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index 93f622331fb..a9dd2fbb22e 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -306,7 +306,7 @@ static int cmp_by_tag_and_age(const void *a_, const void *b_)
 }
 
 static int name_ref(const char *path, const struct object_id *oid,
-		    unsigned int flags, void *cb_data)
+		    unsigned int unused_flags, void *cb_data)
 {
 	struct object *o = parse_object(the_repository, oid);
 	struct name_ref_data *data = cb_data;
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 7af3cbf9688..a8a4907588a 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -759,7 +759,7 @@ static enum write_one_status write_one(struct hashfile *f,
 }
 
 static int mark_tagged(const char *path, const struct object_id *oid,
-		       unsigned int flag, void *cb_data)
+		       unsigned int unused_flags, void *cb_data)
 {
 	struct object_id peeled;
 	struct object_entry *entry = packlist_find(&to_pack, oid);
@@ -3013,7 +3013,7 @@ static void add_tag_chain(const struct object_id *oid)
 }
 
 static int add_ref_tag(const char *tag, const struct object_id *oid,
-		       unsigned int flag, void *cb_data)
+		       unsigned int unused_flags, void *cb_data)
 {
 	struct object_id peeled;
 
diff --git a/builtin/rebase.c b/builtin/rebase.c
index d4015b72610..ec131afa2cc 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -1025,7 +1025,6 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 	struct rebase_options options = REBASE_OPTIONS_INIT;
 	const char *branch_name;
 	int ret, total_argc, in_progress = 0;
-	unsigned int flags;
 	int keep_base = 0;
 	int ok_to_skip_pre_rebase = 0;
 	struct strbuf msg = STRBUF_INIT;
@@ -1639,6 +1638,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 		}
 	} else if (argc == 0) {
 		/* Do not need to switch branches, we are already on it. */
+		unsigned int flags;
 		options.head_name =
 			xstrdup_or_null(resolve_ref_unsafe("HEAD", 0, NULL,
 					 &flags));
@@ -1696,7 +1696,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 	if (can_fast_forward(options.onto, options.upstream, options.restrict_revision,
 		    &options.orig_head, &merge_base) &&
 	    allow_preemptive_ff) {
-		unsigned int flag;
+		unsigned int unused_flags;
 
 		if (!(options.flags & REBASE_FORCE)) {
 			/* Lazily switch to the target branch if needed... */
@@ -1709,7 +1709,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 			if (!(options.flags & REBASE_NO_QUIET))
 				; /* be quiet */
 			else if (!strcmp(branch_name, "HEAD") &&
-				 resolve_ref_unsafe("HEAD", 0, NULL, &flag))
+				 resolve_ref_unsafe("HEAD", 0, NULL,
+						    &unused_flags))
 				puts(_("HEAD is up to date."));
 			else
 				printf(_("Current branch %s is up to date.\n"),
@@ -1719,7 +1720,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 		} else if (!(options.flags & REBASE_NO_QUIET))
 			; /* be quiet */
 		else if (!strcmp(branch_name, "HEAD") &&
-			 resolve_ref_unsafe("HEAD", 0, NULL, &flag))
+			 resolve_ref_unsafe("HEAD", 0, NULL, &unused_flags))
 			puts(_("HEAD is up to date, rebase forced."));
 		else
 			printf(_("Current branch %s is up to date, rebase "
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index b189487a17b..9ba14922352 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -291,7 +291,7 @@ static void show_ref(const char *path, const struct object_id *oid)
 }
 
 static int show_ref_cb(const char *path_full, const struct object_id *oid,
-		       unsigned int flag, void *data)
+		       unsigned int unused_flags, void *data)
 {
 	struct oidset *seen = data;
 	const char *path = strip_namespace(path_full);
@@ -1645,12 +1645,13 @@ static void run_update_post_hook(struct command *commands)
 
 static void check_aliased_update_internal(struct command *cmd,
 					  struct string_list *list,
-					  const char *dst_name, int flag)
+					  const char *dst_name,
+					  unsigned int flags)
 {
 	struct string_list_item *item;
 	struct command *dst_cmd;
 
-	if (!(flag & REF_ISSYMREF))
+	if (!(flags & REF_ISSYMREF))
 		return;
 
 	if (!dst_name) {
@@ -1691,11 +1692,11 @@ static void check_aliased_update(struct command *cmd, struct string_list *list)
 {
 	struct strbuf buf = STRBUF_INIT;
 	const char *dst_name;
-	unsigned int flag;
+	unsigned int flags;
 
 	strbuf_addf(&buf, "%s%s", get_git_namespace(), cmd->ref_name);
-	dst_name = resolve_ref_unsafe(buf.buf, 0, NULL, &flag);
-	check_aliased_update_internal(cmd, list, dst_name, flag);
+	dst_name = resolve_ref_unsafe(buf.buf, 0, NULL, &flags);
+	check_aliased_update_internal(cmd, list, dst_name, flags);
 	strbuf_release(&buf);
 }
 
diff --git a/builtin/reflog.c b/builtin/reflog.c
index 278e895cc57..87d09c941a7 100644
--- a/builtin/reflog.c
+++ b/builtin/reflog.c
@@ -417,7 +417,7 @@ static void reflog_expiry_cleanup(void *cb_data)
 }
 
 static int collect_reflog(const char *ref, const struct object_id *oid,
-			  unsigned int unused, void *cb_data)
+			  unsigned int unused_flags, void *cb_data)
 {
 	struct worktree_reflogs *cb = cb_data;
 	struct worktree *worktree = cb->worktree;
diff --git a/builtin/remote.c b/builtin/remote.c
index 92ac729aeab..b95c5aa2fdf 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -534,7 +534,7 @@ struct branches_for_remote {
 
 static int add_branch_for_removal(const char *refname,
 				  const struct object_id *oid,
-				  unsigned int flags, void *cb_data)
+				  unsigned int unused_flags, void *cb_data)
 {
 	struct branches_for_remote *branches = cb_data;
 	struct refspec_item refspec;
@@ -575,21 +575,21 @@ struct rename_info {
 };
 
 static int read_remote_branches(const char *refname,
-				const struct object_id *oid, unsigned int flags,
-				void *cb_data)
+				const struct object_id *oid,
+				unsigned int unused_flags, void *cb_data)
 {
 	struct rename_info *rename = cb_data;
 	struct strbuf buf = STRBUF_INIT;
 	struct string_list_item *item;
-	unsigned int flag;
 	const char *symref;
 
 	strbuf_addf(&buf, "refs/remotes/%s/", rename->old_name);
 	if (starts_with(refname, buf.buf)) {
+		unsigned int flags;
 		item = string_list_append(rename->remote_branches, refname);
-		symref = resolve_ref_unsafe(refname, RESOLVE_REF_READING,
-					    NULL, &flag);
-		if (symref && (flag & REF_ISSYMREF))
+		symref = resolve_ref_unsafe(refname, RESOLVE_REF_READING, NULL,
+					    &flags);
+		if (symref && (flags & REF_ISSYMREF))
 			item->util = xstrdup(symref);
 		else
 			item->util = NULL;
@@ -768,10 +768,10 @@ static int mv(int argc, const char **argv)
 	for_each_ref(read_remote_branches, &rename);
 	for (i = 0; i < remote_branches.nr; i++) {
 		struct string_list_item *item = remote_branches.items + i;
-		unsigned int flag = 0;
+		unsigned int flags = 0;
 
-		read_ref_full(item->string, RESOLVE_REF_READING, NULL, &flag);
-		if (!(flag & REF_ISSYMREF))
+		read_ref_full(item->string, RESOLVE_REF_READING, NULL, &flags);
+		if (!(flags & REF_ISSYMREF))
 			continue;
 		if (delete_ref(NULL, item->string, NULL, REF_NO_DEREF))
 			die(_("deleting '%s' failed"), item->string);
diff --git a/builtin/repack.c b/builtin/repack.c
index ff6ddc0f357..f995f829970 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -464,8 +464,8 @@ struct midx_snapshot_ref_data {
 };
 
 static int midx_snapshot_ref_one(const char *refname,
-				 const struct object_id *oid, unsigned int flag,
-				 void *_data)
+				 const struct object_id *oid,
+				 unsigned int unused_flag, void *_data)
 {
 	struct midx_snapshot_ref_data *data = _data;
 	struct object_id peeled;
diff --git a/builtin/replace.c b/builtin/replace.c
index 26bc9daba35..55677f4df45 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -40,8 +40,8 @@ struct show_data {
 };
 
 static int show_reference(struct repository *r, const char *refname,
-			  const struct object_id *oid, unsigned int flag,
-			  void *cb_data)
+			  const struct object_id *oid,
+			  unsigned int unused_flags, void *cb_data)
 {
 	struct show_data *data = cb_data;
 
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index b842c958f20..46f09c25db6 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -196,7 +196,7 @@ static int show_default(void)
 }
 
 static int show_reference(const char *refname, const struct object_id *oid,
-			  unsigned int flag, void *cb_data)
+			  unsigned int unused_flags, void *cb_data)
 {
 	if (ref_excluded(ref_excludes, refname))
 		return 0;
@@ -205,7 +205,7 @@ static int show_reference(const char *refname, const struct object_id *oid,
 }
 
 static int anti_reference(const char *refname, const struct object_id *oid,
-			  unsigned int flag, void *cb_data)
+			  unsigned int unused_flags, void *cb_data)
 {
 	show_rev(REVERSED, oid, refname);
 	return 0;
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index 625ba0c28ce..8c392afcd74 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -403,7 +403,7 @@ static int append_ref(const char *refname, const struct object_id *oid,
 }
 
 static int append_head_ref(const char *refname, const struct object_id *oid,
-			   unsigned int flag, void *cb_data)
+			   unsigned int unused_flags, void *cb_data)
 {
 	struct object_id tmp;
 	int ofs = 11;
@@ -418,7 +418,7 @@ static int append_head_ref(const char *refname, const struct object_id *oid,
 }
 
 static int append_remote_ref(const char *refname, const struct object_id *oid,
-			     unsigned int flag, void *cb_data)
+			     unsigned int unused_flags, void *cb_data)
 {
 	struct object_id tmp;
 	int ofs = 13;
@@ -433,7 +433,7 @@ static int append_remote_ref(const char *refname, const struct object_id *oid,
 }
 
 static int append_tag_ref(const char *refname, const struct object_id *oid,
-			  int flag, void *cb_data)
+			  int unused_flags, void *cb_data)
 {
 	if (!starts_with(refname, "refs/tags/"))
 		return 0;
@@ -444,7 +444,7 @@ static const char *match_ref_pattern = NULL;
 static int match_ref_slash = 0;
 
 static int append_matching_ref(const char *refname, const struct object_id *oid,
-			       unsigned int flag, void *cb_data)
+			       unsigned int flags, void *cb_data)
 {
 	/* we want to allow pattern hold/<asterisk> to show all
 	 * branches under refs/heads/hold/, and v0.99.9? to show
@@ -460,9 +460,9 @@ static int append_matching_ref(const char *refname, const struct object_id *oid,
 	if (wildmatch(match_ref_pattern, tail, 0))
 		return 0;
 	if (starts_with(refname, "refs/heads/"))
-		return append_head_ref(refname, oid, flag, cb_data);
+		return append_head_ref(refname, oid, flags, cb_data);
 	if (starts_with(refname, "refs/tags/"))
-		return append_tag_ref(refname, oid, flag, cb_data);
+		return append_tag_ref(refname, oid, flags, cb_data);
 	return append_ref(refname, oid, 0);
 }
 
diff --git a/builtin/show-ref.c b/builtin/show-ref.c
index 09b708daf5b..ff017b1202a 100644
--- a/builtin/show-ref.c
+++ b/builtin/show-ref.c
@@ -86,7 +86,7 @@ match:
 }
 
 static int add_existing(const char *refname, const struct object_id *oid,
-			unsigned int flag, void *cbdata)
+			unsigned int unused_flags, void *cbdata)
 {
 	struct string_list *list = (struct string_list *)cbdata;
 	string_list_insert(list, refname);
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 320ecd04117..bbced5a3ef7 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -741,7 +741,7 @@ static void print_status(unsigned int flags, char state, const char *path,
 
 static int handle_submodule_head_ref(const char *refname,
 				     const struct object_id *oid,
-				     unsigned int flags, void *cb_data)
+				     unsigned int unused_flags, void *cb_data)
 {
 	struct object_id *output = cb_data;
 	if (oid)
diff --git a/builtin/symbolic-ref.c b/builtin/symbolic-ref.c
index 1ad2997e979..478ae36b4da 100644
--- a/builtin/symbolic-ref.c
+++ b/builtin/symbolic-ref.c
@@ -12,12 +12,12 @@ static const char * const git_symbolic_ref_usage[] = {
 
 static int check_symref(const char *HEAD, int quiet, int shorten, int print)
 {
-	unsigned int flag;
-	const char *refname = resolve_ref_unsafe(HEAD, 0, NULL, &flag);
+	unsigned int flags;
+	const char *refname = resolve_ref_unsafe(HEAD, 0, NULL, &flags);
 
 	if (!refname)
 		die("No such ref: %s", HEAD);
-	else if (!(flag & REF_ISSYMREF)) {
+	else if (!(flags & REF_ISSYMREF)) {
 		if (!quiet)
 			die("ref %s is not a symbolic ref", HEAD);
 		else
diff --git a/bundle.c b/bundle.c
index da4442d4f1a..a6658dab789 100644
--- a/bundle.c
+++ b/bundle.c
@@ -371,15 +371,15 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
 		struct object_id oid;
 		char *ref;
 		const char *display_ref;
-		unsigned int flag;
+		unsigned int flags;
 
 		if (e->item->flags & UNINTERESTING)
 			continue;
 		if (dwim_ref(e->name, strlen(e->name), &oid, &ref, 0) != 1)
 			goto skip_write_ref;
-		if (read_ref_full(e->name, RESOLVE_REF_READING, &oid, &flag))
-			flag = 0;
-		display_ref = (flag & REF_ISSYMREF) ? e->name : ref;
+		if (read_ref_full(e->name, RESOLVE_REF_READING, &oid, &flags))
+			flags = 0;
+		display_ref = (flags & REF_ISSYMREF) ? e->name : ref;
 
 		if (e->item->type == OBJ_TAG &&
 				!is_tag_in_date_range(e->item, revs)) {
diff --git a/delta-islands.c b/delta-islands.c
index dba5454ba01..b53b8dc7f4a 100644
--- a/delta-islands.c
+++ b/delta-islands.c
@@ -365,7 +365,7 @@ static void add_ref_to_island(const char *island_name, const struct object_id *o
 }
 
 static int find_island_for_ref(const char *refname, const struct object_id *oid,
-			       unsigned int flags, void *data)
+			       unsigned int unused_flags, void *data)
 {
 	/*
 	 * We should advertise 'ARRAY_SIZE(matches) - 2' as the max,
diff --git a/fetch-pack.c b/fetch-pack.c
index 19671a30089..43a74beeb10 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -166,7 +166,7 @@ static int rev_list_insert_ref(struct fetch_negotiator *negotiator,
 
 static int rev_list_insert_ref_oid(const char *refname,
 				   const struct object_id *oid,
-				   unsigned int flag, void *cb_data)
+				   unsigned int unused_flags, void *cb_data)
 {
 	return rev_list_insert_ref(cb_data, oid);
 }
@@ -549,7 +549,7 @@ static int mark_complete(const struct object_id *oid)
 }
 
 static int mark_complete_oid(const char *refname, const struct object_id *oid,
-			     unsigned int flag, void *cb_data)
+			     unsigned int unused_flags, void *cb_data)
 {
 	return mark_complete(oid);
 }
diff --git a/http-backend.c b/http-backend.c
index c8757e601d1..351a124333b 100644
--- a/http-backend.c
+++ b/http-backend.c
@@ -559,11 +559,11 @@ static void get_info_refs(struct strbuf *hdr, char *arg)
 }
 
 static int show_head_ref(const char *refname, const struct object_id *oid,
-			 unsigned int flag, void *cb_data)
+			 unsigned int flags, void *cb_data)
 {
 	struct strbuf *buf = cb_data;
 
-	if (flag & REF_ISSYMREF) {
+	if (flags & REF_ISSYMREF) {
 		const char *target = resolve_ref_unsafe(refname,
 							RESOLVE_REF_READING,
 							NULL, NULL);
diff --git a/log-tree.c b/log-tree.c
index 555a08b45c0..0e5452b0505 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -135,7 +135,7 @@ static int ref_filter_match(const char *refname,
 }
 
 static int add_ref_decoration(const char *refname, const struct object_id *oid,
-			      unsigned int flags, void *cb_data)
+			      unsigned int unused_flags, void *cb_data)
 {
 	struct object *obj;
 	enum object_type objtype;
diff --git a/ls-refs.c b/ls-refs.c
index 42ba85b371b..26bfd49556d 100644
--- a/ls-refs.c
+++ b/ls-refs.c
@@ -77,7 +77,7 @@ struct ls_refs_data {
 };
 
 static int send_ref(const char *refname, const struct object_id *oid,
-		    unsigned int flag, void *cb_data)
+		    unsigned int flags, void *cb_data)
 {
 	struct ls_refs_data *data = cb_data;
 	const char *refname_nons = strip_namespace(refname);
@@ -94,11 +94,10 @@ static int send_ref(const char *refname, const struct object_id *oid,
 		strbuf_addf(&data->buf, "%s %s", oid_to_hex(oid), refname_nons);
 	else
 		strbuf_addf(&data->buf, "unborn %s", refname_nons);
-	if (data->symrefs && flag & REF_ISSYMREF) {
+	if (data->symrefs && flags & REF_ISSYMREF) {
 		struct object_id unused;
-		const char *symref_target = resolve_ref_unsafe(refname, 0,
-							       &unused,
-							       &flag);
+		const char *symref_target =
+			resolve_ref_unsafe(refname, 0, &unused, &flags);
 
 		if (!symref_target)
 			die("'%s' is a symref but it is not?", refname);
@@ -123,16 +122,17 @@ static void send_possibly_unborn_head(struct ls_refs_data *data)
 {
 	struct strbuf namespaced = STRBUF_INIT;
 	struct object_id oid;
-	unsigned int flag;
+	unsigned int flags;
 	int oid_is_null;
 
 	strbuf_addf(&namespaced, "%sHEAD", get_git_namespace());
-	if (!resolve_ref_unsafe(namespaced.buf, 0, &oid, &flag))
+	if (!resolve_ref_unsafe(namespaced.buf, 0, &oid, &flags))
 		return; /* bad ref */
 	oid_is_null = is_null_oid(&oid);
 	if (!oid_is_null ||
-	    (data->unborn && data->symrefs && (flag & REF_ISSYMREF)))
-		send_ref(namespaced.buf, oid_is_null ? NULL : &oid, flag, data);
+	    (data->unborn && data->symrefs && (flags & REF_ISSYMREF)))
+		send_ref(namespaced.buf, oid_is_null ? NULL : &oid, flags,
+			 data);
 	strbuf_release(&namespaced);
 }
 
diff --git a/midx.c b/midx.c
index 41cad25e099..0adb5b0c228 100644
--- a/midx.c
+++ b/midx.c
@@ -939,12 +939,12 @@ static void prepare_midx_packing_data(struct packing_data *pdata,
 }
 
 static int add_ref_to_pending(const char *refname, const struct object_id *oid,
-			      unsigned int flag, void *cb_data)
+			      unsigned int flags, void *cb_data)
 {
 	struct rev_info *revs = (struct rev_info*)cb_data;
 	struct object *object;
 
-	if ((flag & REF_ISSYMREF) && (flag & REF_ISBROKEN)) {
+	if ((flags & REF_ISSYMREF) && (flags & REF_ISBROKEN)) {
 		warning("symbolic ref is dangling: %s", refname);
 		return 0;
 	}
diff --git a/negotiator/default.c b/negotiator/default.c
index 3f911f6b633..7ddc40e480b 100644
--- a/negotiator/default.c
+++ b/negotiator/default.c
@@ -36,7 +36,7 @@ static void rev_list_push(struct negotiation_state *ns,
 }
 
 static int clear_marks(const char *refname, const struct object_id *oid,
-		       unsigned int flag, void *cb_data)
+		       unsigned int unused_flags, void *cb_data)
 {
 	struct object *o = deref_tag(the_repository, parse_object(the_repository, oid), refname, 0);
 
diff --git a/negotiator/skipping.c b/negotiator/skipping.c
index 0e6f72987c1..6ac6310b247 100644
--- a/negotiator/skipping.c
+++ b/negotiator/skipping.c
@@ -72,7 +72,7 @@ static struct entry *rev_list_push(struct data *data, struct commit *commit, int
 }
 
 static int clear_marks(const char *refname, const struct object_id *oid,
-		       unsigned int flag, void *cb_data)
+		       unsigned int unused_flags, void *cb_data)
 {
 	struct object *o = deref_tag(the_repository, parse_object(the_repository, oid), refname, 0);
 
diff --git a/notes.c b/notes.c
index e9638a40f0e..1b6f747baf9 100644
--- a/notes.c
+++ b/notes.c
@@ -926,7 +926,7 @@ out:
 
 static int string_list_add_one_ref(const char *refname,
 				   const struct object_id *oid,
-				   unsigned int flag, void *cb)
+				   unsigned int unused_flags, void *cb)
 {
 	struct string_list *refs = cb;
 	if (!unsorted_string_list_has_string(refs, refname))
diff --git a/object-name.c b/object-name.c
index 5561365c9a1..36820a58275 100644
--- a/object-name.c
+++ b/object-name.c
@@ -1305,7 +1305,7 @@ struct handle_one_ref_cb {
 };
 
 static int handle_one_ref(const char *path, const struct object_id *oid,
-			  unsigned int flag, void *cb_data)
+			  unsigned int unused_flags, void *cb_data)
 {
 	struct handle_one_ref_cb *cb = cb_data;
 	struct commit_list **list = cb->list;
diff --git a/reachable.c b/reachable.c
index 74e8ee81bbe..fc04a57cbf6 100644
--- a/reachable.c
+++ b/reachable.c
@@ -27,12 +27,12 @@ static void update_progress(struct connectivity_progress *cp)
 }
 
 static int add_one_ref(const char *path, const struct object_id *oid,
-		       unsigned int flag, void *cb_data)
+		       unsigned int flags, void *cb_data)
 {
 	struct rev_info *revs = (struct rev_info *)cb_data;
 	struct object *object;
 
-	if ((flag & REF_ISSYMREF) && (flag & REF_ISBROKEN)) {
+	if ((flags & REF_ISSYMREF) && (flags & REF_ISBROKEN)) {
 		warning("symbolic ref is dangling: %s", path);
 		return 0;
 	}
diff --git a/ref-filter.c b/ref-filter.c
index f51779bd725..addb7a237a4 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -2234,7 +2234,7 @@ struct ref_filter_cbdata {
  * later object processing.
  */
 static int ref_filter_handler(const char *refname, const struct object_id *oid,
-			      unsigned int flag, void *cb_data)
+			      unsigned int flags, void *cb_data)
 {
 	struct ref_filter_cbdata *ref_cbdata = cb_data;
 	struct ref_filter *filter = ref_cbdata->filter;
@@ -2242,12 +2242,12 @@ static int ref_filter_handler(const char *refname, const struct object_id *oid,
 	struct commit *commit = NULL;
 	unsigned int kind;
 
-	if (flag & REF_BAD_NAME) {
+	if (flags & REF_BAD_NAME) {
 		warning(_("ignoring ref with broken name %s"), refname);
 		return 0;
 	}
 
-	if (flag & REF_ISBROKEN) {
+	if (flags & REF_ISBROKEN) {
 		warning(_("ignoring broken ref %s"), refname);
 		return 0;
 	}
@@ -2290,7 +2290,7 @@ static int ref_filter_handler(const char *refname, const struct object_id *oid,
 	 */
 	ref = ref_array_push(ref_cbdata->array, refname, oid);
 	ref->commit = commit;
-	ref->flag = flag;
+	ref->flag = flags;
 	ref->kind = kind;
 
 	return 0;
diff --git a/refs.c b/refs.c
index 2ca398b8527..a8f60fe73cb 100644
--- a/refs.c
+++ b/refs.c
@@ -438,11 +438,11 @@ int head_ref_namespaced(each_ref_fn fn, void *cb_data)
 	struct strbuf buf = STRBUF_INIT;
 	int ret = 0;
 	struct object_id oid;
-	unsigned int flag;
+	unsigned int flags;
 
 	strbuf_addf(&buf, "%sHEAD", get_git_namespace());
-	if (!read_ref_full(buf.buf, RESOLVE_REF_READING, &oid, &flag))
-		ret = fn(buf.buf, &oid, flag, cb_data);
+	if (!read_ref_full(buf.buf, RESOLVE_REF_READING, &oid, &flags))
+		ret = fn(buf.buf, &oid, flags, cb_data);
 	strbuf_release(&buf);
 
 	return ret;
@@ -653,23 +653,24 @@ int expand_ref(struct repository *repo, const char *str, int len,
 	for (p = ref_rev_parse_rules; *p; p++) {
 		struct object_id oid_from_ref;
 		struct object_id *this_result;
-		unsigned int flag;
+		unsigned int flags;
 		struct ref_store *refs = get_main_ref_store(repo);
 
 		this_result = refs_found ? &oid_from_ref : oid;
 		strbuf_reset(&fullref);
 		strbuf_addf(&fullref, *p, len, str);
 		r = refs_resolve_ref_unsafe(refs, fullref.buf,
-					    RESOLVE_REF_READING,
-					    this_result, &flag);
+					    RESOLVE_REF_READING, this_result,
+					    &flags);
 		if (r) {
 			if (!refs_found++)
 				*ref = xstrdup(r);
 			if (!warn_ambiguous_refs)
 				break;
-		} else if ((flag & REF_ISSYMREF) && strcmp(fullref.buf, "HEAD")) {
+		} else if ((flags & REF_ISSYMREF) &&
+			   strcmp(fullref.buf, "HEAD")) {
 			warning(_("ignoring dangling symref %s"), fullref.buf);
-		} else if ((flag & REF_ISBROKEN) && strchr(fullref.buf, '/')) {
+		} else if ((flags & REF_ISBROKEN) && strchr(fullref.buf, '/')) {
 			warning(_("ignoring broken ref %s"), fullref.buf);
 		}
 	}
@@ -1386,11 +1387,11 @@ const char *find_descendant_ref(const char *dirname,
 int refs_head_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
 {
 	struct object_id oid;
-	unsigned int flag;
+	unsigned int flags;
 
-	if (refs_resolve_ref_unsafe(refs, "HEAD", RESOLVE_REF_READING,
-				    &oid, &flag))
-		return fn("HEAD", &oid, flag, cb_data);
+	if (refs_resolve_ref_unsafe(refs, "HEAD", RESOLVE_REF_READING, &oid,
+				    &flags))
+		return fn("HEAD", &oid, flags, cb_data);
 
 	return 0;
 }
@@ -1778,14 +1779,14 @@ int resolve_gitlink_ref(const char *submodule, const char *refname,
 			struct object_id *oid)
 {
 	struct ref_store *refs;
-	unsigned int flags;
+	unsigned int unused_flags;
 
 	refs = get_submodule_ref_store(submodule);
 
 	if (!refs)
 		return -1;
 
-	if (!refs_resolve_ref_unsafe(refs, refname, 0, oid, &flags) ||
+	if (!refs_resolve_ref_unsafe(refs, refname, 0, oid, &unused_flags) ||
 	    is_null_oid(oid))
 		return -1;
 	return 0;
diff --git a/refs/files-backend.c b/refs/files-backend.c
index b3149ca493b..fe2e1a43e00 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -261,7 +261,6 @@ static void loose_fill_ref_dir(struct ref_store *ref_store,
 	while ((de = readdir(d)) != NULL) {
 		struct object_id oid;
 		struct stat st;
-		unsigned int flag;
 
 		if (de->d_name[0] == '.')
 			continue;
@@ -277,12 +276,12 @@ static void loose_fill_ref_dir(struct ref_store *ref_store,
 					 create_dir_entry(dir->cache, refname.buf,
 							  refname.len));
 		} else {
-			if (!refs_resolve_ref_unsafe(&refs->base,
-						     refname.buf,
-						     RESOLVE_REF_READING,
-						     &oid, &flag)) {
+			unsigned int flags;
+			if (!refs_resolve_ref_unsafe(&refs->base, refname.buf,
+						     RESOLVE_REF_READING, &oid,
+						     &flags)) {
 				oidclr(&oid);
-				flag |= REF_ISBROKEN;
+				flags |= REF_ISBROKEN;
 			} else if (is_null_oid(&oid)) {
 				/*
 				 * It is so astronomically unlikely
@@ -292,7 +291,7 @@ static void loose_fill_ref_dir(struct ref_store *ref_store,
 				 * file to be repo corruption
 				 * (probably due to a software bug).
 				 */
-				flag |= REF_ISBROKEN;
+				flags |= REF_ISBROKEN;
 			}
 
 			if (check_refname_format(refname.buf,
@@ -300,10 +299,10 @@ static void loose_fill_ref_dir(struct ref_store *ref_store,
 				if (!refname_is_safe(refname.buf))
 					die("loose refname is dangerous: %s", refname.buf);
 				oidclr(&oid);
-				flag |= REF_BAD_NAME | REF_ISBROKEN;
+				flags |= REF_BAD_NAME | REF_ISBROKEN;
 			}
-			add_entry_to_dir(dir,
-					 create_ref_entry(refname.buf, &oid, flag));
+			add_entry_to_dir(dir, create_ref_entry(refname.buf,
+							       &oid, flags));
 		}
 		strbuf_setlen(&refname, dirnamelen);
 		strbuf_setlen(&path, path_baselen);
@@ -1400,7 +1399,7 @@ static int files_copy_or_rename_ref(struct ref_store *ref_store,
 		files_downcast(ref_store, REF_STORE_WRITE, "rename_ref");
 	struct object_id orig_oid;
 	int logmoved = 0;
-	unsigned int flag = 0;
+	unsigned int flags = 0;
 	struct ref_lock *lock;
 	struct stat loginfo;
 	struct strbuf sb_oldref = STRBUF_INIT;
@@ -1420,13 +1419,14 @@ static int files_copy_or_rename_ref(struct ref_store *ref_store,
 	}
 
 	if (!refs_resolve_ref_unsafe(&refs->base, oldrefname,
-				     RESOLVE_REF_READING | RESOLVE_REF_NO_RECURSE,
-				     &orig_oid, &flag)) {
+				     RESOLVE_REF_READING |
+					     RESOLVE_REF_NO_RECURSE,
+				     &orig_oid, &flags)) {
 		ret = error("refname %s not found", oldrefname);
 		goto out;
 	}
 
-	if (flag & REF_ISSYMREF) {
+	if (flags & REF_ISSYMREF) {
 		if (copy)
 			ret = error("refname %s is a symbolic ref, copying it is not supported",
 				    oldrefname);
@@ -1522,14 +1522,14 @@ static int files_copy_or_rename_ref(struct ref_store *ref_store,
 		goto rollbacklog;
 	}
 
-	flag = log_all_ref_updates;
+	flags = log_all_ref_updates;
 	log_all_ref_updates = LOG_REFS_NONE;
 	if (write_ref_to_lockfile(lock, &orig_oid, 0, &err) ||
 	    commit_ref_update(refs, lock, &orig_oid, NULL, &err)) {
 		error("unable to write current sha1 into %s: %s", oldrefname, err.buf);
 		strbuf_release(&err);
 	}
-	log_all_ref_updates = flag;
+	log_all_ref_updates = flags;
 
  rollbacklog:
 	if (logmoved && rename(sb_newref.buf, sb_oldref.buf))
@@ -1710,9 +1710,10 @@ static int log_ref_write_fd(int fd, const struct object_id *old_oid,
 }
 
 static int files_log_ref_write(struct files_ref_store *refs,
-			       const char *refname, const struct object_id *old_oid,
+			       const char *refname,
+			       const struct object_id *old_oid,
 			       const struct object_id *new_oid, const char *msg,
-			       int flags, struct strbuf *err)
+			       unsigned int flags, struct strbuf *err)
 {
 	int logfd, result;
 
@@ -1834,13 +1835,13 @@ static int commit_ref_update(struct files_ref_store *refs,
 		 * check with HEAD only which should cover 99% of all usage
 		 * scenarios (even 100% of the default ones).
 		 */
-		unsigned int head_flag;
+		unsigned int head_flags;
 		const char *head_ref;
 
 		head_ref = refs_resolve_ref_unsafe(&refs->base, "HEAD",
-						   RESOLVE_REF_READING,
-						   NULL, &head_flag);
-		if (head_ref && (head_flag & REF_ISSYMREF) &&
+						   RESOLVE_REF_READING, NULL,
+						   &head_flags);
+		if (head_ref && (head_flags & REF_ISSYMREF) &&
 		    !strcmp(head_ref, lock->ref_name)) {
 			struct strbuf log_err = STRBUF_INIT;
 			if (files_log_ref_write(refs, "HEAD",
@@ -2984,7 +2985,7 @@ static int files_transaction_abort(struct ref_store *ref_store,
 }
 
 static int ref_present(const char *refname, const struct object_id *oid,
-		       unsigned int flags, void *cb_data)
+		       unsigned int unused_flags, void *cb_data)
 {
 	struct string_list *affected_refnames = cb_data;
 
diff --git a/remote.c b/remote.c
index ff21b77f643..402ec7d9472 100644
--- a/remote.c
+++ b/remote.c
@@ -500,7 +500,7 @@ static void alias_all_urls(struct remote_state *remote_state)
 
 static void read_config(struct repository *repo)
 {
-	unsigned int flag;
+	unsigned int flags;
 
 	if (repo->remote_state->initialized)
 		return;
@@ -509,8 +509,8 @@ static void read_config(struct repository *repo)
 	repo->remote_state->current_branch = NULL;
 	if (startup_info->have_repository) {
 		const char *head_ref = refs_resolve_ref_unsafe(
-			get_main_ref_store(repo), "HEAD", 0, NULL, &flag);
-		if (head_ref && (flag & REF_ISSYMREF) &&
+			get_main_ref_store(repo), "HEAD", 0, NULL, &flags);
+		if (head_ref && (flags & REF_ISSYMREF) &&
 		    skip_prefix(head_ref, "refs/heads/", &head_ref)) {
 			repo->remote_state->current_branch = make_branch(
 				repo->remote_state, head_ref, strlen(head_ref));
@@ -1271,14 +1271,12 @@ static int match_explicit(struct ref *src, struct ref *dst,
 		return -1;
 
 	if (!dst_value) {
-		unsigned int flag;
-
-		dst_value = resolve_ref_unsafe(matched_src->name,
-					       RESOLVE_REF_READING,
-					       NULL, &flag);
-		if (!dst_value ||
-		    ((flag & REF_ISSYMREF) &&
-		     !starts_with(dst_value, "refs/heads/")))
+		unsigned int flags;
+
+		dst_value = resolve_ref_unsafe(
+			matched_src->name, RESOLVE_REF_READING, NULL, &flags);
+		if (!dst_value || ((flags & REF_ISSYMREF) &&
+				   !starts_with(dst_value, "refs/heads/")))
 			die(_("%s cannot be resolved to branch"),
 			    matched_src->name);
 	}
@@ -1947,11 +1945,11 @@ const char *branch_get_push(struct branch *branch, struct strbuf *err)
 
 static int ignore_symref_update(const char *refname)
 {
-	unsigned int flag;
+	unsigned int flags;
 
-	if (!resolve_ref_unsafe(refname, 0, NULL, &flag))
+	if (!resolve_ref_unsafe(refname, 0, NULL, &flags))
 		return 0; /* non-existing refs are OK */
-	return (flag & REF_ISSYMREF);
+	return (flags & REF_ISSYMREF);
 }
 
 /*
diff --git a/replace-object.c b/replace-object.c
index 1a9ed348661..d00486305a5 100644
--- a/replace-object.c
+++ b/replace-object.c
@@ -7,8 +7,8 @@
 #include "commit.h"
 
 static int register_replace_ref(struct repository *r, const char *refname,
-				const struct object_id *oid, unsigned int flag,
-				void *cb_data)
+				const struct object_id *oid,
+				unsigned int unused_flags, void *cb_data)
 {
 	/* Get sha1 from refname */
 	const char *slash = strrchr(refname, '/');
diff --git a/revision.c b/revision.c
index ccdb069af1a..80984f583de 100644
--- a/revision.c
+++ b/revision.c
@@ -1535,7 +1535,7 @@ int ref_excluded(struct string_list *ref_excludes, const char *path)
 }
 
 static int handle_one_ref(const char *path, const struct object_id *oid,
-			  unsigned int flag, void *cb_data)
+			  unsigned int unused_flags, void *cb_data)
 {
 	struct all_refs_cb *cb = cb_data;
 	struct object *object;
@@ -1619,8 +1619,8 @@ static int handle_one_reflog_ent(struct object_id *ooid, struct object_id *noid,
 }
 
 static int handle_one_reflog(const char *refname_in_wt,
-			     const struct object_id *oid, unsigned int flag,
-			     void *cb_data)
+			     const struct object_id *oid,
+			     unsigned int unused_flags, void *cb_data)
 {
 	struct all_refs_cb *cb = cb_data;
 	struct strbuf refname = STRBUF_INIT;
diff --git a/server-info.c b/server-info.c
index 78119897d30..06e3eb388ea 100644
--- a/server-info.c
+++ b/server-info.c
@@ -147,7 +147,7 @@ out:
 }
 
 static int add_info_ref(const char *path, const struct object_id *oid,
-			unsigned int flag, void *cb_data)
+			unsigned int unused_flags, void *cb_data)
 {
 	struct update_info_ctx *uic = cb_data;
 	struct object *o = parse_object(the_repository, oid);
diff --git a/shallow.c b/shallow.c
index da9f1e28e93..189cfa4d90a 100644
--- a/shallow.c
+++ b/shallow.c
@@ -596,7 +596,7 @@ static void paint_down(struct paint_info *info, const struct object_id *oid,
 }
 
 static int mark_uninteresting(const char *refname, const struct object_id *oid,
-			      unsigned int flags, void *cb_data)
+			      unsigned int unused_flags, void *cb_data)
 {
 	struct commit *commit = lookup_commit_reference_gently(the_repository,
 							       oid, 1);
@@ -707,7 +707,7 @@ struct commit_array {
 };
 
 static int add_ref(const char *refname, const struct object_id *oid,
-		   unsigned int flags, void *cb_data)
+		   unsigned int unused_flags, void *cb_data)
 {
 	struct commit_array *ca = cb_data;
 	ALLOC_GROW(ca->commits, ca->nr + 1, ca->alloc);
diff --git a/submodule.c b/submodule.c
index e5c5d9aa6be..fac2bee0bec 100644
--- a/submodule.c
+++ b/submodule.c
@@ -916,7 +916,7 @@ static void free_submodules_oids(struct string_list *submodules)
 }
 
 static int has_remote(const char *refname, const struct object_id *oid,
-		      unsigned int flags, void *cb_data)
+		      unsigned int unused_flags, void *cb_data)
 {
 	return 1;
 }
@@ -1223,7 +1223,7 @@ int push_unpushed_submodules(struct repository *r,
 }
 
 static int append_oid_to_array(const char *ref, const struct object_id *oid,
-			       unsigned int flags, void *data)
+			       unsigned int unused_flags, void *data)
 {
 	struct oid_array *array = data;
 	oid_array_append(array, oid);
diff --git a/transport-helper.c b/transport-helper.c
index c207103aaff..b31c1198b8e 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -1090,13 +1090,15 @@ static int push_refs_with_export(struct transport *transport,
 			if (strcmp(ref->name, ref->peer_ref->name)) {
 				if (!ref->deletion) {
 					const char *name;
-					unsigned int flag;
+					unsigned int ref_flags;
 
 					/* Follow symbolic refs (mainly for HEAD). */
-					name = resolve_ref_unsafe(ref->peer_ref->name,
-								  RESOLVE_REF_READING,
-								  &oid, &flag);
-					if (!name || !(flag & REF_ISSYMREF))
+					name = resolve_ref_unsafe(
+						ref->peer_ref->name,
+						RESOLVE_REF_READING, &oid,
+						&ref_flags);
+					if (!name ||
+					    !(ref_flags & REF_ISSYMREF))
 						name = ref->peer_ref->name;
 
 					strbuf_addf(&buf, "%s:%s", name, ref->name);
diff --git a/transport.c b/transport.c
index 5b6d5d29388..00f4906e12b 100644
--- a/transport.c
+++ b/transport.c
@@ -80,7 +80,7 @@ static void set_upstreams(struct transport *transport, struct ref *refs,
 		const char *localname;
 		const char *tmp;
 		const char *remotename;
-		unsigned int flag = 0;
+		unsigned int ref_flags = 0;
 		/*
 		 * Check suitability for tracking. Must be successful /
 		 * already up-to-date ref create/modify (not delete).
@@ -96,10 +96,10 @@ static void set_upstreams(struct transport *transport, struct ref *refs,
 		/* Follow symbolic refs (mainly for HEAD). */
 		localname = ref->peer_ref->name;
 		remotename = ref->name;
-		tmp = resolve_ref_unsafe(localname, RESOLVE_REF_READING,
-					 NULL, &flag);
-		if (tmp && flag & REF_ISSYMREF &&
-			starts_with(tmp, "refs/heads/"))
+		tmp = resolve_ref_unsafe(localname, RESOLVE_REF_READING, NULL,
+					 &ref_flags);
+		if (tmp && ref_flags & REF_ISSYMREF &&
+		    starts_with(tmp, "refs/heads/"))
 			localname = tmp;
 
 		/* Both source and destination must be local branches. */
diff --git a/upload-pack.c b/upload-pack.c
index cb652db4f78..6300af75f20 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -1169,7 +1169,7 @@ static int mark_our_ref(const char *refname, const char *refname_full,
 }
 
 static int check_ref(const char *refname_full, const struct object_id *oid,
-		     unsigned int flag, void *cb_data)
+		     unsigned int unused_flags, void *cb_data)
 {
 	const char *refname = strip_namespace(refname_full);
 
@@ -1193,7 +1193,7 @@ static void format_session_id(struct strbuf *buf, struct upload_pack_data *d) {
 }
 
 static int send_ref(const char *refname, const struct object_id *oid,
-		    unsigned int flag, void *cb_data)
+		    unsigned int unused_flags, void *cb_data)
 {
 	static const char *capabilities = "multi_ack thin-pack side-band"
 		" side-band-64k ofs-delta shallow deepen-since deepen-not"
@@ -1236,15 +1236,15 @@ static int send_ref(const char *refname, const struct object_id *oid,
 }
 
 static int find_symref(const char *refname, const struct object_id *oid,
-		       unsigned int flag, void *cb_data)
+		       unsigned int flags, void *cb_data)
 {
 	const char *symref_target;
 	struct string_list_item *item;
 
-	if ((flag & REF_ISSYMREF) == 0)
+	if ((flags & REF_ISSYMREF) == 0)
 		return 0;
-	symref_target = resolve_ref_unsafe(refname, 0, NULL, &flag);
-	if (!symref_target || (flag & REF_ISSYMREF) == 0)
+	symref_target = resolve_ref_unsafe(refname, 0, NULL, &flags);
+	if (!symref_target || (flags & REF_ISSYMREF) == 0)
 		die("'%s' is a symref but it is not?", refname);
 	item = string_list_append(cb_data, strip_namespace(refname));
 	item->util = xstrdup(strip_namespace(symref_target));
diff --git a/walker.c b/walker.c
index c1b82504f51..af8ce53a15b 100644
--- a/walker.c
+++ b/walker.c
@@ -216,7 +216,7 @@ static int interpret_target(struct walker *walker, char *target, struct object_i
 }
 
 static int mark_complete(const char *path, const struct object_id *oid,
-			 unsigned int flag, void *cb_data)
+			 unsigned int unused_flags, void *cb_data)
 {
 	struct commit *commit = lookup_commit_reference_gently(the_repository,
 							       oid, 1);
diff --git a/worktree.c b/worktree.c
index 58c958e055a..69291ce4985 100644
--- a/worktree.c
+++ b/worktree.c
@@ -559,7 +559,7 @@ int other_head_refs(each_ref_fn fn, void *cb_data)
 	for (p = worktrees; *p; p++) {
 		struct worktree *wt = *p;
 		struct object_id oid;
-		unsigned int flag;
+		unsigned int flags;
 
 		if (wt->is_current)
 			continue;
@@ -567,10 +567,9 @@ int other_head_refs(each_ref_fn fn, void *cb_data)
 		strbuf_reset(&refname);
 		strbuf_worktree_ref(wt, &refname, "HEAD");
 		if (refs_resolve_ref_unsafe(get_main_ref_store(the_repository),
-					    refname.buf,
-					    RESOLVE_REF_READING,
-					    &oid, &flag))
-			ret = fn(refname.buf, &oid, flag, cb_data);
+					    refname.buf, RESOLVE_REF_READING,
+					    &oid, &flags))
+			ret = fn(refname.buf, &oid, flags, cb_data);
 		if (ret)
 			break;
 	}
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH v2] refs.h: make all flags arguments unsigned
  2022-02-01 23:03     ` Junio C Hamano
@ 2022-02-03 14:29       ` Han-Wen Nienhuys
  2022-02-03 17:53         ` Ævar Arnfjörð Bjarmason
  0 siblings, 1 reply; 17+ messages in thread
From: Han-Wen Nienhuys @ 2022-02-03 14:29 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Ævar Arnfjörð Bjarmason,
	Han-Wen Nienhuys via GitGitGadget, git, Han-Wen Nienhuys

On Wed, Feb 2, 2022 at 12:03 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>
> > The post-image LGTM, but I'm also a bit "meh" on the churn just for
> > signed->unsigned, especially given the conflict with my in-flight
> > ab/no-errno-from-resolve-ref-unsafe. But it's not too bad, and if Junio
> > hasn't complained about it...
>
> I won't complain myself.  I'd still try to help newer developers,
> but my intention is to make it the responsibility for individual
> developers to make sure their topic works well with topics in
> flight ;-)

I'm sending v3 based on seen.

> Between "enum" and #define that is stored in "unsigned", neither
> gives us much type safety in C; "enum" may be somewhat worse by
> giving a false sense of having a type safety that does not really
> exist, than "unsigned int" that is more honestly defeats such a
> false sense of safety.  So I have no strong preference either way.

Neither gives true type safety, and I don't know if an enum is kosher
at all; shouldn't the value always be one of the enumerees, strictly
speaking?

I proposed both options because a distinct typename lets me jump to
the definition of the flags easily through ctags.

Another idea is to mark the type of the flags by its name, eg.
transaction_flags, resolve_flags, reftype_flags etc. This wouldn't
help with ctags, but it does help with readability.

-- 
Han-Wen Nienhuys - Google Munich
I work 80%. Don't expect answers from me on Fridays.
--

Google Germany GmbH, Erika-Mann-Strasse 33, 80636 Munich

Registergericht und -nummer: Hamburg, HRB 86891

Sitz der Gesellschaft: Hamburg

Geschäftsführer: Paul Manicle, Halimah DeLaine Prado

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2] refs.h: make all flags arguments unsigned
  2022-02-03 14:29       ` Han-Wen Nienhuys
@ 2022-02-03 17:53         ` Ævar Arnfjörð Bjarmason
  2022-02-03 18:16           ` Han-Wen Nienhuys
  2022-02-03 18:27           ` Junio C Hamano
  0 siblings, 2 replies; 17+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2022-02-03 17:53 UTC (permalink / raw)
  To: Han-Wen Nienhuys
  Cc: Junio C Hamano, Han-Wen Nienhuys via GitGitGadget, git,
	Han-Wen Nienhuys


On Thu, Feb 03 2022, Han-Wen Nienhuys wrote:

> On Wed, Feb 2, 2022 at 12:03 AM Junio C Hamano <gitster@pobox.com> wrote:
>>
>> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>>
>> > The post-image LGTM, but I'm also a bit "meh" on the churn just for
>> > signed->unsigned, especially given the conflict with my in-flight
>> > ab/no-errno-from-resolve-ref-unsafe. But it's not too bad, and if Junio
>> > hasn't complained about it...
>>
>> I won't complain myself.  I'd still try to help newer developers,
>> but my intention is to make it the responsibility for individual
>> developers to make sure their topic works well with topics in
>> flight ;-)
>
> I'm sending v3 based on seen.
>
>> Between "enum" and #define that is stored in "unsigned", neither
>> gives us much type safety in C; "enum" may be somewhat worse by
>> giving a false sense of having a type safety that does not really
>> exist, than "unsigned int" that is more honestly defeats such a
>> false sense of safety.  So I have no strong preference either way.
>
> Neither gives true type safety, and I don't know if an enum is kosher
> at all; shouldn't the value always be one of the enumerees, strictly
> speaking?

No, it's nice so you can use it in switch/case, but it's also a
perfectly legit use-case to use it for bitfields.

And as I noted e.g. gdb will understand that and give you pretty-printed
flags based on that, which is very nice for debugging.

And it's also just nice for readability and source navigation. I.e. if
it's "unsigned int foo_flags" and I find "foo_flags" with [ce]tags I'll
only find all other uses of "foo_flags".

Whereas the enum will give me its definition, which usually has comments
etc.

To be fair it's usually easy to find it even without that, because
you'll find a use of a relevant "#define" pretty soon, and can navigate
to that. But sometimes that's 1-2 functions away if the flag is being
passed along.

So being able to navigate straight from the function arguments is nice,
as you can do with structs and other types.

> I proposed both options because a distinct typename lets me jump to
> the definition of the flags easily through ctags.

I'm not sure I understand you here. I use ctags (via Emacs) and it's
perfectly capable of finding both "enum xyz" and "typedef enum { ... }
xyz":
    
    $ make TAGS
    $ grep -e rewrite_result -e parse_opt_option_flags TAGS
    static enum rewrite_result line_log_rewrite_one(1285,32804
    enum parse_opt_option_flags 39,772
            enum parse_opt_option_flags flags;137,4133
    static enum rewrite_result rewrite_one_1(3608,101152
    static enum rewrite_result rewrite_one(3645,102081
    enum rewrite_result 445,12193
    typedef enum rewrite_result (*rewrite_parent_fn_t)rewrite_parent_fn_t451,12279

Hrm, that's etags actually, but the same is true of "make tags":
    
    $ grep -e rewrite_result -e parse_opt_option_flags tags
    line_log_rewrite_one    line-log.c      /^static enum rewrite_result line_log_rewrite_one(st/
    parse_opt_option_flags  parse-options.h 39
    rewrite_one_1   revision.c      /^static enum rewrite_result rewrite_one_1(struct re/
    rewrite_one     revision.c      /^static enum rewrite_result rewrite_one(struct rev_/
    rewrite_result  revision.h      445

In any case, both [ce]tags find a typdef'd and non-typedef'd variant,
don't they?

> Another idea is to mark the type of the flags by its name, eg.
> transaction_flags, resolve_flags, reftype_flags etc. This wouldn't
> help with ctags, but it does help with readability.

Yes, enums or not, what I was also pointing out in
https://lore.kernel.org/git/220201.86ilty9vq2.gmgdl@evledraar.gmail.com/
is that changing just one logical set of flags at a time would make this
much easier to review.

It doesn't matter for the end result as long as we end up with "unsigned
int" everywhere, but would with enums.


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2] refs.h: make all flags arguments unsigned
  2022-02-03 17:53         ` Ævar Arnfjörð Bjarmason
@ 2022-02-03 18:16           ` Han-Wen Nienhuys
  2022-02-03 21:20             ` Ævar Arnfjörð Bjarmason
  2022-02-03 18:27           ` Junio C Hamano
  1 sibling, 1 reply; 17+ messages in thread
From: Han-Wen Nienhuys @ 2022-02-03 18:16 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: Junio C Hamano, Han-Wen Nienhuys via GitGitGadget, git,
	Han-Wen Nienhuys

On Thu, Feb 3, 2022 at 7:05 PM Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
> > I proposed both options because a distinct typename lets me jump to
> > the definition of the flags easily through ctags.
>
> I'm not sure I understand you here. I use ctags (via Emacs) and it's

"I proposed both options" (ie. enum or typedef) , so we are in
resounding agreement.

> > Another idea is to mark the type of the flags by its name, eg.
> > transaction_flags, resolve_flags, reftype_flags etc. This wouldn't
> > help with ctags, but it does help with readability.
>
> Yes, enums or not, what I was also pointing out in
> https://lore.kernel.org/git/220201.86ilty9vq2.gmgdl@evledraar.gmail.com/
> is that changing just one logical set of flags at a time would make this
> much easier to review.
>
> It doesn't matter for the end result as long as we end up with "unsigned
> int" everywhere, but would with enums.

Not sure if you need to review it in that detail. If you change a
definition in the .h file,  the compiler will complain about all
mismatches. So it doesn't need human verification once you know it
compiles.

-- 
Han-Wen Nienhuys - Google Munich
I work 80%. Don't expect answers from me on Fridays.
--

Google Germany GmbH, Erika-Mann-Strasse 33, 80636 Munich

Registergericht und -nummer: Hamburg, HRB 86891

Sitz der Gesellschaft: Hamburg

Geschäftsführer: Paul Manicle, Halimah DeLaine Prado

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2] refs.h: make all flags arguments unsigned
  2022-02-03 17:53         ` Ævar Arnfjörð Bjarmason
  2022-02-03 18:16           ` Han-Wen Nienhuys
@ 2022-02-03 18:27           ` Junio C Hamano
  2022-02-03 18:33             ` Han-Wen Nienhuys
  1 sibling, 1 reply; 17+ messages in thread
From: Junio C Hamano @ 2022-02-03 18:27 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: Han-Wen Nienhuys, Han-Wen Nienhuys via GitGitGadget, git,
	Han-Wen Nienhuys

Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:

> Yes, enums or not, what I was also pointing out in
> https://lore.kernel.org/git/220201.86ilty9vq2.gmgdl@evledraar.gmail.com/
> is that changing just one logical set of flags at a time would make this
> much easier to review.

Another thing to consider is how to make this play better with other
topics in flight.  Basing a huge single patch on top of 'seen' is a
way to ensure that the patch will never be useful.  There won't be a
good time when such a topic can graduate.  The topic will also have
a hard time keeping up with what new topics add while waiting for
what happen to be in 'seen' today (some of which may even go away
without graduating) all graduate.

Limiting the scope to small and more stable subset of flags that are
in 'master' and does not conflict (e.g. no new bit defined to the
set of flags, no existing bit gets removed, no new callers that use
the bitset introduced) with other topics would incrementally improve
the code base, and makes progress in the sense that it reduces the
remaining work.

> It doesn't matter for the end result as long as we end up with "unsigned
> int" everywhere, but would with enums.

As it won't be an error to assign to what has converted to enum a
value that is in int or unsigned that comes from the part of the
code base that is not yet converted, so it may be OK either way.

Assigning between converted "unsigned" and unconverted "int" may add
unnecessary warnings during transitory period, but I think the story
would be the same for a flag bitset that is conveted into an "enum",
which the compiler happens to make it "unsigned", which was originally
a signed "int".

Thanks.




^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2] refs.h: make all flags arguments unsigned
  2022-02-03 18:27           ` Junio C Hamano
@ 2022-02-03 18:33             ` Han-Wen Nienhuys
  2022-02-03 19:15               ` Junio C Hamano
  0 siblings, 1 reply; 17+ messages in thread
From: Han-Wen Nienhuys @ 2022-02-03 18:33 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Ævar Arnfjörð Bjarmason,
	Han-Wen Nienhuys via GitGitGadget, git, Han-Wen Nienhuys

On Thu, Feb 3, 2022 at 7:27 PM Junio C Hamano <gitster@pobox.com> wrote:
> > Yes, enums or not, what I was also pointing out in
> > https://lore.kernel.org/git/220201.86ilty9vq2.gmgdl@evledraar.gmail.com/
> > is that changing just one logical set of flags at a time would make this
> > much easier to review.
>
> Another thing to consider is how to make this play better with other
> topics in flight.  Basing a huge single patch on top of 'seen' is a
> way to ensure that the patch will never be useful.  There won't be a
> good time when such a topic can graduate.  The topic will also have
> a hard time keeping up with what new topics add while waiting for
> what happen to be in 'seen' today (some of which may even go away
> without graduating) all graduate.
>
> Limiting the scope to small and more stable subset of flags that are
> in 'master' and does not conflict (e.g. no new bit defined to the
> set of flags, no existing bit gets removed, no new callers that use
> the bitset introduced) with other topics would incrementally improve
> the code base, and makes progress in the sense that it reduces the
> remaining work.

OK. But do we agree we want to use enums? Me and AEvar are in favor,
anyone against?

-- 
Han-Wen Nienhuys - Google Munich
I work 80%. Don't expect answers from me on Fridays.
--

Google Germany GmbH, Erika-Mann-Strasse 33, 80636 Munich

Registergericht und -nummer: Hamburg, HRB 86891

Sitz der Gesellschaft: Hamburg

Geschäftsführer: Paul Manicle, Halimah DeLaine Prado

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2] refs.h: make all flags arguments unsigned
  2022-02-03 18:33             ` Han-Wen Nienhuys
@ 2022-02-03 19:15               ` Junio C Hamano
  0 siblings, 0 replies; 17+ messages in thread
From: Junio C Hamano @ 2022-02-03 19:15 UTC (permalink / raw)
  To: Han-Wen Nienhuys
  Cc: Ævar Arnfjörð Bjarmason,
	Han-Wen Nienhuys via GitGitGadget, git, Han-Wen Nienhuys

Han-Wen Nienhuys <hanwen@google.com> writes:

> On Thu, Feb 3, 2022 at 7:27 PM Junio C Hamano <gitster@pobox.com> wrote:
>> > Yes, enums or not, what I was also pointing out in
>> > https://lore.kernel.org/git/220201.86ilty9vq2.gmgdl@evledraar.gmail.com/
>> > is that changing just one logical set of flags at a time would make this
>> > much easier to review.
>>
>> Another thing to consider is how to make this play better with other
>> topics in flight.  Basing a huge single patch on top of 'seen' is a
>> way to ensure that the patch will never be useful.  There won't be a
>> good time when such a topic can graduate.  The topic will also have
>> a hard time keeping up with what new topics add while waiting for
>> what happen to be in 'seen' today (some of which may even go away
>> without graduating) all graduate.
>>
>> Limiting the scope to small and more stable subset of flags that are
>> in 'master' and does not conflict (e.g. no new bit defined to the
>> set of flags, no existing bit gets removed, no new callers that use
>> the bitset introduced) with other topics would incrementally improve
>> the code base, and makes progress in the sense that it reduces the
>> remaining work.
>
> OK. But do we agree we want to use enums? Me and AEvar are in favor,
> anyone against?

No strong preference either way from me.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2] refs.h: make all flags arguments unsigned
  2022-02-03 18:16           ` Han-Wen Nienhuys
@ 2022-02-03 21:20             ` Ævar Arnfjörð Bjarmason
  0 siblings, 0 replies; 17+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2022-02-03 21:20 UTC (permalink / raw)
  To: Han-Wen Nienhuys
  Cc: Junio C Hamano, Han-Wen Nienhuys via GitGitGadget, git,
	Han-Wen Nienhuys


On Thu, Feb 03 2022, Han-Wen Nienhuys wrote:

> On Thu, Feb 3, 2022 at 7:05 PM Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
>> > I proposed both options because a distinct typename lets me jump to
>> > the definition of the flags easily through ctags.
>>
>> I'm not sure I understand you here. I use ctags (via Emacs) and it's
>
> "I proposed both options" (ie. enum or typedef) , so we are in
> resounding agreement.

Ah, so by "because a distinct typename lets me jump to the definition of
the flags easily through ctags." you mean one of "enum x" or "typedef
enum { ... } x", not just the latter?

>> > Another idea is to mark the type of the flags by its name, eg.
>> > transaction_flags, resolve_flags, reftype_flags etc. This wouldn't
>> > help with ctags, but it does help with readability.
>>
>> Yes, enums or not, what I was also pointing out in
>> https://lore.kernel.org/git/220201.86ilty9vq2.gmgdl@evledraar.gmail.com/
>> is that changing just one logical set of flags at a time would make this
>> much easier to review.
>>
>> It doesn't matter for the end result as long as we end up with "unsigned
>> int" everywhere, but would with enums.
>
> Not sure if you need to review it in that detail. If you change a
> definition in the .h file,  the compiler will complain about all
> mismatches. So it doesn't need human verification once you know it
> compiles.

That's true in C++ I think, but not C. Or do you have a compiler that'll
warn about e.g. this change:
	
	diff --git a/refs.c b/refs.c
	index addb26293b4..e6c3931ec00 100644
	--- a/refs.c
	+++ b/refs.c
	@@ -1078,7 +1078,7 @@ int ref_transaction_update(struct ref_transaction *transaction,
	 			   const char *refname,
	 			   const struct object_id *new_oid,
	 			   const struct object_id *old_oid,
	-			   unsigned int flags, const char *msg,
	+			   enum foobar flags, const char *msg,
	 			   struct strbuf *err)
	 {
	 	assert(err);
	diff --git a/refs.h b/refs.h
	index 8f91a7f9ff2..63dde1da4de 100644
	--- a/refs.h
	+++ b/refs.h
	@@ -670,11 +670,12 @@ struct ref_transaction *ref_transaction_begin(struct strbuf *err);
	  * See the above comment "Reference transaction updates" for more
	  * information.
	  */
	+enum foobar { FOOBAR = 0 };
	 int ref_transaction_update(struct ref_transaction *transaction,
	 			   const char *refname,
	 			   const struct object_id *new_oid,
	 			   const struct object_id *old_oid,
	-			   unsigned int flags, const char *msg,
	+			   enum foobar flags, const char *msg,
	 			   struct strbuf *err);
	 
	 /*

What I'm referring to, keeping in mind that that doesn't warn, is that
since we can't get the compiler to whine about e.g. that "flags" being
compared against values not in the enum, or when I pass that "enum" to a
not-that-enum right after in ref_transaction_add_update() is that it's
extra useful for reviewing these sorts of changes if what's logically
one flag is changed at a time, as opposed to a big search/replacement
(and tracking things down for s/int/enum/ would force one to do that).

For doing this sort of change in C I find it to be a useful technique to do this:
	
	diff --git a/refs.c b/refs.c
	index addb26293b4..ab58dd8948d 100644
	--- a/refs.c
	+++ b/refs.c
	@@ -1078,7 +1078,7 @@ int ref_transaction_update(struct ref_transaction *transaction,
	 			   const char *refname,
	 			   const struct object_id *new_oid,
	 			   const struct object_id *old_oid,
	-			   unsigned int flags, const char *msg,
	+			   unsigned int *flags, const char *msg,
	 			   struct strbuf *err)
	 {
	 	assert(err);
	diff --git a/refs.h b/refs.h
	index 8f91a7f9ff2..80ef4616838 100644
	--- a/refs.h
	+++ b/refs.h
	@@ -674,7 +674,7 @@ int ref_transaction_update(struct ref_transaction *transaction,
	 			   const char *refname,
	 			   const struct object_id *new_oid,
	 			   const struct object_id *old_oid,
	-			   unsigned int flags, const char *msg,
	+			   unsigned int *flags, const char *msg,
	 			   struct strbuf *err);
	 
	 /*


Which will get you a hard compilation error, e.g.:
	
	$ make builtin/update-ref.o
	    CC builtin/update-ref.o
	builtin/update-ref.c:205:8: error: incompatible integer to pointer conversion passing 'unsigned int' to parameter of type 'unsigned int *' [-Werror,-Wint-conversion]
	                                   update_flags | create_reflog_flag,
	                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	./refs.h:677:21: note: passing argument to parameter 'flags' here
	                           unsigned int *flags, const char *msg,
	                                         ^
	1 error generated.
	make: *** [Makefile:2542: builtin/update-ref.o] Error 1

Which you'd then "fix" like this:
		
	diff --git a/builtin/update-ref.c b/builtin/update-ref.c
	index a84e7b47a20..33bcde36871 100644
	--- a/builtin/update-ref.c
	+++ b/builtin/update-ref.c
	@@ -185,6 +185,7 @@ static void parse_cmd_update(struct ref_transaction *transaction,
	 	char *refname;
	 	struct object_id new_oid, old_oid;
	 	int have_old;
	+	unsigned int f = update_flags | create_reflog_flag;
	 
	 	refname = parse_refname(&next);
	 	if (!refname)
	@@ -202,7 +203,7 @@ static void parse_cmd_update(struct ref_transaction *transaction,
	 
	 	if (ref_transaction_update(transaction, refname,
	 				   &new_oid, have_old ? &old_oid : NULL,
	-				   update_flags | create_reflog_flag,
	+				   &f,
	 				   msg, &err))
	 		die("%s", err.buf);
	 
Now, obviously those changes suck, but the point is that if you do it
like that you can be assured that you got all callsites, so if you first
change it to an "int *", then get it to compile, and then search/replace
the resulting hunks you just changed & repeat, you can be assured that
you got all the callers, and that we don't have cases left where an
"int" becomes "unsigned int", or that our shiny new "enum" is
immediately passed as an "int" etc.

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2022-02-03 21:31 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-31 20:15 [PATCH] refs.h: make all flags arguments unsigned Han-Wen Nienhuys via GitGitGadget
2022-02-01  2:02 ` Junio C Hamano
2022-02-01 11:47   ` Han-Wen Nienhuys
2022-02-01 18:41     ` Junio C Hamano
2022-02-01 12:46 ` [PATCH v2] " Han-Wen Nienhuys via GitGitGadget
2022-02-01 20:20   ` Ævar Arnfjörð Bjarmason
2022-02-01 23:03     ` Junio C Hamano
2022-02-03 14:29       ` Han-Wen Nienhuys
2022-02-03 17:53         ` Ævar Arnfjörð Bjarmason
2022-02-03 18:16           ` Han-Wen Nienhuys
2022-02-03 21:20             ` Ævar Arnfjörð Bjarmason
2022-02-03 18:27           ` Junio C Hamano
2022-02-03 18:33             ` Han-Wen Nienhuys
2022-02-03 19:15               ` Junio C Hamano
2022-02-03 14:26   ` [PATCH v3 0/2] " Han-Wen Nienhuys via GitGitGadget
2022-02-03 14:26     ` [PATCH v3 1/2] " Han-Wen Nienhuys via GitGitGadget
2022-02-03 14:26     ` [PATCH v3 2/2] Uniformize flag argument naming to `flags` or `unused_flags` Han-Wen Nienhuys via GitGitGadget

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).