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

Re: [PATCH 2/2] diff-files: mark i-t-a paths as "new"

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 15, 2015, 07:05 UTC
Message-ID
<xmqqioe2viye.fsf@gitster.dls.corp.google.com>
In-Reply-To
<1425910445-27383-3-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:
Show 18 quoted lines
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  builtin/add.c | 1 +
>  diff-lib.c    | 5 +++++
>  2 files changed, 6 insertions(+)
>
> diff --git a/builtin/add.c b/builtin/add.c
> index 3390933..ee370b0 100644
> --- a/builtin/add.c
> +++ b/builtin/add.c
> @@ -63,6 +63,7 @@ static void update_callback(struct diff_queue_struct *q,
>  		switch (fix_unmerged_status(p, data)) {
>  		default:
>  			die(_("unexpected diff status %c"), p->status);
> +		case DIFF_STATUS_ADDED:
>  		case DIFF_STATUS_MODIFIED:
>  		case DIFF_STATUS_TYPE_CHANGED:
>  			if (add_file_to_index(&the_index, path, data->flags)) {

Is this related to making "diff-files" show an i-t-a as "new", or something else?

Ahh, "added" would have never appeared in diff-files output (because by definition comparing index and working tree for only paths known to the index would never produce "add"), and the point of this series is to use that status to signal that the path is marked as i-t-a.

And an i-t-a path is "not yet exist in the index, known to the system, and exists in the working tree", so catching that new case here and calling add_file_to_index() would cause such a path to be truly added to the index (this is "add -u" codepath, right?).

Makes sense.
Show 16 quoted lines
> diff --git a/diff-lib.c b/diff-lib.c
> index db0e6f8..5f1afa4 100644
> --- a/diff-lib.c
> +++ b/diff-lib.c
> @@ -212,6 +212,11 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
>  					       ce->sha1, !is_null_sha1(ce->sha1),
>  					       ce->name, 0);
>  				continue;
> +			} else if (ce->ce_flags & CE_INTENT_TO_ADD) {
> +				diff_addremove(&revs->diffopt, '+', ce->ce_mode,
> +					       EMPTY_BLOB_SHA1_BIN, 0,
> +					       ce->name, 0);
> +				continue;
>  			}
>  
>  			changed = match_stat_with_submodule(&revs->diffopt, ce, &st,
And this makes sense, of course.

The way "add -N" entries appear in "git status" has been disturbing for quite a while to me, too. Thanks for starting to look into it.

Previous: Nguyễn Thái Ngọc DuyNext: Michael J Gruber
Message 16 of 18 in “Bug fixes regarding diff and "git add -N"”
  1. 0/2 Bug fixes regarding diff and "git add -N"Nguyễn Thái Ngọc Duy, Mar 9, 2015
  2. 1/2 diff --cached: do not report i-t-a entries as "new"Nguyễn Thái Ngọc Duy, Mar 9, 2015
  3. Junio C HamanoMar 15, 2015
  4. diff-lib.c: adjust position of i-t-a entries in diffNguyễn Thái Ngọc Duy, Mar 16, 2015
  5. Michael J GruberMar 16, 2015
  6. Junio C HamanoMar 16, 2015
  7. Duy NguyenMar 17, 2015
  8. Junio C HamanoMar 17, 2015
  9. Duy NguyenMar 18, 2015
  10. Junio C HamanoMar 18, 2015
  11. Junio C HamanoMar 19, 2015
  12. Duy NguyenMar 24, 2015
  13. Junio C HamanoMar 24, 2015
  14. Junio C HamanoMar 23, 2015
  15. 2/2 diff-files: mark i-t-a paths as "new"Nguyễn Thái Ngọc Duy, Mar 9, 2015
  16. Junio C HamanoMar 15, 2015
  17. t2203,t4011: adjust to changed intent-to-add treatmentMichael J Gruber, Mar 9, 2015
  18. Junio C HamanoMar 15, 2015

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.