From: Scott Johnson <scott.johnson@arilinc.com>
To: git@vger.kernel.org
Subject: push.recurseSubmodules=check doesn't consider tags
Date: Tue, 11 Jun 2019 19:04:40 -0700 [thread overview]
Message-ID: <62F6F2E3-FAED-4EE9-BDB8-D484252A845F@arilinc.com> (raw)
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 reply other threads:[~2019-06-12 2:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-12 2:04 Scott Johnson [this message]
2019-06-12 17:26 ` push.recurseSubmodules=check doesn't consider tags Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=62F6F2E3-FAED-4EE9-BDB8-D484252A845F@arilinc.com \
--to=scott.johnson@arilinc.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).