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

Re: [PATCH 3/3] vcs-svn: Refactor dump_export code into dispatch table

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Feb 1, 2011, 17:42 UTC
Message-ID
<20110201174241.GB3771@burratino>
In-Reply-To
<1296570403-9082-4-git-send-email-artagnon@gmail.com>
Ramkumar Ramachandra wrote:
> +++ b/vcs-svn/dump_export.c
> @@ -11,6 +11,48 @@
[...]
Show 16 quoted lines
> +static state_fn *const dispatch_table[NODE_KIND_COUNT][NODE_ACTION_COUNT] = {
> +	/* NODE_KIND_UNKNOWN */
> +	{abort, abort, abort, Adelete, abort},
> +	/* NODE_KIND_NORMAL */
> +	{abort, Nchange, Nadd, Adelete, Nreplace},
> +	/* NODE_KIND_EXECUTABLE */
> +	{abort, Echange, Eadd, Adelete, Ereplace},
> +	/* NODE_KIND_SYMLINK */
> +	{abort, Schange, Sadd, Adelete, Sreplace},
> +	/* NODE_KIND_GITLINK */
> +	{abort, abort, abort, abort, abort},
> +	/* NODE_KIND_DIR */
> +	{abort, Dchange, Dadd, Adelete, Dreplace},
> +	/* NODE_KIND_SUBDIR */
> +	{abort, abort, abort, abort, abort}
> +};

Heh. I think that Junio was suggesting making the _parser_ table-driven, meaning something like

	... node_kinds[] = {
		{ "100644", sizeof("100644"), "file" },
		{ "100755", sizeof("100755"), "file", "svn:executable" },
		{ "120000", sizeof("120000"), "file", "svn:special" },
		{ "160000", sizeof("160000"), "file" },	/* NEEDSWORK: seems wrong" */
		{ "040000", sizeof("040000"), "dir" }
	};

(Side note: remember that 644 and 755 are permitted synonyms for 100644 and 100755!)

I personally think that simple state machines tend to be easier to follow if the current state is represented by the instruction pointer rather than a variable, as in the current fast-import.c. But maybe that's a matter of taste?

Anyway, my other complaints about this dispatch_table are that the function names leave me rubbing my head and I can't keep the list of states you're transitioning between straight in my head. I guess "Adelete" is an abbreviation for print_delete_node_action? Is a callback needed at all (rather than just a string) for such actions?

Hope that helps, Jonathan

Previous: Ramkumar RamachandraNext: Junio C Hamano
Message 11 of 13 in “Towards a Git-to-SVN bridge”
  1. 0/3 Towards a Git-to-SVN bridgeRamkumar Ramachandra, Feb 1, 2011
  2. 1/3 vcs-svn: Introduce svnload, a dumpfile producerRamkumar Ramachandra, Feb 1, 2011
  3. Erik Faye-LundFeb 1, 2011
  4. Ramkumar RamachandraFeb 2, 2011
  5. Erik Faye-LundFeb 2, 2011
  6. 2/3 t9010-svn-fi: Add tests for svn-fiRamkumar Ramachandra, Feb 1, 2011
  7. Jonathan NiederFeb 1, 2011
  8. Ramkumar RamachandraFeb 2, 2011
  9. Jonathan NiederFeb 2, 2011
  10. 3/3 vcs-svn: Refactor dump_export code into dispatch tableRamkumar Ramachandra, Feb 1, 2011
  11. Jonathan NiederFeb 1, 2011
  12. Junio C HamanoFeb 1, 2011
  13. Ramkumar RamachandraFeb 2, 2011

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.