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

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

From
JGJan-Benedict Glaw <jbglaw@lug-owl.de>
Date
Mar 9, 2006, 17:14 UTC
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 <freku045@student.liu.se> wrote:
Show 13 quoted lines
> --- /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.
Show 5 quoted lines
> +# 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...

Show 5 quoted lines
> +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));
Previous: Fredrik KuivinenNext: Fredrik Kuivinen
Message 3 of 6 in “Make the output of 'git' nicer”
  1. 0/3 Make the output of 'git' nicerFredrik Kuivinen, Mar 9, 2006
  2. 1/3 Nicer output from 'git'Fredrik Kuivinen, Mar 9, 2006
  3. Jan-Benedict GlawMar 9, 2006
  4. 2/3 Fix some inconsistencies in the docsFredrik Kuivinen, Mar 9, 2006
  5. 3/3 Remove trailing dot after short descriptionFredrik Kuivinen, Mar 9, 2006
  6. Ryan AndersonMar 9, 2006

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.