git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Beller <sbeller@google.com>
To: Andrew J <andj2223@gmail.com>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: Strangeness with git-add and nested repositories
Date: Wed, 27 Apr 2016 09:08:22 -0700	[thread overview]
Message-ID: <CAGZ79kZhATfP1FpXnhivCa_Az-3KADSCReOo68E2Q3s29x5HNw@mail.gmail.com> (raw)
In-Reply-To: <CAH6n4TdG9LQOPaaw_H6vuCgia0-4JXhPsSiAJPa5GtjfduQoSw@mail.gmail.com>

On Wed, Apr 27, 2016 at 1:31 AM, Andrew J <andj2223@gmail.com> wrote:
> I've noticed some strangeness with git-add and nested repos.
>
> This tar.gz has a reproduction script, parent repo, and nested repo
> that exhibits the issue:
> https://drive.google.com/uc?export=download&id=0Bwjufq6oAZMfcGVxZ2dlMElEVlE
>
> If you extract the archive and do the following (on linux please, I
> haven't even tried this on Windows):
> cd git-add-bug
> ./bad-git-add.sh
> (Examine the script before running, please)
>
> It will echo what I'm encountering to the screen, so it should be
> straightforward to follow, but I will summarize here:
> If I run a git-add command where one or more of the files live in
> nested repositories, like so (command is shortened here, includes more
> files in the script):
> git add -v -f --
> src/chromium/src/third_party/libFuzzer/src/FuzzerInterface.h testfile
> As confirmed by git-status, this results in testfile being added, but
> FuzzerInterface.h not being added.
> FuzzerInterface.h is inside of a nested repository
> (src/chromium/src/third_party/libFuzzer/src/), while testfile is in
> the current main repository.
>
> On the other hand, the following command:
> git add -v -f -- src/chromium/src/third_party/libFuzzer/src/FuzzerInterface.h
> Results in FuzzerInterface.h being added, as confirmed by git-status.
> Excluding testfile from the git-add command seems to do the trick.
>
> My expectation:
> Both testfile and FuzzerInterface.h should be added if they are
> specified in the git-add command, regardless of whether they are
> specified along with another file that doesn't happen to live in a
> nested repository ("testfile" in this example).

I would call it a bug. [This use case is interesting for working with submodules
(though your nested repositories do not seem to be submodules), so worth
looking at for me.]

>
> If someone could help me understand what's going on here, I'd appreciate it.

I think (pure speculation), that it the error is in the context
(repository) switching logic.
What happens if you alter the order, i.e. give testfile first and then
the files in the nested
repos?

    git add -- file path/to/subdir/file

should do internally IMHO:

    git add file
    git -C path-to-subdir add file

Thanks,
Stefan

>
> Thanks,
>
> Andrew
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2016-04-27 16:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-27  8:31 Strangeness with git-add and nested repositories Andrew J
2016-04-27 16:08 ` Stefan Beller [this message]
2016-04-28  6:10   ` Andrew J
2016-04-28 16:35     ` Stefan Beller
2016-04-28 16:39   ` Junio C Hamano
2016-04-28 16:48     ` Junio C Hamano
2016-04-29  2:11       ` Andrew J
2016-04-28 16:54     ` Stefan Beller
2016-04-29  2:51     ` Junio C Hamano
2016-04-29  2:54       ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAGZ79kZhATfP1FpXnhivCa_Az-3KADSCReOo68E2Q3s29x5HNw@mail.gmail.com \
    --to=sbeller@google.com \
    --cc=andj2223@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).