Re: [PATCH 2/2] submodule.c: warn about missing submodule commit in recursive actions

2018-09-06 Thread Martin Ă…gren
> +   if (repo_submodule_init(, the_repository, path) < 0)
> +   warning(_("Could not get submodule repository for submodule 
> 's'"), path);

Missing "%" in format specifier, so `path` will never be used. Also,
s/C/c/ at the start of the warning.

Thanks for marking with _().

Martin


Re: [PATCH 2/2] submodule.c: warn about missing submodule commit in recursive actions

2018-09-05 Thread Jonathan Nieder
Hi,

Stefan Beller wrote:

> Subject: submodule.c: warn about missing submodule commit in recursive actions

Nit: the diff already tells me what file the change is in.  What I'd
be more interested in is the subsystem or what commands this affects.
Does this affect all --recurse-submodules commands, or just some?

Here, I think it's about common submodule code, so I guess
'submodule:' would be a fine prefix.

> By checking if a submodule commit exists before attempting the update
> we can improve the error message from the
> error(_("Submodule '%s' could not be updated."), path);
> to the new and more specific
> error(_("Submodule '%s' doesn't have commit '%s'"),
>   path, oid_to_hex(new_oid));

Maybe it's just me, but I find this formatting where I cannot
distinguish between a line that was wrapped early and the start of a
callout hard to read.  Some extra line breaks would help:

  By checking if a submodule commit exists before attempting the update
  we can improve the error message from the

  error(_("Submodule '%s' could not be updated."), path);

  to the new and more specific

  error(_("Submodule '%s' doesn't have commit '%s'"),
path, oid_to_hex(new_oid));

Beyond that, I still don't know what this change does.  Can you give
an example?  For example, what command would I run before and what bad
result would I get, and what result does this patch produce instead?

Thanks,
Jonathan


[PATCH 2/2] submodule.c: warn about missing submodule commit in recursive actions

2018-09-05 Thread Stefan Beller
By checking if a submodule commit exists before attempting the update
we can improve the error message from the
error(_("Submodule '%s' could not be updated."), path);
to the new and more specific
error(_("Submodule '%s' doesn't have commit '%s'"),
  path, oid_to_hex(new_oid));

Signed-off-by: Stefan Beller 
---
 submodule.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/submodule.c b/submodule.c
index da2ed8696f5..56104af1c7c 100644
--- a/submodule.c
+++ b/submodule.c
@@ -1605,6 +1605,7 @@ int submodule_move_head(const char *path,
struct child_process cp = CHILD_PROCESS_INIT;
const struct submodule *sub;
int *error_code_ptr, error_code;
+   struct repository subrepo;
 
if (!is_submodule_active(the_repository, path))
return 0;
@@ -1627,6 +1628,13 @@ int submodule_move_head(const char *path,
if (!sub)
BUG("could not get submodule information for '%s'", path);
 
+   if (repo_submodule_init(, the_repository, path) < 0)
+   warning(_("Could not get submodule repository for submodule 
's'"), path);
+   else if (new_oid && !lookup_commit(subrepo, new_oid)) {
+   return error(_("Submodule '%s' doesn't have commit '%s'"),
+path, oid_to_hex(new_oid));
+   }
+
if (old_head && !(flags & SUBMODULE_MOVE_HEAD_FORCE)) {
/* Check if the submodule has a dirty index. */
if (submodule_has_dirty_index(sub))
-- 
2.19.0.rc2.392.g5ba43deb5a-goog