diff mbox series

submodule: add newline on invalid submodule error

Message ID 20200207004833.255965-1-emilyshaffer@google.com (mailing list archive)
State New, archived
Headers show
Series submodule: add newline on invalid submodule error | expand

Commit Message

Emily Shaffer Feb. 7, 2020, 12:48 a.m. UTC
Since 'err' contains output for multiple submodules and is printed all
at once by fetch_populated_submodules(), errors for each submodule
should be newline separated for readability. The same strbuf is added to
with a newline in the other half of the conditional where this error is
detected, so make the two consistent.

Signed-off-by: Emily Shaffer <emilyshaffer@google.com>
---
 submodule.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Derrick Stolee Feb. 7, 2020, 1:55 p.m. UTC | #1
On 2/6/2020 7:48 PM, Emily Shaffer wrote:
> Since 'err' contains output for multiple submodules and is printed all
> at once by fetch_populated_submodules(), errors for each submodule
> should be newline separated for readability. The same strbuf is added to
> with a newline in the other half of the conditional where this error is
> detected, so make the two consistent.

A worthy goal, and thanks for pointing out that this matches the
"Fetching submodule %s%s\n" string in the other block.

> -					    _("Could not access submodule '%s'"),
> +					    _("Could not access submodule '%s'\n"),

My initial thought was that this `\n` should be added in front of the
string, and only if the string has existing data. However, that's not
what happens in the other block, so doing it that way would require
changing both places. This approach is also less error-prone, even if
it may result in an "extra" newline at the end of all the messages.

LGTM.

Thanks,
-Stolee
diff mbox series

Patch

diff --git a/submodule.c b/submodule.c
index 3a184b66ab..d63f4476d9 100644
--- a/submodule.c
+++ b/submodule.c
@@ -1480,7 +1480,7 @@  static int get_next_submodule(struct child_process *cp,
 			    !is_empty_dir(ce->name)) {
 				spf->result = 1;
 				strbuf_addf(err,
-					    _("Could not access submodule '%s'"),
+					    _("Could not access submodule '%s'\n"),
 					    ce->name);
 			}
 		}