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

Re: Strangeness with git-add and nested repositories

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 28, 2016, 16:48 UTC
Message-ID
<xmqqtwil65nx.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<xmqq1t5p7kmp.fsf@gitster.mtv.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
>  * "git add -- path/to/subdir/file", when any of path/, path/to/,
>    path/to/subdir/ is a Git repository that is different from the
>    current Git repository, must fail.

If any of the leading directories in that long path is actually a git repository that is different from the current one, it shouldn't have added it. IOW, adding the path is a bug.

"git add A/B/C" usually enforces this rule by
 - check A; if A is a separate repository (A/.git exists, etc.),
   do not add this path;
   - check A/B; if A/B is a separate repository, ignore;
     - check A/B/C; if A/B/C is a separate repository, ignore.
       otherwise add it.

When given multiple paths, e.g. "git add A/B/C A/D", it tries to "optimize" things by first finding common leading directory (in this case "A/") and doing something slightly different, and I think the bug Andrew saw lies in that codepath. It is likely that the code is forgetting to make sure that there is no top of enclosed working tree in the common leading directory part of the path.

Previous: Junio C HamanoNext: Andrew J
Message 6 of 10 in “Strangeness with git-add and nested repositories”
  1. Andrew JApr 27, 2016
  2. Stefan BellerApr 27, 2016
  3. Andrew JApr 28, 2016
  4. Stefan BellerApr 28, 2016
  5. Junio C HamanoApr 28, 2016
  6. Junio C HamanoApr 28, 2016
  7. Andrew JApr 29, 2016
  8. Stefan BellerApr 28, 2016
  9. Junio C HamanoApr 29, 2016
  10. Junio C HamanoApr 29, 2016

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.