From: Jan-Benedict Glaw Date: Thu, 09 Mar 2006 17:14:34 GMT Subject: Re: [PATCH 1/3] Nicer output from 'git' Message-ID: <20060309171434.GD4297@lug-owl.de> In-Reply-To: <20060309162419.GB4484@c165.ib.student.liu.se> On Thu, 2006-03-09 17:24:19 +0100, Fredrik Kuivinen wrote: > --- /dev/null > +++ b/generate-cmdlist.sh > @@ -0,0 +1,22 @@ > +#!/bin/sh > + > +echo "/* Automatically generated by $0 */ > +struct cmdname_help > +{ > + char name[16]; > + char help[64]; > +}; > + > +struct cmdname_help common_cmds[] = {" I'd use a here document for this. > +# Please keep this list sorted > +for i in "add" "apply" "bisect" "branch" "checkout" "cherry-pick" "clone" \ > +"commit" "diff" "fetch" "grep" "init-db" "log" "merge" "mv" \ > +"prune" "pull" "push" "rebase" "reset" "revert" "rm" "show-branch" \ > +"status" "tag" "verify-tag" "whatchanged" You can omit all the quotes here--these words won't change by any means of variable substitution or whitespace rearrangement... > +static void list_common_cmds_help() > +{ > + int i, longest = 0; > + > + for(i = 0; i < sizeof(common_cmds)/sizeof(struct cmdname_help); i++) { This smells like a good candidate for ARRAY_SIZE()? > + if(strlen(common_cmds[i].name) > longest) > + longest = strlen(common_cmds[i].name); > + } Maybe make len a size_t instead of int? > + puts("The most commonly used git commands are:"); > + for(i = 0; i < sizeof(common_cmds)/sizeof(struct cmdname_help); i++) { ARRAY_SIZE() MfG, JBG -- Jan-Benedict Glaw jbglaw@lug-owl.de . +49-172-7608481 _ O _ "Eine Freie Meinung in einem Freien Kopf | Gegen Zensur | Gegen Krieg _ _ O für einen Freien Staat voll Freier Bürger" | im Internet! | im Irak! O O O ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));