|
21 | 21 | #include "sigchain.h" |
22 | 22 | #include "fsck.h" |
23 | 23 |
|
24 | | -static const char receive_pack_usage[] = "git receive-pack <git-dir>"; |
| 24 | +static const char * const receive_pack_usage[] = { |
| 25 | + N_("git receive-pack <git-dir>"), |
| 26 | + NULL |
| 27 | +}; |
25 | 28 |
|
26 | 29 | enum deny_action { |
27 | 30 | DENY_UNCONFIGURED, |
@@ -49,7 +52,7 @@ static int quiet; |
49 | 52 | static int prefer_ofs_delta = 1; |
50 | 53 | static int auto_update_server_info; |
51 | 54 | static int auto_gc = 1; |
52 | | -static int fix_thin = 1; |
| 55 | +static int reject_thin; |
53 | 56 | static int stateless_rpc; |
54 | 57 | static const char *service_dir; |
55 | 58 | static const char *head_name; |
@@ -1548,7 +1551,7 @@ static const char *unpack(int err_fd, struct shallow_info *si) |
1548 | 1551 | if (fsck_objects) |
1549 | 1552 | argv_array_pushf(&child.args, "--strict%s", |
1550 | 1553 | fsck_msg_types.buf); |
1551 | | - if (fix_thin) |
| 1554 | + if (!reject_thin) |
1552 | 1555 | argv_array_push(&child.args, "--fix-thin"); |
1553 | 1556 | child.out = -1; |
1554 | 1557 | child.err = err_fd; |
@@ -1707,45 +1710,29 @@ static int delete_only(struct command *commands) |
1707 | 1710 | int cmd_receive_pack(int argc, const char **argv, const char *prefix) |
1708 | 1711 | { |
1709 | 1712 | int advertise_refs = 0; |
1710 | | - int i; |
1711 | 1713 | struct command *commands; |
1712 | 1714 | struct sha1_array shallow = SHA1_ARRAY_INIT; |
1713 | 1715 | struct sha1_array ref = SHA1_ARRAY_INIT; |
1714 | 1716 | struct shallow_info si; |
1715 | 1717 |
|
1716 | | - packet_trace_identity("receive-pack"); |
| 1718 | + struct option options[] = { |
| 1719 | + OPT__QUIET(&quiet, N_("quiet")), |
| 1720 | + OPT_HIDDEN_BOOL(0, "stateless-rpc", &stateless_rpc, NULL), |
| 1721 | + OPT_HIDDEN_BOOL(0, "advertise-refs", &advertise_refs, NULL), |
| 1722 | + OPT_HIDDEN_BOOL(0, "reject-thin-pack-for-testing", &reject_thin, NULL), |
| 1723 | + OPT_END() |
| 1724 | + }; |
1717 | 1725 |
|
1718 | | - argv++; |
1719 | | - for (i = 1; i < argc; i++) { |
1720 | | - const char *arg = *argv++; |
| 1726 | + packet_trace_identity("receive-pack"); |
1721 | 1727 |
|
1722 | | - if (*arg == '-') { |
1723 | | - if (!strcmp(arg, "--quiet")) { |
1724 | | - quiet = 1; |
1725 | | - continue; |
1726 | | - } |
| 1728 | + argc = parse_options(argc, argv, prefix, options, receive_pack_usage, 0); |
1727 | 1729 |
|
1728 | | - if (!strcmp(arg, "--advertise-refs")) { |
1729 | | - advertise_refs = 1; |
1730 | | - continue; |
1731 | | - } |
1732 | | - if (!strcmp(arg, "--stateless-rpc")) { |
1733 | | - stateless_rpc = 1; |
1734 | | - continue; |
1735 | | - } |
1736 | | - if (!strcmp(arg, "--reject-thin-pack-for-testing")) { |
1737 | | - fix_thin = 0; |
1738 | | - continue; |
1739 | | - } |
| 1730 | + if (argc > 1) |
| 1731 | + usage_msg_opt(_("Too many arguments."), receive_pack_usage, options); |
| 1732 | + if (argc == 0) |
| 1733 | + usage_msg_opt(_("You must specify a directory."), receive_pack_usage, options); |
1740 | 1734 |
|
1741 | | - usage(receive_pack_usage); |
1742 | | - } |
1743 | | - if (service_dir) |
1744 | | - usage(receive_pack_usage); |
1745 | | - service_dir = arg; |
1746 | | - } |
1747 | | - if (!service_dir) |
1748 | | - usage(receive_pack_usage); |
| 1735 | + service_dir = argv[0]; |
1749 | 1736 |
|
1750 | 1737 | setup_path(); |
1751 | 1738 |
|
|
0 commit comments