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

push.recurseSubmodules=check doesn't consider tags

From
SJScott Johnson <scott.johnson@arilinc.com>
Date
Jun 12, 2019, 02:04 UTC
Message-ID
<62F6F2E3-FAED-4EE9-BDB8-D484252A845F@arilinc.com>
I occasionally rebase my submodules. I realize the danger (historical submodule pointers could point to commits that get garbage-collected away) so I always create and push a tag before the rebase, to make sure the old commits will never get purged. I believe this is safe, based on some experiments I’ve run.
The issue: I set the config var push.recurseSubmodules=check, and it seems to insist on having a branch and not merely a tag. When I push the parent repo’s commits, I get failures: "The following submodule paths contain changes that can not be found on any remote”. This is overly pessimistic: the commits are there on the remote, and the tag demonstrates that.
Expected behavior: when the submodule remote has a branch or a tag with the submodule pointer as ancestor, the push.recurseSubmodules=check should succeed.
Actual behavior: the push.recurseSubmodules=check fails when only a tag, and not any branch, contains the specific commit hash.
I’m using Git 2.18.0, but I’ve checked newer Release Notes and didn’t see anything.

Below is a Makefile that demonstrates the unexpected failure. The “pre-rebase” tag should be sufficient to allow the check to succeed. Run this in an empty directory. ---- .PHONY: all clean

# Make sure no config settings, either /etc/gitconfig or ~/.gitconfig, # affect this experiment. We will create our own ./.gitconfig. GIT := GIT_CONFIG_NOSYSTEM=1 HOME=$(PWD) XDG_CONFIG_HOME= git

all:
        # Configure globally (into ./.gitconfig)
        $(GIT) config --global user.email "you@example.com"
        $(GIT) config --global user.name "Your Name"
        $(GIT) config --global push.recurseSubmodules check
        # Create upstream repos
        mkdir sub.git && cd sub.git && $(GIT) init --bare
        mkdir repo.git && cd repo.git && $(GIT) init --bare
        # Create local repos
        $(GIT) clone repo.git repo
        $(GIT) clone sub.git sub
        # Populate submodule
        cd sub && echo "foo" > foo && $(GIT) add foo && $(GIT) commit -m 'rev 1 of foo' && $(GIT) push
        # Add submodule to parent repo
        cd repo && $(GIT) submodule add ../sub.git && $(GIT) commit -m 'Add submodule' && $(GIT) push
        # Track a new branch in the submodule
        cd repo/sub && $(GIT) checkout -b aril && $(GIT) push -u origin aril
        # Add commits to sub repo
        cd repo/sub && echo "bar" > bar && $(GIT) add bar && $(GIT) commit -m 'Add bar' && $(GIT) push
        cd repo/sub && echo "foo2" >> foo && $(GIT) commit -am 'Add more to foo' && $(GIT) push
        # Update parent with new submodule commits. Note: no push
        cd repo && $(GIT) add sub && $(GIT) commit -m 'Update sub'
        # Sub's master branch diverges
        cd sub && echo "three" > three && $(GIT) add three && $(GIT) commit -m 'Add three' && $(GIT) push
        # Rebase submodule: this tag is enough to keep the old commits from being garbage collected
        cd repo/sub && $(GIT) tag pre-rebase && $(GIT) push --tags origin
        cd repo/sub && $(GIT) checkout master && $(GIT) pull --ff-only
        cd repo/sub && $(GIT) checkout aril
        cd repo/sub && $(GIT) rebase master && $(GIT) push --force-with-lease
        # Update parent repo with newly rebased sub: this will FAIL due to push.recurseSubmodules=check unable to find HEAD^'s submodule pointer in any pushed branch in repo/sub
        cd repo && $(GIT) add sub && $(GIT) commit -m 'Add rebased submodule' && $(GIT) push
clean:
        rm -rf repo repo2 repo.git sub sub.git .gitconfig
Next: Junio C Hamano
Message 1 of 2 in “push.recurseSubmodules=check doesn't consider tags”
  1. Scott JohnsonJun 12, 2019
  2. Junio C HamanoJun 12, 2019

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.