diff --git a/branch.c b/branch.c index 22f4f46b96..e26301197d 100644 --- a/branch.c +++ b/branch.c @@ -840,7 +840,7 @@ void create_branches_recursively(struct repository *r, const char *name, * tedious to determine whether or not tracking was set up in the * superproject. */ - if (track) + if (tracking_name && track) setup_tracking(name, tracking_name, track, quiet); for (i = 0; i < submodule_entry_list.entry_nr; i++) { diff --git a/t/t3207-branch-submodule.sh b/t/t3207-branch-submodule.sh index 4afb2d3198..97d057959d 100755 --- a/t/t3207-branch-submodule.sh +++ b/t/t3207-branch-submodule.sh @@ -98,6 +98,23 @@ test_expect_success 'should respect submodule.recurse when creating branches' ' ) ' +test_expect_success 'should move a branch to a start point that names no ref' ' + test_when_finished "rm -rf no-submodules" && + git init no-submodules && + ( + cd no-submodules && + test_commit one && + test_commit two && + git remote add origin . && + git config submodule.propagateBranches true && + git config submodule.recurse true && + git branch branch-a HEAD~1 && + oid=$(git rev-parse HEAD) && + git branch -f branch-a "$oid" && + test_cmp_rev HEAD branch-a + ) +' + test_expect_success 'should ignore submodule.recurse when not creating branches' ' test_when_finished "reset_test" && (