Skip to content

Commit c0e78f7

Browse files
committed
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
2 parents 8202d12 + 8373037 commit c0e78f7

22 files changed

+53
-72
lines changed

builtin/clone.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,7 @@ static void setup_reference(void)
354354
add_one_reference, &required);
355355
}
356356

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

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

builtin/column.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ int cmd_column(int argc, const char **argv, const char *prefix)
4343

4444
memset(&copts, 0, sizeof(copts));
4545
copts.padding = 1;
46-
argc = parse_options(argc, argv, "", options, builtin_column_usage, 0);
46+
argc = parse_options(argc, argv, prefix, options, builtin_column_usage, 0);
4747
if (argc)
4848
usage_with_options(builtin_column_usage, options);
4949
if (real_command || command) {

builtin/hash-object.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ int cmd_hash_object(int argc, const char **argv, const char *prefix)
108108
int i;
109109
const char *errstr = NULL;
110110

111-
argc = parse_options(argc, argv, NULL, hash_object_options,
111+
argc = parse_options(argc, argv, prefix, hash_object_options,
112112
hash_object_usage, 0);
113113

114114
if (flags & HASH_WRITE_OBJECT)

builtin/mktree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static const char *mktree_usage[] = {
6767
NULL
6868
};
6969

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

builtin/name-rev.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ static void set_commit_rev_name(struct commit *commit, struct rev_name *name)
4040
}
4141

4242
static int is_better_name(struct rev_name *name,
43-
const char *tip_name,
4443
timestamp_t taggerdate,
45-
int generation,
4644
int distance,
4745
int from_tag)
4846
{
@@ -103,8 +101,7 @@ static void name_rev(struct commit *commit,
103101
name = xmalloc(sizeof(rev_name));
104102
set_commit_rev_name(commit, name);
105103
goto copy_data;
106-
} else if (is_better_name(name, tip_name, taggerdate,
107-
generation, distance, from_tag)) {
104+
} else if (is_better_name(name, taggerdate, distance, from_tag)) {
108105
copy_data:
109106
name->tip_name = tip_name;
110107
name->taggerdate = taggerdate;

builtin/pack-objects.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2899,7 +2899,7 @@ static int ofscmp(const void *a_, const void *b_)
28992899
return oidcmp(&a->object->oid, &b->object->oid);
29002900
}
29012901

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

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

31603160
if (keep_unreachable)
3161-
add_objects_in_unpacked_packs(&revs);
3161+
add_objects_in_unpacked_packs();
31623162
if (pack_loose_unreachable)
31633163
add_unreachable_loose_objects();
31643164
if (unpack_unreachable)
3165-
loosen_unused_packed_objects(&revs);
3165+
loosen_unused_packed_objects();
31663166

31673167
oid_array_clear(&recent_objects);
31683168
}

builtin/range-diff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ int cmd_range_diff(int argc, const char **argv, const char *prefix)
3232
repo_diff_setup(the_repository, &diffopt);
3333

3434
options = parse_options_concat(range_diff_options, diffopt.parseopts);
35-
argc = parse_options(argc, argv, NULL, options,
35+
argc = parse_options(argc, argv, prefix, options,
3636
builtin_range_diff_usage, 0);
3737

3838
diff_setup_done(&diffopt);

builtin/read-tree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static int git_read_tree_config(const char *var, const char *value, void *cb)
111111
return git_default_config(var, value, cb);
112112
}
113113

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

166166
git_config(git_read_tree_config, NULL);
167167

168-
argc = parse_options(argc, argv, unused_prefix, read_tree_options,
168+
argc = parse_options(argc, argv, cmd_prefix, read_tree_options,
169169
read_tree_usage, 0);
170170

171171
hold_locked_index(&lock_file, LOCK_DIE_ON_ERROR);

builtin/rebase.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
508508
if (argc == 1)
509509
usage_with_options(builtin_rebase_interactive_usage, options);
510510

511-
argc = parse_options(argc, argv, NULL, options,
511+
argc = parse_options(argc, argv, prefix, options,
512512
builtin_rebase_interactive_usage, PARSE_OPT_KEEP_ARGV0);
513513

514514
if (!is_null_oid(&squash_onto))

builtin/receive-pack.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1809,8 +1809,7 @@ static const char *unpack_with_sideband(struct shallow_info *si)
18091809
return ret;
18101810
}
18111811

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

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

18781877
if (shallow_update) {
1879-
prepare_shallow_update(commands, si);
1878+
prepare_shallow_update(si);
18801879
return;
18811880
}
18821881

builtin/remote.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,7 +1407,7 @@ static int update(int argc, const char **argv)
14071407
return retval;
14081408
}
14091409

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

1440-
if (!add_mode && remove_all_fetch_refspecs(remotename, key.buf)) {
1440+
if (!add_mode && remove_all_fetch_refspecs(key.buf)) {
14411441
strbuf_release(&key);
14421442
return 1;
14431443
}

builtin/rev-list.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ static enum missing_action arg_missing_action;
7777

7878
#define DEFAULT_OIDSET_SIZE (16*1024)
7979

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

8888
if (info->flags & REV_LIST_QUIET) {
89-
finish_commit(commit, data);
89+
finish_commit(commit);
9090
return;
9191
}
9292

@@ -99,7 +99,7 @@ static void show_commit(struct commit *commit, void *data)
9999
revs->count_left++;
100100
else
101101
revs->count_right++;
102-
finish_commit(commit, data);
102+
finish_commit(commit);
103103
return;
104104
}
105105

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

194-
static void finish_commit(struct commit *commit, void *data)
194+
static void finish_commit(struct commit *commit)
195195
{
196196
if (commit->parents) {
197197
free_commit_list(commit->parents);

builtin/rm.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static void print_error_files(struct string_list *files_list,
6161
}
6262
}
6363

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

8585
if (!submodule_uses_gitfile(name))
86-
absorb_git_dir_into_superproject(prefix, name,
86+
absorb_git_dir_into_superproject(name,
8787
ABSORB_GITDIR_RECURSE_SUBMODULES);
8888
}
8989
}
@@ -313,7 +313,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
313313
}
314314

