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

Re: [PATCH] git submodule: add submodules with git add -f <path>

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Jul 6, 2010, 22:33 UTC
Message-ID
<AANLkTinn_Vz6I619Do4AOCVMUgfpyy84L1wh3lkuCP7R@mail.gmail.com>
In-Reply-To
<4C33A552.5060008@web.de>
On Tue, Jul 6, 2010 at 21:51, Jens Lehmann <Jens.Lehmann@web.de> wrote:
Show 25 quoted lines
> [...]
> But while I think adding the --force option to the "git add .gitmodules"
> makes perfect sense (as the submodule can't be successfully added until
> it is recorded in this file and there is really no point in ignoring
> .gitmodules when you decide to use submodules), I'm not so sure about
> what to do when the submodule path itself is ignored.
>
> I see two possible behaviors here:
>
> a) We just ignore .gitignore and add the submodule anyways (which is
>   what this patch does)
>
> b) We do the same a "git add <ignored file>" does: Print an error
>   message, maybe even tell the user to use a - still to be added -
>   "--force" (or "-f") option and exit. But without checking out the
>   submodule first nor adding or changing .gitmodules.
>
> IMHO b) is more consistent with the current behavior of "git add". And
> when you later decide that the submodules files should live in the
> superproject and you drop the submodule, the then probably still
> present entry in .gitignore might really shoot you in the foot when
> you add new files there and they won't show up because they are still
> ignored.
>
> What do others think?

Option C would be treating it like git init as the current patch does. But init isn't strictly comparable to git add or git submodule add since it's not adding something to *another* repository.

I really don't care, B or C works for me, although C is of course easier since I don't have to write another patch :)

Option b) is more consistent with git-add, but I can't find a way to ask any git tool whether a non-existing path is ignored without actually adding something. git add --dry-run will die on "pathspec 'foo' did not match any files" unless the file exists already.

Previous: Jens LehmannNext: Jens Lehmann
Message 5 of 10 in “git submodule: add submodules with git add -f <path>”
  1. git submodule: add submodules with git add -f <path>Ævar Arnfjörð Bjarmason, Jul 2, 2010
  2. git submodule: add submodules with git add -f <path>Ævar Arnfjörð Bjarmason, Jul 5, 2010
  3. Junio C HamanoJul 6, 2010
  4. Jens LehmannJul 6, 2010
  5. Ævar Arnfjörð BjarmasonJul 6, 2010
  6. git add: Add the "--ignore-missing" option for the dry runJens Lehmann, Jul 9, 2010
  7. Junio C HamanoJul 12, 2010
  8. git submodule add: Require the new --force option to add ignored pathsJens Lehmann, Jul 17, 2010
  9. git submodule add: Remove old docs about implicit -fÆvar Arnfjörð Bjarmason, Jul 17, 2010
  10. Jens LehmannJul 17, 2010

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.