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

Re: gitmodulesSymlink .gitmodules is a symbolic link

From
Jeff King <peff@peff.net>
Date
Nov 16, 2023, 20:27 UTC
Message-ID
<20231116202718.GD1146561@coredump.intra.peff.net>
In-Reply-To
<CAM30mqasEjEBbn1vSUwvKP6LLjAFSw3xoeLrB1zLWnH37Z2fUg@mail.gmail.com>
On Wed, Nov 15, 2023 at 05:01:10PM +0100, flobee.code wrote:
> But in general I think the exclusion of symlinks to git system files
> is a mistake. It is implemented too sweepingly in my eyes.

I agree that the fact that we reject these at such a low level makes it hard to use the tooling to rewrite the history to fix it.

But because of the security implications of out-of-tree symlinks from untrusted repositories, it's important to catch these consistently. I see your use case is for in-tree links, but detecting that makes the checks much more complex. It also has always been the case that symlinks do not behave consistently, as Git does not follow them when reading in-index versions of meta files.

Show 5 quoted lines
> And `git` itself also aborts. So I can't solve the problems this way.
> 
>     git filter-branch --tree-filter 'rm -f .gitmodules' HEAD
>     Rewrite [SomeHash] (3/185) (0 seconds passed, remaining 0 predicted) \
>         error: Invalid path '.gitmodules' Could not initialize the index

I didn't test, but you could probably get by with using "git replace" to first fix up the offending trees, and then run filter-branch (though there may be a lot of such trees, so you'd probably to script that step). I also suspect that filter-repo would handle this better:

  https://github.com/newren/git-filter-repo
but didn't try it myself.
-Peff
Previous: flobee.code
Message 2 of 2 in “gitmodulesSymlink .gitmodules is a symbolic link”
  1. flobee.codeNov 15, 2023
  2. Jeff KingNov 16, 2023

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.