315315
if (!index_only)
316-
submodules_absorb_gitdir_if_needed(prefix);
316+
submodules_absorb_gitdir_if_needed();
317317

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

builtin/show-branch.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,6 @@ static int show_merge_base(struct commit_list *seen, int num_rev)
514514

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

864863
if (independent)
865-
return show_independent(rev, num_rev, ref_name, rev_mask);
864+
return show_independent(rev, num_rev, rev_mask);
866865

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

builtin/submodule--helper.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2107,8 +2107,7 @@ static int absorb_git_dirs(int argc, const char **argv, const char *prefix)
21072107
return 1;
21082108

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

21132112
return 0;
21142113
}

builtin/upload-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ int cmd_upload_pack(int argc, const char **argv, const char *prefix)
3333
packet_trace_identity("upload-pack");
3434
read_replace_refs = 0;
3535

36-
argc = parse_options(argc, argv, NULL, options, upload_pack_usage, 0);
36+
argc = parse_options(argc, argv, prefix, options, upload_pack_usage, 0);
3737

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

builtin/verify-commit.c

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,14 @@ static const char * const verify_commit_usage[] = {
2121
NULL
2222
};
2323

24-
static int run_gpg_verify(const struct object_id *oid, const char *buf, unsigned long size, unsigned flags)
24+
static int run_gpg_verify(struct commit *commit, unsigned flags)
2525
{
2626
struct signature_check signature_check;
2727
int ret;
2828

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

31-
ret = check_commit_signature(lookup_commit(the_repository, oid),
32-
&signature_check);
31+
ret = check_commit_signature(commit, &signature_check);
3332
print_signature_buffer(&signature_check, flags);
3433

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

3938
static int verify_commit(const char *name, unsigned flags)
4039
{
41-
enum object_type type;
4240
struct object_id oid;
43-
char *buf;
44-
unsigned long size;
45-
int ret;
41+
struct object *obj;
4642

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

50-
buf = read_object_file(&oid, &type, &size);
51-
if (!buf)
46+
obj = parse_object(the_repository, &oid);
47+
if (!obj)
5248
return error("%s: unable to read file.", name);
53-
if (type != OBJ_COMMIT)
49+
if (obj->type != OBJ_COMMIT)
5450
return error("%s: cannot verify a non-commit object of type %s.",
55-
name, type_name(type));
56-
57-
ret = run_gpg_verify(&oid, buf, size, flags);
51+
name, type_name(obj->type));
5852

59-
free(buf);
60-
return ret;
53+
return run_gpg_verify((struct commit *)obj, flags);
6154
}
6255

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

builtin/write-tree.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ static const char * const write_tree_usage[] = {
1616
NULL
1717
};
1818

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

3737
git_config(git_default_config, NULL);
38-
argc = parse_options(argc, argv, unused_prefix, write_tree_options,
38+
argc = parse_options(argc, argv, cmd_prefix, write_tree_options,
3939
write_tree_usage, 0);
4040

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

read-cache.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2037,7 +2037,7 @@ static void *load_cache_entries_thread(void *_data)
20372037
}
20382038

20392039
static unsigned long load_cache_entries_threaded(struct index_state *istate, const char *mmap, size_t mmap_size,
2040-
unsigned long src_offset, int nr_threads, struct index_entry_offset_table *ieot)
2040+
int nr_threads, struct index_entry_offset_table *ieot)
20412041
{
20422042
int i, offset, ieot_blocks, ieot_start, err;
20432043
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)
21982198
ieot = read_ieot_extension(mmap, mmap_size, extension_offset);
21992199

22002200
if (ieot) {
2201-
src_offset += load_cache_entries_threaded(istate, mmap, mmap_size, src_offset, nr_threads, ieot);
2201+
src_offset += load_cache_entries_threaded(istate, mmap, mmap_size, nr_threads, ieot);
22022202
free(ieot);
22032203
} else {
22042204
src_offset += load_all_cache_entries(istate, mmap, mmap_size, src_offset);

0 commit comments

Comments
 (0)