git@vger.kernel.org mailing list mirror (one of many)
 help / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Stefan Beller <sbeller@google.com>
Cc: jrnieder@gmail.com, git@vger.kernel.org
Subject: Re: [PATCH 3/4] unpack-trees: Fix same() for submodules
Date: Fri, 22 Dec 2017 11:57:00 -0800
Message-ID: <xmqq3742sfhv.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20171220221725.129162-4-sbeller@google.com>

Stefan Beller <sbeller@google.com> writes:

> The function same(a, b) is used to check if two entries a and b are the
> same.  As the index contains the staged files the same() function can be
> used to check if files between a given revision and the index are the same.
>
> In case of submodules, the gitlink entry is showing up as not modified
> despite potential changes inside the submodule.
>
> Fix the function to examine submodules by looking inside the submodule.
> This patch alone doesn't affect any correctness garantuees, but in

guarantees?  I somehow misread this as orangutan ;-)

> combination with the next patch this fixes the new test introduced
> earlier in this series.
>
> This may be a slight performance regression as now we have to
> inspect any submodule thouroughly.
>
> Signed-off-by: Stefan Beller <sbeller@google.com>
> ---
>  unpack-trees.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/unpack-trees.c b/unpack-trees.c
> index bf8b602901..4d839e8edb 100644
> --- a/unpack-trees.c
> +++ b/unpack-trees.c
> @@ -1427,6 +1427,8 @@ static int same(const struct cache_entry *a, const struct cache_entry *b)
>  		return 1;
>  	if ((a->ce_flags | b->ce_flags) & CE_CONFLICTED)
>  		return 0;
> +	if (S_ISGITLINK(b->ce_mode) && should_update_submodules())
> +		return !oidcmp(&a->oid, &b->oid) && !is_submodule_modified(b->name, 0);

Isn't this is working at the wrong level?

It is technically correct to say "the function is used to check if
two entries a and be are the same", but that statement misses a more
important aspect of the function.  It is asked if these two things
are the same and does not get involved in seeing if the working tree
is dirty with respect to (one of) the entries it was passed.

For example, a virtual merge in a recursive merge would not (and
should not) care if local changes exist in the working tree, and
this function does not get any hint if it is to
look at the working tree to tell such a case and the outermost merge
apart.

Somebody has to be careful not to stomp on local changes in the
outmost merge in a recursive merge, but I do not think this function
is designed to be the place to do so.  Isn't a submodule with
"potential changes" the same way?



>  	return a->ce_mode == b->ce_mode &&
>  	       !oidcmp(&a->oid, &b->oid);
>  }

  reply index

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-20 22:17 [PATCHv2 0/4] Fix --recurse-submodules for submodule worktree changes Stefan Beller
2017-12-20 22:17 ` [PATCH 3/4] unpack-trees: Fix same() for submodules Stefan Beller
2017-12-22 19:57   ` Junio C Hamano [this message]
2017-12-20 22:17 ` [PATCH 4/4] submodule: submodule_move_head omits old argument in forced case Stefan Beller
2017-12-22 20:01   ` Junio C Hamano

Reply instructions:

You may reply publically 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=xmqq3742sfhv.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=jrnieder@gmail.com \
    --cc=sbeller@google.com \
    /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

git@vger.kernel.org mailing list mirror (one of many)

Archives are clonable:
	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.org/gmane.comp.version-control.git

 note: .onion URLs require Tor: https://www.torproject.org/
       or Tor2web: https://www.tor2web.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox