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

Re: [PATCH v2 1/2] rm: better error message on failure for multiple files

From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Date
Jun 10, 2013, 14:38 UTC
Message-ID
<vpqtxl6ghf5.fsf@anie.imag.fr>
In-Reply-To
<1370874127-4326-1-git-send-email-Mathieu.Lienard--Mayor@ensimag.imag.fr>
Mathieu Lienard--Mayor <Mathieu.Lienard--Mayor@ensimag.imag.fr> writes:
Show 19 quoted lines
> When 'git rm' fails, it now displays a single message
> with the list of files involved, instead of displaying
> a list of messages with one file each.
>
> As an example, the old message:
> 	error: 'foo.txt' has changes staged in the index
> 	(use --cached to keep the file, or -f to force removal)
> 	error: 'bar.txt' has changes staged in the index
> 	(use --cached to keep the file, or -f to force removal)
>
> would now be displayed as:
> 	error: the following files have changes staged in the index:
> 	    foo.txt
> 	    bar.txt
> 	(use --cached to keep the file, or -f to force removal)
>
> Signed-off-by: Mathieu Lienard--Mayor <Mathieu.Lienard--Mayor@ensimag.imag.fr>
> Signed-off-by: Jorge Juan Garcia Garcia <Jorge-Juan.Garcia-Garcia@ensimag.imag.fr>
> Signed-off-by: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>list
There's a "list" after my email, probably a typo.
> +/*
> + * PRECONDITION: files_list is a non-empty string_list
> + */

Avoid repeating in comments what the code already says. "file_list is non-empty" is sufficient, we already know it's a string_list.

Show 12 quoted lines
> +	if (files_staged.nr)
> +		errs = print_error_files(&files_staged,
> +					 _("the following files have staged "
> +					   "content different from both the"
> +					   "\nfile and the HEAD:"),
> +					 _("\n(use -f to force removal)"));
> +	if (files_cached.nr)
> +		errs = print_error_files(&files_cached,
> +					 _("the following files have changes "
> +					   "staged in the index:"),
> +					 _("\n(use --cached to keep the file, "
> +					   "or -f to force removal)"));

What happens if both conditions are true? It seems the second will override the first. I think it'd be OK because what matters is that errs is set by someone, no matter who, and the error message is displayed on screen, not contained in the variable, but this looks weird.

I'd find it more readable with "errs |= print_error_files(...)".

And actually, you may want to move the if (....nr) inside print_error_files (wich could then be called print_error_files_maybe).

At least, there should be a test where two conditions are true.
Show 7 quoted lines
> +	if (files_submodule.nr)
> +		errs = print_error_files(&files_submodule,
> +					 _("the following submodules (or one "
> +					   "of its nested submodule) use a "
> +					   ".git directory:"),
> +					 _("\n(use 'rm -rf' if you really "
> +					   "want to remove i including all "

i -> it ?

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Previous: Mathieu Lienard--MayorNext: Mathieu Liénard--Mayor
Message 2 of 4 in “rm: introduce advice.rmHints to shorten messages”
  1. 2/2 rm: introduce advice.rmHints to shorten messagesMathieu Lienard--Mayor, Jun 10, 2013
  2. Matthieu MoyJun 10, 2013
  3. Mathieu Liénard--MayorJun 10, 2013
  4. Matthieu MoyJun 10, 2013

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.