Re: [PATCH v3] diff-lib.c: handle empty deleted ita files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Varun Naik <vcnaik94@xxxxxxxxx> 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.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux