From: Sverre Rabbelier <srabbelier@gmail.com>
To: "Shawn O. Pearce" <spearce@spearce.org>,
"Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
"Git List" <git@vger.kernel.org>
Cc: Sverre Rabbelier <srabbelier@gmail.com>
Subject: [RFC PATCH 2/2] fast-import: add option command
Date: Sat, 1 Aug 2009 22:06:09 -0700 [thread overview]
Message-ID: <1249189570-26576-3-git-send-email-srabbelier@gmail.com> (raw)
In-Reply-To: <1249189570-26576-2-git-send-email-srabbelier@gmail.com>
This allows the frontend to specify any of the supported options as
long as no non-option command has been given. This way the
user does not have to include any frontend-specific options, but
instead she can rely on the frontend to tell fast-import what it
needs.
Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
---
This addds an extra prefixcmp for each command, but only for the
first command, and any 'option' commands. I felt that was better
than to add seen_non_option_command=1 to each other command.
fast-import.c | 39 +++++++++++++++++++++++++++++++++++++++
1 files changed, 39 insertions(+), 0 deletions(-)
diff --git a/fast-import.c b/fast-import.c
index 57fff3b..2007ed8 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -348,6 +348,7 @@ static struct recent_command *rc_free;
static unsigned int cmd_save = 100;
static uintmax_t next_mark;
static struct strbuf new_data = STRBUF_INIT;
+static int seen_non_option_command;
static void write_branch_report(FILE *rpt, struct branch *b)
{
@@ -1663,6 +1664,10 @@ static int read_next_command(void)
if (stdin_eof)
return EOF;
+ if (!seen_non_option_command
+ && prefixcmp(command_buf.buf, "option "))
+ seen_non_option_command = 1;
+
rc = rc_free;
if (rc)
rc_free = rc->next;
@@ -2422,6 +2427,38 @@ static void option_stats() {
show_stats = 1;
}
+static void parse_option(void)
+{
+ char* option = command_buf.buf + 7;
+
+ if (seen_non_option_command)
+ die("Got option command '%s' after non-option command", option);
+
+ if (!prefixcmp(option, "date-format")) {
+ option_date_format(option + 12);
+ } else if (!prefixcmp(option, "max-pack-size")) {
+ option_max_pack_size(option + 14);
+ } else if (!prefixcmp(option, "depth")) {
+ option_depth(option + 6);
+ } else if (!prefixcmp(option, "active-branches")) {
+ option_active_branches(option + 16);
+ } else if (!prefixcmp(option, "import-marks")) {
+ option_import_marks(option + 13);
+ } else if (!prefixcmp(option, "export-marks")) {
+ option_export_marks(option + 13);
+ } else if (!prefixcmp(option, "export-pack-edges")) {
+ option_export_pack_edges(option + 18);
+ } else if (!prefixcmp(option, "force")) {
+ option_force();
+ } else if (!prefixcmp(option, "quiet")) {
+ option_quiet();
+ } else if (!prefixcmp(option, "stats")) {
+ option_stats();
+ } else {
+ die("Unsupported option: %s", option);
+ }
+}
+
static int git_pack_config(const char *k, const char *v, void *cb)
{
if (!strcmp(k, "pack.depth")) {
@@ -2516,6 +2553,8 @@ int main(int argc, const char **argv)
parse_checkpoint();
else if (!prefixcmp(command_buf.buf, "progress "))
parse_progress();
+ else if (!prefixcmp(command_buf.buf, "option "))
+ parse_option();
else
die("Unsupported command: %s", command_buf.buf);
}
--
1.6.3.GIT
next prev parent reply other threads:[~2009-08-02 5:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-02 1:29 option directive to fast-import Sverre Rabbelier
2009-08-02 5:06 ` [RFC PATCH 0/3] fast-import: add option command Sverre Rabbelier
2009-08-02 5:06 ` [RFC PATCH 1/2] fast-import: put option parsing code in seperate functions Sverre Rabbelier
2009-08-02 5:06 ` Sverre Rabbelier [this message]
2009-08-02 5:06 ` [RFC PATCH 3/3] fast-import: test the new option command Sverre Rabbelier
2009-08-02 7:09 ` [RFC PATCH v1a 1/3] fast-import: put option parsing code in seperate functions Sverre Rabbelier
2009-08-03 0:15 ` [RFC PATCH 0/3] fast-import: add option command Shawn O. Pearce
2009-08-03 4:31 ` Sverre Rabbelier
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=1249189570-26576-3-git-send-email-srabbelier@gmail.com \
--to=srabbelier@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=spearce@spearce.org \
/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).