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

Git fetch bug in git 2.21+ "Could not access submodule '%s'"

From
PPPaolo Pettinato (ppettina) <ppettina@cisco.com>
Date
Aug 14, 2019, 09:57 UTC
Message-ID
<951a0ac4-592f-d71c-df6a-53a806249f7b@cisco.com>

Spotted this when our Jenkins executors had git updated, and later managed to reproduce locally. The issue happens when fetching an updated ref from a remote, and that ref updates a submodule which is not checked out but whose folder is dirty.

Steps to reproduce (on *nix) with repositories on GitHub:
Scenario: git-fetch-bug repository with 2 branches, the HEADs for these 
branches point respectively to 2 different commits in a submodule.

$ mkdir git_repo $ cd git_repo

# Manually fetch "master" branch $ git init $ git remote add origin https://github.com/paolope/git-fetch-bug.git $ git fetch origin master

# Checkout $ git checkout master

# Repo now contains a folder named "sm" which is bound to contain a submodule checkout. But the submodule is not checked out yet. # Dirty that folder: $ touch sm/test

# Fetching another branch will fail $ git fetch origin branch_1

Output:
remote: Enumerating objects: 7, done.
remote: Counting objects: 100% (7/7), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 5 (delta 2), reused 5 (delta 2), pack-reused 0
Unpacking objects: 100% (5/5), done.
 From https://github.com/paolope/git-fetch-bug
  * branch            branch_1   -> FETCH_HEAD
  * [new branch]      branch_1   -> origin/branch_1
Could not access submodule 'sm' # fails, plus no newline here :P!

# Re-issuing the command succeeds $ git fetch origin branch_1

Output:
 From https://github.com/paolope/git-fetch-bug
  * branch            branch_1   -> FETCH_HEAD

I'd expect the command not to fail, or to fail consistently. This behaviour didn't happen in git 2.18.1, so the regression was introduced somewhere in between. It is possible that this is related to this issue: https://marc.info/?l=git&m=155246493613592&w=2 Regards, Paolo Pettinato **

Next: Jeff King
Message 1 of 8 in “Git fetch bug in git 2.21+ "Could not access submodule '%s'"”
  1. Paolo Pettinato (ppettina)Aug 14, 2019
  2. Jeff KingAug 14, 2019
  3. Junio C HamanoAug 14, 2019
  4. Paolo Pettinato (ppettina)Aug 14, 2019
  5. Junio C HamanoAug 14, 2019
  6. Jeff KingAug 14, 2019
  7. get_next_submodule(): format error string as an errorJeff King, Aug 14, 2019
  8. Junio C HamanoAug 14, 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.