From 03f2465bb1c1d9222181c493373e668c0ba7eb51 Mon Sep 17 00:00:00 2001 From: Eric Sunshine Date: Fri, 19 Jun 2020 19:35:44 -0400 Subject: worktree: drop get_worktrees() unused 'flags' argument get_worktrees() accepts a 'flags' argument, however, there are no existing flags (the lone flag GWT_SORT_LINKED was recently retired) and no behavior which can be tweaked. Therefore, drop the 'flags' argument. Signed-off-by: Eric Sunshine Signed-off-by: Junio C Hamano diff --git a/branch.c b/branch.c index 5794947..c5b1941 100644 --- a/branch.c +++ b/branch.c @@ -369,7 +369,7 @@ int replace_each_worktree_head_symref(const char *oldref, const char *newref, const char *logmsg) { int ret = 0; - struct worktree **worktrees = get_worktrees(0); + struct worktree **worktrees = get_worktrees(); int i; for (i = 0; worktrees[i]; i++) { diff --git a/builtin/branch.c b/builtin/branch.c index d8297f8..5a27530 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -468,7 +468,7 @@ static void print_current_branch_name(void) static void reject_rebase_or_bisect_branch(const char *target) { - struct worktree **worktrees = get_worktrees(0); + struct worktree **worktrees = get_worktrees(); int i; for (i = 0; worktrees[i]; i++) { diff --git a/builtin/config.c b/builtin/config.c index ee4aef6..5e39f61 100644 --- a/builtin/config.c +++ b/builtin/config.c @@ -672,7 +672,7 @@ int cmd_config(int argc, const char **argv, const char *prefix) given_config_source.file = git_pathdup("config"); given_config_source.scope = CONFIG_SCOPE_LOCAL; } else if (use_worktree_config) { - struct worktree **worktrees = get_worktrees(0); + struct worktree **worktrees = get_worktrees(); if (repository_format_worktree_config) given_config_source.file = git_pathdup("config.worktree"); else if (worktrees[0] && worktrees[1]) diff --git a/builtin/fsck.c b/builtin/fsck.c index 8d13794..5ebf813 100644 --- a/builtin/fsck.c +++ b/builtin/fsck.c @@ -576,7 +576,7 @@ static void get_default_heads(void) for_each_rawref(fsck_handle_ref, NULL); - worktrees = get_worktrees(0); + worktrees = get_worktrees(); for (p = worktrees; *p; p++) { struct worktree *wt = *p; struct strbuf ref = STRBUF_INIT; diff --git a/builtin/reflog.c b/builtin/reflog.c index 81dfd56..0b6853b 100644 --- a/builtin/reflog.c +++ b/builtin/reflog.c @@ -615,7 +615,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix) int i; memset(&collected, 0, sizeof(collected)); - worktrees = get_worktrees(0); + worktrees = get_worktrees(); for (p = worktrees; *p; p++) { if (!all_worktrees && !(*p)->is_current) continue; diff --git a/builtin/worktree.c b/builtin/worktree.c index c20e4ce..2551c36 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -325,7 +325,7 @@ static int add_worktree(const char *path, const char *refname, struct strbuf sb_name = STRBUF_INIT; struct worktree **worktrees; - worktrees = get_worktrees(0); + worktrees = get_worktrees(); check_candidate_path(path, opts->force, worktrees, "add"); free_worktrees(worktrees); worktrees = NULL; @@ -724,7 +724,7 @@ static int list(int ac, const char **av, const char *prefix) if (ac) usage_with_options(worktree_usage, options); else { - struct worktree **worktrees = get_worktrees(0); + struct worktree **worktrees = get_worktrees(); int path_maxlen = 0, abbrev = DEFAULT_ABBREV, i; /* sort worktrees by path but keep main worktree at top */ @@ -758,7 +758,7 @@ static int lock_worktree(int ac, const char **av, const char *prefix) if (ac != 1) usage_with_options(worktree_usage, options); - worktrees = get_worktrees(0); + worktrees = get_worktrees(); wt = find_worktree(worktrees, prefix, av[0]); if (!wt) die(_("'%s' is not a working tree"), av[0]); @@ -791,7 +791,7 @@ static int unlock_worktree(int ac, const char **av, const char *prefix) if (ac != 1) usage_with_options(worktree_usage, options); - worktrees = get_worktrees(0); + worktrees = get_worktrees(); wt = find_worktree(worktrees, prefix, av[0]); if (!wt) die(_("'%s' is not a working tree"), av[0]); @@ -865,7 +865,7 @@ static int move_worktree(int ac, const char **av, const char *prefix) strbuf_addstr(&dst, path); free(path); - worktrees = get_worktrees(0); + worktrees = get_worktrees(); wt = find_worktree(worktrees, prefix, av[0]); if (!wt) die(_("'%s' is not a working tree"), av[0]); @@ -991,7 +991,7 @@ static int remove_worktree(int ac, const char **av, const char *prefix) if (ac != 1) usage_with_options(worktree_usage, options); - worktrees = get_worktrees(0); + worktrees = get_worktrees(); wt = find_worktree(worktrees, prefix, av[0]); if (!wt) die(_("'%s' is not a working tree"), av[0]); diff --git a/ref-filter.c b/ref-filter.c index b1812cb..76802e8 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -1579,7 +1579,7 @@ static void lazy_init_worktree_map(void) if (ref_to_worktree_map.worktrees) return; - ref_to_worktree_map.worktrees = get_worktrees(0); + ref_to_worktree_map.worktrees = get_worktrees(); hashmap_init(&(ref_to_worktree_map.map), ref_to_worktree_map_cmpfnc, NULL, 0); populate_worktree_map(&(ref_to_worktree_map.map), ref_to_worktree_map.worktrees); } diff --git a/revision.c b/revision.c index 8136929..a42f6d5 100644 --- a/revision.c +++ b/revision.c @@ -1452,7 +1452,7 @@ static void add_other_reflogs_to_pending(struct all_refs_cb *cb) { struct worktree **worktrees, **p; - worktrees = get_worktrees(0); + worktrees = get_worktrees(); for (p = worktrees; *p; p++) { struct worktree *wt = *p; @@ -1540,7 +1540,7 @@ void add_index_objects_to_pending(struct rev_info *revs, unsigned int flags) if (revs->single_worktree) return; - worktrees = get_worktrees(0); + worktrees = get_worktrees(); for (p = worktrees; *p; p++) { struct worktree *wt = *p; struct index_state istate = { NULL }; diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c index 799fc00..759e69d 100644 --- a/t/helper/test-ref-store.c +++ b/t/helper/test-ref-store.c @@ -37,7 +37,7 @@ static const char **get_store(const char **argv, struct ref_store **refs) *refs = get_submodule_ref_store(gitdir); } else if (skip_prefix(argv[0], "worktree:", &gitdir)) { - struct worktree **p, **worktrees = get_worktrees(0); + struct worktree **p, **worktrees = get_worktrees(); for (p = worktrees; *p; p++) { struct worktree *wt = *p; diff --git a/worktree.c b/worktree.c index 42cabc5..f470147 100644 --- a/worktree.c +++ b/worktree.c @@ -123,7 +123,7 @@ static void mark_current_worktree(struct worktree **worktrees) free(git_dir); } -struct worktree **get_worktrees(unsigned flags) +struct worktree **get_worktrees(void) { struct worktree **list = NULL; struct strbuf path = STRBUF_INIT; @@ -398,7 +398,7 @@ const struct worktree *find_shared_symref(const char *symref, if (worktrees) free_worktrees(worktrees); - worktrees = get_worktrees(0); + worktrees = get_worktrees(); for (i = 0; worktrees[i]; i++) { struct worktree *wt = worktrees[i]; @@ -559,7 +559,7 @@ int other_head_refs(each_ref_fn fn, void *cb_data) struct worktree **worktrees, **p; int ret = 0; - worktrees = get_worktrees(0); + worktrees = get_worktrees(); for (p = worktrees; *p; p++) { struct worktree *wt = *p; struct object_id oid; diff --git a/worktree.h b/worktree.h index bd2235a..516744c 100644 --- a/worktree.h +++ b/worktree.h @@ -25,7 +25,7 @@ struct worktree { * The caller is responsible for freeing the memory from the returned * worktrees by calling free_worktrees(). */ -struct worktree **get_worktrees(unsigned flags); +struct worktree **get_worktrees(void); /* * Returns 1 if linked worktrees exist, 0 otherwise. -- cgit v0.10.2-6-g49f6