git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Varun Naik <vcnaik94@gmail.com>
Cc: git@vger.kernel.org, pclouds@gmail.com
Subject: Re: [PATCH v3] diff-lib.c: handle empty deleted ita files
Date: Thu, 15 Aug 2019 12:06:48 -0700	[thread overview]
Message-ID: <xmqqv9uy2qpj.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <20190801161558.12838-1-vcnaik94@gmail.com> (Varun Naik's message of "Thu, 1 Aug 2019 09:15:58 -0700")

Varun Naik <vcnaik94@gmail.com> writes:

> diff --git a/diff-lib.c b/diff-lib.c
> index 61812f48c2..29dba467d5 100644
> --- a/diff-lib.c
> +++ b/diff-lib.c
> @@ -433,8 +433,11 @@ static void do_oneway_diff(struct unpack_trees_options *o,
>  
>  	/*
>  	 * Something removed from the tree?
> +	 * Consider a file deleted from the index and added as ita to be "deleted",
> +	 * even though it should arguably be "modified", because we want empty
> +	 * deleted ita files to appear in the diff.
>  	 */
> -	if (!idx) {
> +	if (!idx || (cached && ce_intent_to_add(idx))) {
>  		diff_index_show_file(revs, "-", tree, &tree->oid, 1,
>  				     tree->ce_mode, 0);
>  		return;

There is already half of the same logic near the beginning of this
function, no?

	/*
	 * i-t-a entries do not actually exist in the index (if we're
	 * looking at its content)
	 */
	if (o->index_only &&
	    revs->diffopt.ita_invisible_in_index &&
	    idx && ce_intent_to_add(idx)) {
		idx = NULL;
		if (!tree)
			return;	/* nothing to diff.. */
	}

IOW, when ita-invisible-in-index flag is set, idx is made NULL and
all the rest of the function behaves as if there is no such entry in
the index (e.g. relative to HEAD it looks as if the entry is removed
in the index).

So for example, when ita-invisible-in-index is not set, this piece,
just above the part you touched, kicks in:

	/*
	 * Something added to the tree?
	 */
	if (!tree) {
		show_new_file(revs, idx, cached, match_missing);
		return;
	}

and says "no such entry in the tree, but you have an I-T-A entry
there in the index".

It is unclear why we can unconditionally declare "I-T-A entry does
not exist, the entry was in the tree but not in the index" in the
code you touched, without consulting ita-invisible-in-index flag.
It feels awfully inconsistent to me.

Of course, consistency could go the other way around, and the right
fix to achieve consistency might turn out to be to drop the check
for ita-invisible-in-index flag (and perhaps the flag itself) from
the early part of this function.  I dunno.

Thanks.

  parent reply	other threads:[~2019-08-15 19:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-12 15:02 [PATCH] reset: unstage " Varun Naik
2019-07-26  4:48 ` [PATCH v2] " Varun Naik
2019-07-26 18:19   ` Junio C Hamano
2019-07-29  6:52     ` Varun Naik
2019-07-29 16:07       ` Junio C Hamano
2019-08-01 16:15 ` [PATCH v3] diff-lib.c: handle " Varun Naik
2019-08-15 16:26   ` Varun Naik
2019-08-15 19:06   ` Junio C Hamano [this message]
2019-08-19 15:42     ` Varun Naik
2019-08-19 20:15       ` Junio C Hamano
2020-02-14 17:12         ` Varun Naik

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=xmqqv9uy2qpj.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=pclouds@gmail.com \
    --cc=vcnaik94@gmail.com \
    --subject='Re: [PATCH v3] diff-lib.c: handle empty deleted ita files' \
    /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 list mirror (unofficial, one of many)

This inbox may be cloned and mirrored by anyone:

	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

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 git git/ https://public-inbox.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.version-control.git
	nntp://ie5yzdi7fg72h7s4sdcztq5evakq23rdt33mfyfcddc5u3ndnw24ogqd.onion/inbox.comp.version-control.git
	nntp://4uok3hntl7oi7b4uf4rtfwefqeexfzil2w6kgk2jn5z2f764irre7byd.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

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

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