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

Re: [PATCH 5/5] submodule: submodule_move_head omits old argument in forced case

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Dec 19, 2017, 22:44 UTC
Message-ID
<20171219224431.GG240141@aiede.mtv.corp.google.com>
In-Reply-To
<20171219222636.216001-6-sbeller@google.com>
Hi,

I had trouble understanding what this fixes, so I'll try nitpicking a bit as a sideways way to address that.

Stefan Beller wrote:
> With the previous patch applied (fix of the same() function),

This tripped me up a bit. Usually commits assume that all previous patches have already been applied, since that allows the maintainer to apply the early part of a series on one day and the later part another day without losing too much context.

I think this intends to say something like
	Now that we allow recursing into an unchanged submodule (see
	"unpack-trees: Fix same() for submodules", 2017-12-19), it is
	possible for ...
Show 7 quoted lines
>                                                               the
> function `submodule_move_head` may be invoked with the same argument
> for the `old` and `new` state of a submodule, for example when you
> run `reset --hard --recurse-submodules` in the superproject that has no
> change in the gitlink entry, but only worktree related change in the
> submodule. The read-tree call in the submodule is not amused about
> the duplicate argument.

What is the symptom of read-tree being unamused? Is that a sign that these patches are out of order (i.e. that we should prepare to handle an unchanged submodule first, and then adjust the caller to pass in unchanged submodules)?

> It turns out that we can omit the duplicate old argument in all forced
> cases anyway, so let's do that.

What is the end-user visibile effect of such a change? E.g. what becomes possible to a user that wasn't possible before?

Among the commands you mentioned before:
  checkout -f
	I think I would expect this not to touch a submodule that
	hasn't changed, since that would be consistent with its
	behavior on files that haven't changed.
  reset --hard
	Nice!  Yes, recursing into unchanged submodules is a big part
	of the psychological comfort of being able to say "you can
	always use reset --hard <commit> to get back to a known
	state".
  read-tree -u --reset
	This is essentially the plumbing equivalent of reset --hard,
	so it makes sense for them to be consistent.  Ok.

Based on the checkout -f case, if I've understood correctly then patch 4/5 goes too far on it (but I could easily be convinced otherwise).

Show 17 quoted lines
> Signed-off-by: Stefan Beller <sbeller@google.com>
> ---
>  submodule.c               | 4 +++-
>  t/lib-submodule-update.sh | 2 +-
>  2 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/submodule.c b/submodule.c
> index fa25888783..db0f7ac51e 100644
> --- a/submodule.c
> +++ b/submodule.c
> @@ -1653,7 +1653,9 @@ int submodule_move_head(const char *path,
>  	else
>  		argv_array_push(&cp.args, "-m");
>  
> -	argv_array_push(&cp.args, old ? old : EMPTY_TREE_SHA1_HEX);
> +	if (!(flags & SUBMODULE_MOVE_HEAD_FORCE))
> +		argv_array_push(&cp.args, old ? old : EMPTY_TREE_SHA1_HEX);
Interesting.  What is the effect when old != new?

Thanks, Jonathan

Previous: Stefan BellerNext: Stefan Beller
Message 11 of 38 in “Fix --recurse-submodules for submodule worktree changes”
  1. 0/5 Fix --recurse-submodules for submodule worktree changesStefan Beller, Dec 19, 2017
  2. 1/5 t/lib-submodule-update.sh: clarify testStefan Beller, Dec 19, 2017
  3. 3/5 t/lib-submodule-update.sh: add new test for submodule internal changeStefan Beller, Dec 19, 2017
  4. Jonathan NiederDec 19, 2017
  5. Stefan BellerDec 19, 2017
  6. 2/5 t/lib-submodule-update.sh: Fix test ignoring ignored files in submodulesStefan Beller, Dec 19, 2017
  7. Junio C HamanoDec 22, 2017
  8. Stefan BellerDec 27, 2017
  9. 4/5 unpack-trees: Fix same() for submodulesStefan Beller, Dec 19, 2017
  10. 5/5 submodule: submodule_move_head omits old argument in forced caseStefan Beller, Dec 19, 2017
  11. Jonathan NiederDec 19, 2017
  12. Stefan BellerDec 19, 2017
  13. Jonathan NiederDec 19, 2017
  14. Jonathan NiederDec 20, 2017
  15. Stefan BellerDec 20, 2017
  16. Stefan BellerDec 20, 2017
  17. 0/5 Fix --recurse-submodules for submodule worktree changesStefan Beller, Dec 27, 2017
  18. 1/5 t/helper/test-lazy-name-hash: fix compilationStefan Beller, Dec 27, 2017
  19. 2/5 t/lib-submodule-update.sh: clarify testStefan Beller, Dec 27, 2017
  20. 3/5 t/lib-submodule-update.sh: Fix test ignoring ignored files in submodulesStefan Beller, Dec 27, 2017
  21. 5/5 submodule: submodule_move_head omits old argument in forced caseStefan Beller, Dec 27, 2017
  22. 4/5 unpack-trees: oneway_merge to update submodulesStefan Beller, Dec 27, 2017
  23. Junio C HamanoJan 2, 2018
  24. Stefan BellerJan 2, 2018
  25. 0/5 Fix --recurse-submodules for submodule worktree changesStefan Beller, Jan 3, 2018
  26. 1/5 t/helper/test-lazy-name-hash: fix compilationStefan Beller, Jan 3, 2018
  27. 2/5 t/lib-submodule-update.sh: clarify testStefan Beller, Jan 3, 2018
  28. 3/5 t/lib-submodule-update.sh: Fix test ignoring ignored files in submodulesStefan Beller, Jan 3, 2018
  29. 5/5 submodule: submodule_move_head omits old argument in forced caseStefan Beller, Jan 3, 2018
  30. 4/5 unpack-trees: oneway_merge to update submodulesStefan Beller, Jan 3, 2018
  31. Junio C HamanoJan 3, 2018
  32. Stefan BellerJan 3, 2018
  33. 0/4 Fix --recurse-submodules for submodule worktree changesStefan Beller, Jan 5, 2018
  34. 1/4 t/lib-submodule-update.sh: clarify testStefan Beller, Jan 5, 2018
  35. 2/4 t/lib-submodule-update.sh: Fix test ignoring ignored files in submodulesStefan Beller, Jan 5, 2018
  36. 3/4 unpack-trees: oneway_merge to update submodulesStefan Beller, Jan 5, 2018
  37. 4/4 submodule: submodule_move_head omits old argument in forced caseStefan Beller, Jan 5, 2018
  38. Junio C HamanoJan 9, 2018

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.