git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/4] fast-import: add option command

From
Sverre Rabbelier <srabbelier@gmail.com>
Date
Aug 13, 2009, 05:09 UTC
Message-ID
<1250140186-12363-4-git-send-email-srabbelier@gmail.com>
In-Reply-To
<1250140186-12363-3-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. ---

    This is a lot simpler from the previous version as we can now
    reuse parse_one_option from 1/4.
 fast-import.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/fast-import.c b/fast-import.c
index 17d57ab..2ec804d 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;
@@ -2460,6 +2465,16 @@ static void parse_one_option(const char *option)
     }
 }
 
+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);
+
+    parse_one_option(option);
+}
+
 static int git_pack_config(const char *k, const char *v, void *cb)
 {
 	if (!strcmp(k, "pack.depth")) {
@@ -2534,6 +2549,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.4.16.g72c66.dirty
Previous: Sverre RabbelierNext: Sverre Rabbelier
Message 4 of 30 in “fast-import: add a new option command”
  1. 0/4 fast-import: add a new option commandSverre Rabbelier, Aug 13, 2009
  2. 1/4 fast-import: put option parsing code in seperate functionsSverre Rabbelier, Aug 13, 2009
  3. 2/4 fast-import: define a new option commandSverre Rabbelier, Aug 13, 2009
  4. 3/4 fast-import: add option commandSverre Rabbelier, Aug 13, 2009
  5. 4/4 fast-import: test the new option commandSverre Rabbelier, Aug 13, 2009
  6. Shawn O. PearceAug 13, 2009
  7. Shawn O. PearceAug 13, 2009
  8. Johannes SchindelinAug 13, 2009
  9. Shawn O. PearceAug 13, 2009
  10. Johannes SchindelinAug 13, 2009
  11. Shawn O. PearceAug 13, 2009
  12. Shawn O. PearceAug 13, 2009
  13. Sverre RabbelierAug 13, 2009
  14. Johannes SchindelinAug 13, 2009
  15. Sverre RabbelierAug 13, 2009
  16. Shawn O. PearceAug 13, 2009
  17. Sverre RabbelierAug 13, 2009
  18. Shawn O. PearceAug 13, 2009
  19. Sverre RabbelierAug 13, 2009
  20. Shawn O. PearceAug 13, 2009
  21. Johannes SchindelinAug 13, 2009
  22. Sverre RabbelierAug 13, 2009
  23. Shawn O. PearceAug 13, 2009
  24. Sverre RabbelierAug 13, 2009
  25. Junio C HamanoAug 13, 2009
  26. Sverre RabbelierAug 13, 2009
  27. Junio C HamanoAug 13, 2009
  28. Sverre RabbelierAug 13, 2009
  29. Sverre RabbelierNov 23, 2009
  30. Shawn O. PearceNov 23, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.