From: "Sidhant Sharma [:tk]" <tigerkid001@gmail.com>
To: git@vger.kernel.org
Cc: matthieu.moy@grenoble-inp.fr, sunshine@sunshineco.com
Subject: [PATCH v2] builtin/receive-pack.c: use parse_options API
Date: Wed, 2 Mar 2016 01:51:01 +0530 [thread overview]
Message-ID: <1456863661-22783-1-git-send-email-tigerkid001@gmail.com> (raw)
In-Reply-To: <1456846560-9223-1-git-send-email-tigerkid001@gmail.com>
In-Reply-To: <1456846560-9223-1-git-send-email-tigerkid001@gmail.com>
Make receive-pack use the parse_options API,
bringing it more in line with send-pack and push.
Helped-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: Sidhant Sharma [:tk] <tigerkid001@gmail.com>
---
Link to previous version: $gmane/288035
builtin/receive-pack.c | 53 +++++++++++++++++++-------------------------------
1 file changed, 20 insertions(+), 33 deletions(-)
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index c8e32b2..220a899 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -21,7 +21,10 @@
#include "sigchain.h"
#include "fsck.h"
-static const char receive_pack_usage[] = "git receive-pack <git-dir>";
+static const char * const receive_pack_usage[] = {
+ N_("git receive-pack <git-dir>"),
+ NULL
+};
enum deny_action {
DENY_UNCONFIGURED,
@@ -49,7 +52,7 @@ static int quiet;
static int prefer_ofs_delta = 1;
static int auto_update_server_info;
static int auto_gc = 1;
-static int fix_thin = 1;
+static int reject_thin;
static int stateless_rpc;
static const char *service_dir;
static const char *head_name;
@@ -1548,7 +1551,7 @@ static const char *unpack(int err_fd, struct shallow_info *si)
if (fsck_objects)
argv_array_pushf(&child.args, "--strict%s",
fsck_msg_types.buf);
- if (fix_thin)
+ if (!reject_thin)
argv_array_push(&child.args, "--fix-thin");
child.out = -1;
child.err = err_fd;
@@ -1707,45 +1710,29 @@ static int delete_only(struct command *commands)
int cmd_receive_pack(int argc, const char **argv, const char *prefix)
{
int advertise_refs = 0;
- int i;
struct command *commands;
struct sha1_array shallow = SHA1_ARRAY_INIT;
struct sha1_array ref = SHA1_ARRAY_INIT;
struct shallow_info si;
+ struct option options[] = {
+ OPT__QUIET(&quiet, N_("quiet")),
+ OPT_HIDDEN_BOOL(0, "stateless-rpc", &stateless_rpc, NULL),
+ OPT_HIDDEN_BOOL(0, "advertise-refs", &advertise_refs, NULL),
+ OPT_HIDDEN_BOOL(0, "reject-thin-pack-for-testing", &reject_thin, NULL),
+ OPT_END()
+ };
+
packet_trace_identity("receive-pack");
- argv++;
- for (i = 1; i < argc; i++) {
- const char *arg = *argv++;
+ argc = parse_options(argc, argv, prefix, options, receive_pack_usage, 0);
- if (*arg == '-') {
- if (!strcmp(arg, "--quiet")) {
- quiet = 1;
- continue;
- }
+ if (argc > 1)
+ usage_msg_opt(_("Too many arguments."), receive_pack_usage, options);
+ if (argc == 0)
+ usage_msg_opt(_("You must specify a directory."), receive_pack_usage, options);
- if (!strcmp(arg, "--advertise-refs")) {
- advertise_refs = 1;
- continue;
- }
- if (!strcmp(arg, "--stateless-rpc")) {
- stateless_rpc = 1;
- continue;
- }
- if (!strcmp(arg, "--reject-thin-pack-for-testing")) {
- fix_thin = 0;
- continue;
- }
-
- usage(receive_pack_usage);
- }
- if (service_dir)
- usage(receive_pack_usage);
- service_dir = arg;
- }
- if (!service_dir)
- usage(receive_pack_usage);
+ service_dir = argv[0];
setup_path();
--
2.7.2
next prev parent reply other threads:[~2016-03-01 20:21 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-01 15:36 [PATCH] builtin/receive-pack.c: use parse_options API Sidhant Sharma [:tk]
2016-03-01 17:22 ` Matthieu Moy
2016-03-01 17:48 ` Sidhant Sharma
2016-03-01 17:57 ` Matthieu Moy
2016-03-01 18:54 ` Eric Sunshine
2016-03-01 20:21 ` Sidhant Sharma [:tk] [this message]
2016-03-01 20:31 ` [PATCH v2] " Sidhant Sharma
2016-03-01 20:39 ` Matthieu Moy
2016-03-01 22:05 ` Junio C Hamano
2016-03-02 5:18 ` Sidhant Sharma
2016-03-02 8:51 ` Junio C Hamano
2016-03-02 8:23 ` Matthieu Moy
2016-03-02 9:53 ` Duy Nguyen
2016-03-02 13:53 ` Sidhant Sharma
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1456863661-22783-1-git-send-email-tigerkid001@gmail.com \
--to=tigerkid001@gmail.com \
--cc=git@vger.kernel.org \
--cc=matthieu.moy@grenoble-inp.fr \
--cc=sunshine@sunshineco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).