Merge branch 'jk/unused-params-final-batch'

* jk/unused-params-final-batch:
  verify-commit: simplify parameters to run_gpg_verify()
  show-branch: drop unused parameter from show_independent()
  rev-list: drop unused void pointer from finish_commit()
  remove_all_fetch_refspecs(): drop unused "remote" parameter
  receive-pack: drop unused "commands" from prepare_shallow_update()
  pack-objects: drop unused rev_info parameters
  name-rev: drop unused parameters from is_better_name()
  mktree: drop unused length parameter
  wt-status: drop unused status parameter
  read-cache: drop unused parameter from threaded load
  clone: drop dest parameter from copy_alternates()
  submodule: drop unused prefix parameter from some functions
  builtin: consistently pass cmd_* prefix to parse_options
  cmd_{read,write}_tree: rename "unused" variable that is used
maint
Junio C Hamano 2019-06-13 13:19:34 -07:00
commit c0e78f7e46
22 changed files with 53 additions and 72 deletions

View File

@ -354,8 +354,7 @@ static void setup_reference(void)
add_one_reference, &required); add_one_reference, &required);
} }


static void copy_alternates(struct strbuf *src, struct strbuf *dst, static void copy_alternates(struct strbuf *src, const char *src_repo)
const char *src_repo)
{ {
/* /*
* Read from the source objects/info/alternates file * Read from the source objects/info/alternates file
@ -436,7 +435,7 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest,


/* Files that cannot be copied bit-for-bit... */ /* Files that cannot be copied bit-for-bit... */
if (!strcmp(src->buf + src_baselen, "/info/alternates")) { if (!strcmp(src->buf + src_baselen, "/info/alternates")) {
copy_alternates(src, dest, src_repo); copy_alternates(src, src_repo);
continue; continue;
} }



View File

@ -43,7 +43,7 @@ int cmd_column(int argc, const char **argv, const char *prefix)


memset(&copts, 0, sizeof(copts)); memset(&copts, 0, sizeof(copts));
copts.padding = 1; copts.padding = 1;
argc = parse_options(argc, argv, "", options, builtin_column_usage, 0); argc = parse_options(argc, argv, prefix, options, builtin_column_usage, 0);
if (argc) if (argc)
usage_with_options(builtin_column_usage, options); usage_with_options(builtin_column_usage, options);
if (real_command || command) { if (real_command || command) {

View File

@ -108,7 +108,7 @@ int cmd_hash_object(int argc, const char **argv, const char *prefix)
int i; int i;
const char *errstr = NULL; const char *errstr = NULL;


argc = parse_options(argc, argv, NULL, hash_object_options, argc = parse_options(argc, argv, prefix, hash_object_options,
hash_object_usage, 0); hash_object_usage, 0);


if (flags & HASH_WRITE_OBJECT) if (flags & HASH_WRITE_OBJECT)

View File

@ -67,7 +67,7 @@ static const char *mktree_usage[] = {
NULL NULL
}; };


static void mktree_line(char *buf, size_t len, int nul_term_line, int allow_missing) static void mktree_line(char *buf, int nul_term_line, int allow_missing)
{ {
char *ptr, *ntr; char *ptr, *ntr;
const char *p; const char *p;
@ -172,7 +172,7 @@ int cmd_mktree(int ac, const char **av, const char *prefix)
break; break;
die("input format error: (blank line only valid in batch mode)"); die("input format error: (blank line only valid in batch mode)");
} }
mktree_line(sb.buf, sb.len, nul_term_line, allow_missing); mktree_line(sb.buf, nul_term_line, allow_missing);
} }
if (is_batch_mode && got_eof && used < 1) { if (is_batch_mode && got_eof && used < 1) {
/* /*

View File

@ -40,9 +40,7 @@ static void set_commit_rev_name(struct commit *commit, struct rev_name *name)
} }


static int is_better_name(struct rev_name *name, static int is_better_name(struct rev_name *name,
const char *tip_name,
timestamp_t taggerdate, timestamp_t taggerdate,
int generation,
int distance, int distance,
int from_tag) int from_tag)
{ {
@ -103,8 +101,7 @@ static void name_rev(struct commit *commit,
name = xmalloc(sizeof(rev_name)); name = xmalloc(sizeof(rev_name));
set_commit_rev_name(commit, name); set_commit_rev_name(commit, name);
goto copy_data; goto copy_data;
} else if (is_better_name(name, tip_name, taggerdate, } else if (is_better_name(name, taggerdate, distance, from_tag)) {
generation, distance, from_tag)) {
copy_data: copy_data:
name->tip_name = tip_name; name->tip_name = tip_name;
name->taggerdate = taggerdate; name->taggerdate = taggerdate;

View File

@ -2899,7 +2899,7 @@ static int ofscmp(const void *a_, const void *b_)
return oidcmp(&a->object->oid, &b->object->oid); return oidcmp(&a->object->oid, &b->object->oid);
} }


static void add_objects_in_unpacked_packs(struct rev_info *revs) static void add_objects_in_unpacked_packs(void)
{ {
struct packed_git *p; struct packed_git *p;
struct in_pack in_pack; struct in_pack in_pack;
@ -3011,7 +3011,7 @@ static int loosened_object_can_be_discarded(const struct object_id *oid,
return 1; return 1;
} }


static void loosen_unused_packed_objects(struct rev_info *revs) static void loosen_unused_packed_objects(void)
{ {
struct packed_git *p; struct packed_git *p;
uint32_t i; uint32_t i;
@ -3158,11 +3158,11 @@ static void get_object_list(int ac, const char **av)
} }


if (keep_unreachable) if (keep_unreachable)
add_objects_in_unpacked_packs(&revs); add_objects_in_unpacked_packs();
if (pack_loose_unreachable) if (pack_loose_unreachable)
add_unreachable_loose_objects(); add_unreachable_loose_objects();
if (unpack_unreachable) if (unpack_unreachable)
loosen_unused_packed_objects(&revs); loosen_unused_packed_objects();


oid_array_clear(&recent_objects); oid_array_clear(&recent_objects);
} }

View File

@ -32,7 +32,7 @@ int cmd_range_diff(int argc, const char **argv, const char *prefix)
repo_diff_setup(the_repository, &diffopt); repo_diff_setup(the_repository, &diffopt);


options = parse_options_concat(range_diff_options, diffopt.parseopts); options = parse_options_concat(range_diff_options, diffopt.parseopts);
argc = parse_options(argc, argv, NULL, options, argc = parse_options(argc, argv, prefix, options,
builtin_range_diff_usage, 0); builtin_range_diff_usage, 0);


diff_setup_done(&diffopt); diff_setup_done(&diffopt);

View File

@ -111,7 +111,7 @@ static int git_read_tree_config(const char *var, const char *value, void *cb)
return git_default_config(var, value, cb); return git_default_config(var, value, cb);
} }


int cmd_read_tree(int argc, const char **argv, const char *unused_prefix) int cmd_read_tree(int argc, const char **argv, const char *cmd_prefix)
{ {
int i, stage = 0; int i, stage = 0;
struct object_id oid; struct object_id oid;
@ -165,7 +165,7 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)


git_config(git_read_tree_config, NULL); git_config(git_read_tree_config, NULL);


argc = parse_options(argc, argv, unused_prefix, read_tree_options, argc = parse_options(argc, argv, cmd_prefix, read_tree_options,
read_tree_usage, 0); read_tree_usage, 0);


hold_locked_index(&lock_file, LOCK_DIE_ON_ERROR); hold_locked_index(&lock_file, LOCK_DIE_ON_ERROR);

View File

@ -508,7 +508,7 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
if (argc == 1) if (argc == 1)
usage_with_options(builtin_rebase_interactive_usage, options); usage_with_options(builtin_rebase_interactive_usage, options);


argc = parse_options(argc, argv, NULL, options, argc = parse_options(argc, argv, prefix, options,
builtin_rebase_interactive_usage, PARSE_OPT_KEEP_ARGV0); builtin_rebase_interactive_usage, PARSE_OPT_KEEP_ARGV0);


if (!is_null_oid(&squash_onto)) if (!is_null_oid(&squash_onto))

View File

@ -1809,8 +1809,7 @@ static const char *unpack_with_sideband(struct shallow_info *si)
return ret; return ret;
} }


static void prepare_shallow_update(struct command *commands, static void prepare_shallow_update(struct shallow_info *si)
struct shallow_info *si)
{ {
int i, j, k, bitmap_size = DIV_ROUND_UP(si->ref->nr, 32); int i, j, k, bitmap_size = DIV_ROUND_UP(si->ref->nr, 32);


@ -1876,7 +1875,7 @@ static void update_shallow_info(struct command *commands,
si->ref = ref; si->ref = ref;


if (shallow_update) { if (shallow_update) {
prepare_shallow_update(commands, si); prepare_shallow_update(si);
return; return;
} }



View File

@ -1407,7 +1407,7 @@ static int update(int argc, const char **argv)
return retval; return retval;
} }


static int remove_all_fetch_refspecs(const char *remote, const char *key) static int remove_all_fetch_refspecs(const char *key)
{ {
return git_config_set_multivar_gently(key, NULL, NULL, 1); return git_config_set_multivar_gently(key, NULL, NULL, 1);
} }
@ -1437,7 +1437,7 @@ static int set_remote_branches(const char *remotename, const char **branches,
if (!remote_is_configured(remote, 1)) if (!remote_is_configured(remote, 1))
die(_("No such remote '%s'"), remotename); die(_("No such remote '%s'"), remotename);


if (!add_mode && remove_all_fetch_refspecs(remotename, key.buf)) { if (!add_mode && remove_all_fetch_refspecs(key.buf)) {
strbuf_release(&key); strbuf_release(&key);
return 1; return 1;
} }

View File

@ -77,7 +77,7 @@ static enum missing_action arg_missing_action;


#define DEFAULT_OIDSET_SIZE (16*1024) #define DEFAULT_OIDSET_SIZE (16*1024)


static void finish_commit(struct commit *commit, void *data); static void finish_commit(struct commit *commit);
static void show_commit(struct commit *commit, void *data) static void show_commit(struct commit *commit, void *data)
{ {
struct rev_list_info *info = data; struct rev_list_info *info = data;
@ -86,7 +86,7 @@ static void show_commit(struct commit *commit, void *data)
display_progress(progress, ++progress_counter); display_progress(progress, ++progress_counter);


if (info->flags & REV_LIST_QUIET) { if (info->flags & REV_LIST_QUIET) {
finish_commit(commit, data); finish_commit(commit);
return; return;
} }


@ -99,7 +99,7 @@ static void show_commit(struct commit *commit, void *data)
revs->count_left++; revs->count_left++;
else else
revs->count_right++; revs->count_right++;
finish_commit(commit, data); finish_commit(commit);
return; return;
} }


@ -188,10 +188,10 @@ static void show_commit(struct commit *commit, void *data)
putchar('\n'); putchar('\n');
} }
maybe_flush_or_die(stdout, "stdout"); maybe_flush_or_die(stdout, "stdout");
finish_commit(commit, data); finish_commit(commit);
} }


static void finish_commit(struct commit *commit, void *data) static void finish_commit(struct commit *commit)
{ {
if (commit->parents) { if (commit->parents) {
free_commit_list(commit->parents); free_commit_list(commit->parents);

View File

@ -61,7 +61,7 @@ static void print_error_files(struct string_list *files_list,
} }
} }


static void submodules_absorb_gitdir_if_needed(const char *prefix) static void submodules_absorb_gitdir_if_needed(void)
{ {
int i; int i;
for (i = 0; i < list.nr; i++) { for (i = 0; i < list.nr; i++) {
@ -83,7 +83,7 @@ static void submodules_absorb_gitdir_if_needed(const char *prefix)
continue; continue;


if (!submodule_uses_gitfile(name)) if (!submodule_uses_gitfile(name))
absorb_git_dir_into_superproject(prefix, name, absorb_git_dir_into_superproject(name,
ABSORB_GITDIR_RECURSE_SUBMODULES); ABSORB_GITDIR_RECURSE_SUBMODULES);
} }
} }
@ -313,7 +313,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
} }


if (!index_only) if (!index_only)
submodules_absorb_gitdir_if_needed(prefix); submodules_absorb_gitdir_if_needed();


/* /*
* If not forced, the file, the index and the HEAD (if exists) * If not forced, the file, the index and the HEAD (if exists)

View File

@ -514,7 +514,6 @@ static int show_merge_base(struct commit_list *seen, int num_rev)


static int show_independent(struct commit **rev, static int show_independent(struct commit **rev,
int num_rev, int num_rev,
char **ref_name,
unsigned int *rev_mask) unsigned int *rev_mask)
{ {
int i; int i;
@ -862,7 +861,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
return show_merge_base(seen, num_rev); return show_merge_base(seen, num_rev);


if (independent) if (independent)
return show_independent(rev, num_rev, ref_name, rev_mask); return show_independent(rev, num_rev, rev_mask);


/* Show list; --more=-1 means list-only */ /* Show list; --more=-1 means list-only */
if (1 < num_rev || extra < 0) { if (1 < num_rev || extra < 0) {

View File

@ -2107,8 +2107,7 @@ static int absorb_git_dirs(int argc, const char **argv, const char *prefix)
return 1; return 1;


for (i = 0; i < list.nr; i++) for (i = 0; i < list.nr; i++)
absorb_git_dir_into_superproject(prefix, absorb_git_dir_into_superproject(list.entries[i]->name, flags);
list.entries[i]->name, flags);


return 0; return 0;
} }

View File

@ -33,7 +33,7 @@ int cmd_upload_pack(int argc, const char **argv, const char *prefix)
packet_trace_identity("upload-pack"); packet_trace_identity("upload-pack");
read_replace_refs = 0; read_replace_refs = 0;


argc = parse_options(argc, argv, NULL, options, upload_pack_usage, 0); argc = parse_options(argc, argv, prefix, options, upload_pack_usage, 0);


if (argc != 1) if (argc != 1)
usage_with_options(upload_pack_usage, options); usage_with_options(upload_pack_usage, options);

View File

@ -21,15 +21,14 @@ static const char * const verify_commit_usage[] = {
NULL NULL
}; };


static int run_gpg_verify(const struct object_id *oid, const char *buf, unsigned long size, unsigned flags) static int run_gpg_verify(struct commit *commit, unsigned flags)
{ {
struct signature_check signature_check; struct signature_check signature_check;
int ret; int ret;


memset(&signature_check, 0, sizeof(signature_check)); memset(&signature_check, 0, sizeof(signature_check));


ret = check_commit_signature(lookup_commit(the_repository, oid), ret = check_commit_signature(commit, &signature_check);
&signature_check);
print_signature_buffer(&signature_check, flags); print_signature_buffer(&signature_check, flags);


signature_check_clear(&signature_check); signature_check_clear(&signature_check);
@ -38,26 +37,20 @@ static int run_gpg_verify(const struct object_id *oid, const char *buf, unsigned


static int verify_commit(const char *name, unsigned flags) static int verify_commit(const char *name, unsigned flags)
{ {
enum object_type type;
struct object_id oid; struct object_id oid;
char *buf; struct object *obj;
unsigned long size;
int ret;


if (get_oid(name, &oid)) if (get_oid(name, &oid))
return error("commit '%s' not found.", name); return error("commit '%s' not found.", name);


buf = read_object_file(&oid, &type, &size); obj = parse_object(the_repository, &oid);
if (!buf) if (!obj)
return error("%s: unable to read file.", name); return error("%s: unable to read file.", name);
if (type != OBJ_COMMIT) if (obj->type != OBJ_COMMIT)
return error("%s: cannot verify a non-commit object of type %s.", return error("%s: cannot verify a non-commit object of type %s.",
name, type_name(type)); name, type_name(obj->type));


ret = run_gpg_verify(&oid, buf, size, flags); return run_gpg_verify((struct commit *)obj, flags);

free(buf);
return ret;
} }


static int git_verify_commit_config(const char *var, const char *value, void *cb) static int git_verify_commit_config(const char *var, const char *value, void *cb)

View File

@ -16,16 +16,16 @@ static const char * const write_tree_usage[] = {
NULL NULL
}; };


int cmd_write_tree(int argc, const char **argv, const char *unused_prefix) int cmd_write_tree(int argc, const char **argv, const char *cmd_prefix)
{ {
int flags = 0, ret; int flags = 0, ret;
const char *prefix = NULL; const char *tree_prefix = NULL;
struct object_id oid; struct object_id oid;
const char *me = "git-write-tree"; const char *me = "git-write-tree";
struct option write_tree_options[] = { struct option write_tree_options[] = {
OPT_BIT(0, "missing-ok", &flags, N_("allow missing objects"), OPT_BIT(0, "missing-ok", &flags, N_("allow missing objects"),
WRITE_TREE_MISSING_OK), WRITE_TREE_MISSING_OK),
OPT_STRING(0, "prefix", &prefix, N_("<prefix>/"), OPT_STRING(0, "prefix", &tree_prefix, N_("<prefix>/"),
N_("write tree object for a subdirectory <prefix>")), N_("write tree object for a subdirectory <prefix>")),
{ OPTION_BIT, 0, "ignore-cache-tree", &flags, NULL, { OPTION_BIT, 0, "ignore-cache-tree", &flags, NULL,
N_("only useful for debugging"), N_("only useful for debugging"),
@ -35,10 +35,10 @@ int cmd_write_tree(int argc, const char **argv, const char *unused_prefix)
}; };


git_config(git_default_config, NULL); git_config(git_default_config, NULL);
argc = parse_options(argc, argv, unused_prefix, write_tree_options, argc = parse_options(argc, argv, cmd_prefix, write_tree_options,
write_tree_usage, 0); write_tree_usage, 0);


ret = write_cache_as_tree(&oid, flags, prefix); ret = write_cache_as_tree(&oid, flags, tree_prefix);
switch (ret) { switch (ret) {
case 0: case 0:
printf("%s\n", oid_to_hex(&oid)); printf("%s\n", oid_to_hex(&oid));
@ -50,7 +50,7 @@ int cmd_write_tree(int argc, const char **argv, const char *unused_prefix)
die("%s: error building trees", me); die("%s: error building trees", me);
break; break;
case WRITE_TREE_PREFIX_ERROR: case WRITE_TREE_PREFIX_ERROR:
die("%s: prefix %s not found", me, prefix); die("%s: prefix %s not found", me, tree_prefix);
break; break;
} }
return ret; return ret;

View File

@ -2037,7 +2037,7 @@ static void *load_cache_entries_thread(void *_data)
} }


static unsigned long load_cache_entries_threaded(struct index_state *istate, const char *mmap, size_t mmap_size, static unsigned long load_cache_entries_threaded(struct index_state *istate, const char *mmap, size_t mmap_size,
unsigned long src_offset, int nr_threads, struct index_entry_offset_table *ieot) int nr_threads, struct index_entry_offset_table *ieot)
{ {
int i, offset, ieot_blocks, ieot_start, err; int i, offset, ieot_blocks, ieot_start, err;
struct load_cache_entries_thread_data *data; struct load_cache_entries_thread_data *data;
@ -2198,7 +2198,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
ieot = read_ieot_extension(mmap, mmap_size, extension_offset); ieot = read_ieot_extension(mmap, mmap_size, extension_offset);


if (ieot) { if (ieot) {
src_offset += load_cache_entries_threaded(istate, mmap, mmap_size, src_offset, nr_threads, ieot); src_offset += load_cache_entries_threaded(istate, mmap, mmap_size, nr_threads, ieot);
free(ieot); free(ieot);
} else { } else {
src_offset += load_all_cache_entries(istate, mmap, mmap_size, src_offset); src_offset += load_all_cache_entries(istate, mmap, mmap_size, src_offset);

View File

@ -1910,7 +1910,7 @@ int submodule_move_head(const char *path,
if (!(flags & SUBMODULE_MOVE_HEAD_DRY_RUN)) { if (!(flags & SUBMODULE_MOVE_HEAD_DRY_RUN)) {
if (old_head) { if (old_head) {
if (!submodule_uses_gitfile(path)) if (!submodule_uses_gitfile(path))
absorb_git_dir_into_superproject("", path, absorb_git_dir_into_superproject(path,
ABSORB_GITDIR_RECURSE_SUBMODULES); ABSORB_GITDIR_RECURSE_SUBMODULES);
} else { } else {
char *gitdir = xstrfmt("%s/modules/%s", char *gitdir = xstrfmt("%s/modules/%s",
@ -1997,8 +1997,7 @@ out:
* Embeds a single submodules git directory into the superprojects git dir, * Embeds a single submodules git directory into the superprojects git dir,
* non recursively. * non recursively.
*/ */
static void relocate_single_git_dir_into_superproject(const char *prefix, static void relocate_single_git_dir_into_superproject(const char *path)
const char *path)
{ {
char *old_git_dir = NULL, *real_old_git_dir = NULL, *real_new_git_dir = NULL; char *old_git_dir = NULL, *real_old_git_dir = NULL, *real_new_git_dir = NULL;
const char *new_git_dir; const char *new_git_dir;
@ -2040,8 +2039,7 @@ static void relocate_single_git_dir_into_superproject(const char *prefix,
* having its git directory within the working tree to the git dir nested * having its git directory within the working tree to the git dir nested
* in its superprojects git dir under modules/. * in its superprojects git dir under modules/.
*/ */
void absorb_git_dir_into_superproject(const char *prefix, void absorb_git_dir_into_superproject(const char *path,
const char *path,
unsigned flags) unsigned flags)
{ {
int err_code; int err_code;
@ -2082,7 +2080,7 @@ void absorb_git_dir_into_superproject(const char *prefix,
char *real_common_git_dir = real_pathdup(get_git_common_dir(), 1); char *real_common_git_dir = real_pathdup(get_git_common_dir(), 1);


if (!starts_with(real_sub_git_dir, real_common_git_dir)) if (!starts_with(real_sub_git_dir, real_common_git_dir))
relocate_single_git_dir_into_superproject(prefix, path); relocate_single_git_dir_into_superproject(path);


free(real_sub_git_dir); free(real_sub_git_dir);
free(real_common_git_dir); free(real_common_git_dir);

View File

@ -141,8 +141,7 @@ void submodule_unset_core_worktree(const struct submodule *sub);
void prepare_submodule_repo_env(struct argv_array *out); void prepare_submodule_repo_env(struct argv_array *out);


#define ABSORB_GITDIR_RECURSE_SUBMODULES (1<<0) #define ABSORB_GITDIR_RECURSE_SUBMODULES (1<<0)
void absorb_git_dir_into_superproject(const char *prefix, void absorb_git_dir_into_superproject(const char *path,
const char *path,
unsigned flags); unsigned flags);


/* /*

View File

@ -2076,9 +2076,7 @@ static void wt_porcelain_v2_submodule_state(
/* /*
* Fix-up changed entries before we print them. * Fix-up changed entries before we print them.
*/ */
static void wt_porcelain_v2_fix_up_changed( static void wt_porcelain_v2_fix_up_changed(struct string_list_item *it)
struct string_list_item *it,
struct wt_status *s)
{ {
struct wt_status_change_data *d = it->util; struct wt_status_change_data *d = it->util;


@ -2138,7 +2136,7 @@ static void wt_porcelain_v2_print_changed_entry(
char submodule_token[5]; char submodule_token[5];
char sep_char, eol_char; char sep_char, eol_char;


wt_porcelain_v2_fix_up_changed(it, s); wt_porcelain_v2_fix_up_changed(it);
wt_porcelain_v2_submodule_state(d, submodule_token); wt_porcelain_v2_submodule_state(d, submodule_token);


key[0] = d->index_status ? d->index_status : '.'; key[0] = d->index_status ? d->index_status : '.';