summaryrefslogtreecommitdiff
path: root/archive.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2025-04-24 17:25:33 -0700
committerJunio C Hamano <gitster@pobox.com>2025-04-24 17:25:34 -0700
commit2bc5414c411aab33c155b1070b7764ef6a49a02d (patch)
tree3f2b065f7c9c54838ab380ba5d16e7a9f742344b /archive.c
parent68e5342e191a2de216dbf712a6dbfa49282429c4 (diff)
parent791aeddfa2fdb9e830e24c50c97bb5e8bf3613e6 (diff)
Merge branch 'ps/parse-options-integers'
Update parse-options API to catch mistakes to pass address of an integral variable of a wrong type/size. * ps/parse-options-integers: parse-options: detect mismatches in integer signedness parse-options: introduce precision handling for `OPTION_UNSIGNED` parse-options: introduce precision handling for `OPTION_INTEGER` parse-options: rename `OPT_MAGNITUDE()` to `OPT_UNSIGNED()` parse-options: support unit factors in `OPT_INTEGER()` global: use designated initializers for options parse: fix off-by-one for minimum signed values
Diffstat (limited to 'archive.c')
-rw-r--r--archive.c35
1 files changed, 26 insertions, 9 deletions
diff --git a/archive.c b/archive.c
index 014c312178..8309ea213e 100644
--- a/archive.c
+++ b/archive.c
@@ -650,20 +650,37 @@ static int parse_archive_args(int argc, const char **argv,
OPT_STRING(0, "format", &format, N_("fmt"), N_("archive format")),
OPT_STRING(0, "prefix", &base, N_("prefix"),
N_("prepend prefix to each pathname in the archive")),
- { OPTION_CALLBACK, 0, "add-file", args, N_("file"),
- N_("add untracked file to archive"), 0, add_file_cb,
- (intptr_t)&base },
- { OPTION_CALLBACK, 0, "add-virtual-file", args,
- N_("path:content"), N_("add untracked file to archive"), 0,
- add_file_cb, (intptr_t)&base },
+ {
+ .type = OPTION_CALLBACK,
+ .long_name = "add-file",
+ .value = args,
+ .argh = N_("file"),
+ .help = N_("add untracked file to archive"),
+ .callback = add_file_cb,
+ .defval = (intptr_t) &base,
+ },
+ {
+ .type = OPTION_CALLBACK,
+ .long_name = "add-virtual-file",
+ .value = args,
+ .argh = N_("path:content"),
+ .help = N_("add untracked file to archive"),
+ .callback = add_file_cb,
+ .defval = (intptr_t) &base,
+ },
OPT_STRING('o', "output", &output, N_("file"),
N_("write the archive to this file")),
OPT_BOOL(0, "worktree-attributes", &worktree_attributes,
N_("read .gitattributes in working directory")),
OPT__VERBOSE(&verbose, N_("report archived files on stderr")),
- { OPTION_STRING, 0, "mtime", &mtime_option, N_("time"),
- N_("set modification time of archive entries"),
- PARSE_OPT_NONEG },
+ {
+ .type = OPTION_STRING,
+ .long_name = "mtime",
+ .value = &mtime_option,
+ .argh = N_("time"),
+ .help = N_("set modification time of archive entries"),
+ .flags = PARSE_OPT_NONEG,
+ },
OPT_NUMBER_CALLBACK(&compression_level,
N_("set compression level"), number_callback),
OPT_GROUP(""),