git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: David Turner <David.Turner@twosigma.com>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>,
	"novalis@novalis.org" <novalis@novalis.org>
Subject: Re: [PATCH 2/3] diff --submodule=diff: do not fail on ever-initialied deleted submodules
Date: Mon, 30 Aug 2021 23:17:29 -0700	[thread overview]
Message-ID: <xmqqwno2xhmu.fsf@gitster.g> (raw)
In-Reply-To: <91f6fc69470d4291a982cb9c4b3cd6c1@exmbdft7.ad.twosigma.com> (David Turner's message of "Tue, 27 Jul 2021 17:35:10 +0000")

David Turner <David.Turner@twosigma.com> writes:

>> From: Junio C Hamano <gitster@pobox.com>
>> Sent: Monday, July 26, 2021 6:57 PM
>> To: David Turner <David.Turner@twosigma.com>
>> Cc: git@vger.kernel.org
>> Subject: Re: [PATCH 2/3] diff --submodule=diff: do not fail on 
>> ever-initialied deleted submodules
>> 
>> David Turner <dturner@twosigma.com> writes:
>> 
>> > If you have ever initialized a submodule, open_submodule will open it.
>> > If you then delete the submodule's worktree directory (but don't 
>> > remove it from .gitmodules), git diff --submodule=diff would crash 
>> > as it attempted to chdir into the now-deleted working tree directory.
>> 
>> Hmph.  So what does the failure look like?  The child process inside
>> start_command() attempts chdir() and reports CHILD_ERR_CHDIR back, and 
>> we catch it as an error by reading from notify_pipe[0] and report 
>> failure from start_command()?  Or are we talking about a more severe 
>> "crash" of an uncontrolled kind?
>
> It's the first kind.
>
>> Bypassing the execution of diff in the submodule like this patch does 
>> may avoid such a failure, but is that all we need to "fix" this issue?  
>> What does the user expect after removing a submodule that way and runs 
>> "diff" with the "-- submodule=diff" option?  Shouldn't we be giving 
>> "all lines from all files have been removed" patch?
>
> Just a note: this only matters if the submodules git dir is
> absorbed.  If not, then we no longer have anywhere to run the
> diff.  But that case does not trigger this error, because in that
> case, open_submodule fails, so we don't resolve a left commit, so
> we exit early, which is the only thing we could do.
>
> If absorbed, then we could, in theory, go into the submodule's
> absorbed git dir (.git/modules/sm2) and run the diff there.  But
> in practice, that's a bit more complicated, because `git diff`
> expects to be run from inside a working directory, not a git dir.
> So it looks in the config for core.worktree, and does
> chdir("../../../sm2"), which is the very dir that we're trying to
> avoid visiting because it's been deleted.  We could work around
> this by setting GIT_WORK_TREE (and GIT_DIR) to ".".  This
> actually seems to work, but it's a little weird to set
> GIT_WORK_TREE to something that is not a working tree just to
> avoid an unnecessary chdir.  To my mild surprise, it also seems
> to work correctly in the case of deleted nested (absorbed)
> submodules.  What do you think of this idea?
>
> (Side note: The same bit about chdir into the working tree is
> true for diff-tree even though it normally does not need anything
> from the working tree.  I say "normally", because in the case of
> nested submodules, it might need to look inside those submodules,
> which might themselves not be absorbed.  Of course, this case
> cannot obtain if the submodule in the worktree has been deleted.
> We should consider fixing the docs for git diff-tree
> --submodule=diff to specify that it only works if -p is passed.)
>
> (Sorry if the formatting on this email ends up bad -- corporate
> email is... corporate .  I'm going to CC my personal address so
> that I can use a better mailer on future replies). 

That I had to ask questions based on the proposed log message and
you needed to answer to clarify means that the next person who
encounters this commit in "git log" would likely have to ask the
same question, and worse, unlike I had you, there is nobody to whom
they ask for help understanding this commit.

Thanks.

  reply	other threads:[~2021-08-31  6:17 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-26 18:33 [PATCH 1/3] Remove unused var David Turner
2021-07-26 18:33 ` [PATCH 2/3] diff --submodule=diff: do not fail on ever-initialied deleted submodules David Turner
2021-07-26 22:57   ` Junio C Hamano
2021-07-27 17:35     ` David Turner
2021-08-31  6:17       ` Junio C Hamano [this message]
2021-08-31 13:12         ` [PATCH v4 1/3] Remove unused var David Turner
2021-08-31 13:12           ` [PATCH v4 2/3] diff --submodule=diff: do not fail on ever-initialied deleted submodules David Turner
2021-08-31 13:12           ` [PATCH v4 3/3] diff --submodule=diff: Don't print failure message twice David Turner
2021-08-31 17:16           ` [PATCH v4 1/3] Remove unused var Junio C Hamano
2021-07-26 18:33 ` [PATCH 3/3] diff --submodule=diff: Don't print failure message twice David Turner
2021-07-26 22:47   ` Junio C Hamano
2021-07-26 22:47 ` [PATCH 1/3] Remove unused var 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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=xmqqwno2xhmu.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=David.Turner@twosigma.com \
    --cc=git@vger.kernel.org \
    --cc=novalis@novalis.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).