{"thread":{"id":"8720","subject":"Working on builtin-commit","startedAt":"2007-06-25T19:27:11Z","lastAt":"2007-06-25T19:27:11Z","messageCount":1,"participants":["Kristian Høgsberg"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"45786","messageId":"1182799631.1689.35.camel@hinata.boston.redhat.com","threadId":"8720","inReplyTo":null,"subject":"Working on builtin-commit","fromName":"Kristian Høgsberg","fromEmail":"krh@redhat.com","sentAt":"2007-06-25T19:27:11Z","receivedAt":"2007-06-25T19:27:11Z","isPatch":false,"sender":{"key":"krh@redhat.com","avatar":"https://gravatar.com/avatar/763dee6f9594ac474f725b137a39565792928e583ddf59b32befc2907409027e?d=mp&s=160"},"body":"Hi,\n\nTo avoid duplication of work, here's a short heads up.  I've started\nworking on porting git-commit.sh (and status) to builtins.  It's still\nwork in progress, and nowhere near a full-time effort, but to prevent\ndoing double work as with builtin-tag, I thought I'd let the list know.\nI have a repo over here:\n\n\tgit://people.freedesktop.org/~krh/git.git\n\nand the code is browsable here:\n\n\thttp://cgit.freedesktop.org/~krh/git.git\n\non the 'builtin-commit' branch.\n\nIt's just a snapshot of my current progress, so don't slam my lack of\nerror checking etc just yet.  The work also needs to be split out in a\nfew patches (eg the read_pipe stuff). One thing that might be\ninteresting to discuss now, though, is my approach to option parsing.  I\nrealize real men do this by hand using a lot of strcmp's, but I broke\ndown and wrote a little option parser.  You give it a pointer to argv\nand an array of these:\n\n\tstruct option {\n\t\tenum option_type type;\n\t\tconst char *long_name;\n\t\tchar short_name;\n\t\tvoid *value;\n\t};\n\nwith\n\n\tenum option_type {\n\t\tOPTION_NONE,\n\t\tOPTION_STRING,\n\t\tOPTION_INTEGER,\n\t\tOPTION_LAST\n\t};\n\nand it goes and parses the command line.  As the shell script, it\naccepts all abreviations of long options, eg all of --messa doit,\n--message=doit, -mdoit, -m doit, for the long_name=\"message\";\nshort_name='m' case.  Ambiguous abbreviations are resolved according to\nthe order the options appears in the array.  I've kept it as simple as\npossible and it works well for builtin-commit.c.  It's obviously useful\nfor other commands, but my goal here is to get git-commit.sh ported to\nC, not to host a flamewar over the option parser API and whether we\nshould port other builtins.\n\ncheers,\nKristian\n"}]}