Skip to content

Fix --recurse-submodules for submodule worktree changes

Stefan Beller git 5 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest4 patches 1 replyIn review
  2. v30 of 5 patches 2 repliesSuperseded
  3. v2 posting 2/25 patches 2 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v2 posting 1/24 patches2 repliesSuperseded
v15 patches10 repliesSuperseded

Changes in v4 from the cover letter

* dropped the patch "t/helper/test-lazy-name-hash: fix compilation" (that snuck into v3 by accident, it is already present at remotes/origin/jh/memihash-opt, but I am carrying it locally in most branches currently.)
* Junio pointed out the micro-optimisation below, both in terms of readability as well as performance

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4t/lib-submodule-update.sh: clarify testt/lib-submodule-update.sh+2 -20 replies
2/4t/lib-submodule-update.sh: Fix test ignoring ignored files in submodulest/lib-submodule-update.sh+1 -00 replies
3/4unpack-trees: oneway_merge to update submodulesunpack-trees.c+3 -00 replies
4/4submodule: submodule_move_head omits old argument in forced casesubmodule.c t/lib-submodule-update.sh+17 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v4 yet.

Read the v4 thread

Cover letter [PATCHv4 0/4] Fix --recurse-submodules for submodule worktree changes

v4:
* dropped the patch "t/helper/test-lazy-name-hash: fix compilation" (that snuck into v3 by accident, it is already present at remotes/origin/jh/memihash-opt, but I am carrying it locally in most branches currently.)
* Junio pointed out the micro-optimisation below, both in terms of readability as well as performance

unpack-trees.c +2 -2
index 7657d6ecdd..96c3327f19 100644
@@ -2139,8 +2139,8 @@ int oneway_merge(const struct cache_entry * const *src,
 			    ie_match_stat(o->src_index, old, &st, CE_MATCH_IGNORE_VALID|CE_MATCH_IGNORE_SKIP_WORKTREE))
 				update |= CE_UPDATE;
 		}
-		if (S_ISGITLINK(old->ce_mode) && should_update_submodules() &&
-		    o->update && !verify_uptodate(old, o))
+		if (o->update && S_ISGITLINK(old->ce_mode) &&
+		    should_update_submodules() && !verify_uptodate(old, o))
 			update |= CE_UPDATE;
 		add_entry(o, old, update, 0);
 		return 0;

v3:
Thanks Junio for review of this series!
The only change in this version of the series is

unpack-trees.c +1 -1
@@ -2140,7 +2140,7 @@ int oneway_merge(const struct cache_entry * const *src,
                                update |= CE_UPDATE;
                }
                if (S_ISGITLINK(old->ce_mode) && should_update_submodules() &&
-                   !verify_uptodate(old, o))
+                   o->update && !verify_uptodate(old, o))
                        update |= CE_UPDATE;
                add_entry(o, old, update, 0);
 

v2:
I dropped the patch to same() as I realized we only need to fix the oneway_merge function, the others (two, three way merge) are fine as they have the checks already in place.

The test added in the last patch got slightly larger as now we also test for newly staged files to be blown away in the submodule.

v1:

The fix is in the last patch, the first patches are just massaging the code base to make the fix easy.

The second patch fixes a bug in the test, which was ineffective at testing. The third patch shows the problem this series addresses,
the fourth patch is a little refactoring, which I want to keep separate as I would expect it to be a performance regression[1].
The first patch is unrelated, but improves the readability of submodule test cases, which we'd want to improve further.

Thanks,
Stefan

Stefan Beller (4):
t/lib-submodule-update.sh: clarify test t/lib-submodule-update.sh: Fix test ignoring ignored files in
submodules
unpack-trees: oneway_merge to update submodules
submodule: submodule_move_head omits old argument in forced case

 submodule.c               |  4 +++-
 t/lib-submodule-update.sh | 19 +++++++++++++++++--
 unpack-trees.c            |  3 +++
 3 files changed, 23 insertions(+), 3 deletions(-)
Signature · 1 line
2.16.0.rc0.223.g4a4ac83678-goog