git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 15, 2019, 19:06 UTC
Message-ID
<xmqqv9uy2qpj.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20190801161558.12838-1-vcnaik94@gmail.com>
Varun Naik <vcnaik94@gmail.com> writes:
Show 17 quoted lines
> 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.
Previous: Varun NaikNext: Varun Naik
Message 8 of 11 in “reset: unstage empty deleted ita files”
  1. reset: unstage empty deleted ita filesVarun Naik, Jul 12, 2019
  2. reset: unstage empty deleted ita filesVarun Naik, Jul 26, 2019
  3. Junio C HamanoJul 26, 2019
  4. Varun NaikJul 29, 2019
  5. Junio C HamanoJul 29, 2019
  6. diff-lib.c: handle empty deleted ita filesVarun Naik, Aug 1, 2019
  7. Varun NaikAug 15, 2019
  8. Junio C HamanoAug 15, 2019
  9. Varun NaikAug 19, 2019
  10. Junio C HamanoAug 19, 2019
  11. Varun NaikFeb 14, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.