Re: [PATCH 1/3] Nicer output from 'git'

From: Jan-Benedict Glaw <jbglaw@lug-owl.de>
Date: 2006-03-10 04:14:34
On Thu, 2006-03-09 17:24:19 +0100, Fredrik Kuivinen <freku045@student.liu.se> 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));

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Received on Fri Mar 10 04:15:14 2006

This archive was generated by hypermail 2.1.8 : 2006-03-10 04:15:27 EST