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

Re: [PATCH] Make git-clean a builtin

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Oct 8, 2007, 03:57 UTC
Message-ID
<Pine.LNX.4.64.0710080450570.4174@racer.site>
In-Reply-To
<11918014664038-git-send-email-shawn.bohrer@gmail.com>
Hi,
On Sun, 7 Oct 2007, Shawn Bohrer wrote:
> +	if (ignored && ignored_only)
> +		usage(builtin_clean_usage);

Maybe a helpful message in that case, too? (It is not apparent from the usage what the user has done wrong here.)

> +	if (disabled) {
> +		die("clean.requireForce set and -n or -f not given; refusing to clean");
> +	}

Please lose the curly brackets here. They are absolutely useless, and the rest of the git source code avoids unnecessary curly brackets.

Show 6 quoted lines
> +	/* Paths (argc - i) + 8 (Possible arguments)*/
> +	argv_ls_files = xmalloc((argc - i + 8) * sizeof(const char *));
> +	argv_ls_files[0] = "ls-files";
> +	argv_ls_files[1] = "--others";
> +	argv_ls_files[2] = "--directory";
> [...]

As Linus already noted, it is probably easy, and much more efficient, to call read_directory() here. The best example how to use read_directory() is... builtin-ls-files.c.

Show 9 quoted lines
> diff --git a/git.c b/git.c
> index d7c6bca..4e39169 100644
> --- a/git.c
> +++ b/git.c
> @@ -320,6 +320,7 @@ static void handle_internal_command(int argc, const char **argv)
>  		{ "check-attr", cmd_check_attr, RUN_SETUP | NEED_WORK_TREE },
>  		{ "cherry", cmd_cherry, RUN_SETUP },
>  		{ "cherry-pick", cmd_cherry_pick, RUN_SETUP | NEED_WORK_TREE },
> +		{ "clean", cmd_clean, RUN_SETUP },
You definitely want to have NEED_WORK_TREE here, too.

Ciao, Dscho

Previous: Shawn Bohrer
Message 2 of 2 in “Make git-clean a builtin”
  1. Make git-clean a builtinShawn Bohrer, Oct 7, 2007
  2. Johannes SchindelinOct 8, 2007

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.