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

Problem with fsck and invalid submodule path in history

From
OBOlivier Bornet <olivier.bornet@puck.ch>
Date
Jul 29, 2019, 07:58 UTC
Message-ID
<9C668779-15AC-4099-AAFA-7FFF519D426F@puck.ch>
Hello,

I have a git repository with an error in a submodule path in the history. The submodule path is “-f”, which is not allowed. But for some reason, it’s in the history of the git, and I’m trying to find a way to manage it without having to rewrite the full history on the main gitlab (if possible)...

To reproduce this unwanted history:
    mkdir test-bad-history
    cd test-bad-history
    echo "Test git submodule problems" > README.md
    git init
    git add README.md
    git commit --message="Start test"
    git submodule add https://github.com/leachim6/hello-world.git
    git commit --message="Commit new submodule with correct path"
    # the bad part...
    git mv hello-world -- -f
    git commit --message="Move submodule to an invalid path"
    # correct it...
    git mv -- -f valid-path
    sed -i.bak 's/-f/valid-path/' .gitmodules
    git add .gitmodules
    git commit --message="Back to a valid path"
After that, even if the git is working correctly, we have a “bad” history if we check with fsck:
    $ git fsck
    Checking object directories: 100% (256/256), done.
    error in blob 19a97d3b70760c74b780c8134e33f5392292c2e6: gitmodulesPath: disallowed submodule path: -f
Is it possible to correct it? Must git handle this kind of errors?
Thanks in advance for any help.

-- Olivier Bornet Olivier.Bornet@puck.ch

Next: SZEDER Gábor
Message 1 of 8 in “Problem with fsck and invalid submodule path in history”
  1. Olivier BornetJul 29, 2019
  2. SZEDER GáborJul 29, 2019
  3. Documentation/git-fsck.txt: include fsck.* config variablesSZEDER Gábor, Jul 29, 2019
  4. Ævar Arnfjörð BjarmasonJul 29, 2019
  5. Junio C HamanoJul 29, 2019
  6. Jeff KingJul 29, 2019
  7. Junio C HamanoJul 29, 2019
  8. Olivier BornetJul 29, 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.