From: "Kristian Høgsberg" <krh@redhat.com>
To: git@vger.kernel.org
Subject: Working on builtin-commit
Date: Mon, 25 Jun 2007 15:27:11 -0400 [thread overview]
Message-ID: <1182799631.1689.35.camel@hinata.boston.redhat.com> (raw)
Hi,
To avoid duplication of work, here's a short heads up. I've started
working on porting git-commit.sh (and status) to builtins. It's still
work in progress, and nowhere near a full-time effort, but to prevent
doing double work as with builtin-tag, I thought I'd let the list know.
I have a repo over here:
git://people.freedesktop.org/~krh/git.git
and the code is browsable here:
http://cgit.freedesktop.org/~krh/git.git
on the 'builtin-commit' branch.
It's just a snapshot of my current progress, so don't slam my lack of
error checking etc just yet. The work also needs to be split out in a
few patches (eg the read_pipe stuff). One thing that might be
interesting to discuss now, though, is my approach to option parsing. I
realize real men do this by hand using a lot of strcmp's, but I broke
down and wrote a little option parser. You give it a pointer to argv
and an array of these:
struct option {
enum option_type type;
const char *long_name;
char short_name;
void *value;
};
with
enum option_type {
OPTION_NONE,
OPTION_STRING,
OPTION_INTEGER,
OPTION_LAST
};
and it goes and parses the command line. As the shell script, it
accepts all abreviations of long options, eg all of --messa doit,
--message=doit, -mdoit, -m doit, for the long_name="message";
short_name='m' case. Ambiguous abbreviations are resolved according to
the order the options appears in the array. I've kept it as simple as
possible and it works well for builtin-commit.c. It's obviously useful
for other commands, but my goal here is to get git-commit.sh ported to
C, not to host a flamewar over the option parser API and whether we
should port other builtins.
cheers,
Kristian
reply other threads:[~2007-06-25 19:27 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1182799631.1689.35.camel@hinata.boston.redhat.com \
--to=krh@redhat.com \
--cc=git@vger.kernel.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