From: Junio C Hamano <gitster@pobox.com>
To: David Turner <dturner@twosigma.com>
Cc: git@vger.kernel.org, novalis@novalis.org
Subject: Re: [PATCH v2 2/3] diff --submodule=diff: do not fail on ever-initialied deleted submodules
Date: Mon, 30 Aug 2021 23:19:11 -0700 [thread overview]
Message-ID: <xmqqsfyqxhk0.fsf@gitster.g> (raw)
In-Reply-To: <20210802170004.4103535-2-dturner@twosigma.com> (David Turner's message of "Mon, 2 Aug 2021 13:00:03 -0400")
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 error out
> as it attempted to chdir into the now-deleted working tree directory.
>
> Instead, we chdir into the submodule's git directory and run the diff
> from there.
>
> Signed-off-by: David Turner <dturner@twosigma.com>
> ---
> submodule.c | 10 ++
> t/t4060-diff-submodule-option-diff-format.sh | 157 +++++++++++++++++++++++++--
> 2 files changed, 160 insertions(+), 7 deletions(-)
>
> diff --git a/submodule.c b/submodule.c
> index 0b1d9c1dde..d13d103975 100644
> --- a/submodule.c
> +++ b/submodule.c
> @@ -710,6 +710,16 @@ void show_submodule_inline_diff(struct diff_options *o, const char *path,
> strvec_push(&cp.args, oid_to_hex(new_oid));
>
> prepare_submodule_repo_env(&cp.env_array);
> +
> + if (!is_directory(path)) {
> + // fall back to absorbed git dir, if any
I'll locally amend this comment style. If there is no other
comments, that would be sufficient.
> + if (!sub)
> + goto done;
> + cp.dir = sub->gitdir;
> + strvec_push(&cp.env_array, GIT_DIR_ENVIRONMENT "=.");
> + strvec_push(&cp.env_array, GIT_WORK_TREE_ENVIRONMENT "=.");
> + }
> +
> if (start_command(&cp))
> diff_emit_submodule_error(o, "(diff failed)\n");
next prev parent reply other threads:[~2021-08-31 6:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-02 17:00 [PATCH v2 1/3] Remove unused var David Turner
2021-08-02 17:00 ` [PATCH v2 2/3] diff --submodule=diff: do not fail on ever-initialied deleted submodules David Turner
2021-08-31 6:19 ` Junio C Hamano [this message]
2021-08-02 17:00 ` [PATCH v2 3/3] diff --submodule=diff: Don't print failure message twice David Turner
2021-08-31 6:19 ` 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=xmqqsfyqxhk0.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=dturner@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.
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).