Skip to content

Commit 5247b76

Browse files
peffgitster
authored andcommitted
builtins: mark unused prefix parameters
All builtins receive a "prefix" parameter, but it is only useful if they need to adjust filenames given by the user on the command line. For builtins that do not even call parse_options(), they often don't look at the prefix at all, and -Wunused-parameter complains. Let's annotate those to silence the compiler warning. I gave a quick scan of each of these cases, and it seems like they don't have anything they _should_ be using the prefix for (i.e., there is no hidden bug that we are missing). The only questionable cases I saw were: - in git-unpack-file, we create a tempfile which will always be at the root of the repository, even if the command is run from a subdir. Arguably this should be created in the subdir from which we're run (as we report the path only as a relative name). However, nobody has complained, and I'm hesitant to change something that is deep plumbing going back to April 2005 (though I think within our scripts, the sole caller in git-merge-one-file would be OK, as it moves to the toplevel itself). - in fetch-pack, local-filesystem remotes are taken as relative to the project root, not the current directory. So: git init server.git [...put stuff in server.git...] git init client.git cd client.git mkdir subdir cd subdir git fetch-pack ../../server.git ... won't work, as we quietly move to the top of the repository before interpreting the path (so "../server.git" would work). This is weird, but again, nobody has complained and this is how it has always worked. And this is how "git fetch" works, too. Plus it raises questions about how a configured remote like: git config remote.origin.url ../server.git should behave. I can certainly come up with a reasonable set of behavior, but it may not be worth stirring up complications in a plumbing tool. So I've left the behavior untouched in both of those cases. If anybody really wants to revisit them, it's easy enough to drop the UNUSED marker. This commit is just about removing them as obstacles to turning on -Wunused-parameter all the time. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7915691 commit 5247b76

12 files changed

+12
-12
lines changed

builtin/credential.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
static const char usage_msg[] =
77
"git credential (fill|approve|reject)";
88

9-
int cmd_credential(int argc, const char **argv, const char *prefix)
9+
int cmd_credential(int argc, const char **argv, const char *prefix UNUSED)
1010
{
1111
const char *op;
1212
struct credential c = CREDENTIAL_INIT;

builtin/fetch-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static void add_sought_entry(struct ref ***sought, int *nr, int *alloc,
4242
(*sought)[*nr - 1] = ref;
4343
}
4444

45-
int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
45+
int cmd_fetch_pack(int argc, const char **argv, const char *prefix UNUSED)
4646
{
4747
int i, ret;
4848
struct ref *ref = NULL;

builtin/fsmonitor--daemon.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1575,7 +1575,7 @@ int cmd_fsmonitor__daemon(int argc, const char **argv, const char *prefix)
15751575
}
15761576

15771577
#else
1578-
int cmd_fsmonitor__daemon(int argc, const char **argv, const char *prefix)
1578+
int cmd_fsmonitor__daemon(int argc, const char **argv, const char *prefix UNUSED)
15791579
{
15801580
struct option options[] = {
15811581
OPT_END()

builtin/merge-index.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ static void merge_all(void)
7171
}
7272
}
7373

74-
int cmd_merge_index(int argc, const char **argv, const char *prefix)
74+
int cmd_merge_index(int argc, const char **argv, const char *prefix UNUSED)
7575
{
7676
int i, force_file = 0;
7777

builtin/merge-ours.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
static const char builtin_merge_ours_usage[] =
1515
"git merge-ours <base>... -- HEAD <remote>...";
1616

17-
int cmd_merge_ours(int argc, const char **argv, const char *prefix)
17+
int cmd_merge_ours(int argc, const char **argv, const char *prefix UNUSED)
1818
{
1919
if (argc == 2 && !strcmp(argv[1], "-h"))
2020
usage(builtin_merge_ours_usage);

builtin/merge-recursive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ static char *better_branch_name(const char *branch)
2020
return xstrdup(name ? name : branch);
2121
}
2222

23-
int cmd_merge_recursive(int argc, const char **argv, const char *prefix)
23+
int cmd_merge_recursive(int argc, const char **argv, const char *prefix UNUSED)
2424
{
2525
const struct object_id *bases[21];
2626
unsigned bases_count = 0;

builtin/pack-redundant.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ static void load_all(void)
558558
}
559559
}
560560

561-
int cmd_pack_redundant(int argc, const char **argv, const char *prefix)
561+
int cmd_pack_redundant(int argc, const char **argv, const char *prefix UNUSED)
562562
{
563563
int i;
564564
int i_still_use_this = 0;

builtin/stash.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1466,7 +1466,7 @@ static int do_create_stash(const struct pathspec *ps, struct strbuf *stash_msg_b
14661466
return ret;
14671467
}
14681468

1469-
static int create_stash(int argc, const char **argv, const char *prefix)
1469+
static int create_stash(int argc, const char **argv, const char *prefix UNUSED)
14701470
{
14711471
int ret;
14721472
struct strbuf stash_msg_buf = STRBUF_INIT;

builtin/submodule--helper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2766,7 +2766,7 @@ static int module_update(int argc, const char **argv, const char *prefix)
27662766
return ret;
27672767
}
27682768

2769-
static int push_check(int argc, const char **argv, const char *prefix)
2769+
static int push_check(int argc, const char **argv, const char *prefix UNUSED)
27702770
{
27712771
struct remote *remote;
27722772
const char *superproject_head;

builtin/unpack-file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ static char *create_temp_file(struct object_id *oid)
2424
return path;
2525
}
2626

27-
int cmd_unpack_file(int argc, const char **argv, const char *prefix)
27+
int cmd_unpack_file(int argc, const char **argv, const char *prefix UNUSED)
2828
{
2929
struct object_id oid;
3030

0 commit comments

Comments
 (0)