Re: [PATCH 1/1] diff-lib: use worktree mode in diffs from i-t-a entries
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 9, 2020, 18:09 UTC
- Message-ID
- <xmqqh7tbelnd.fsf@gitster.c.googlers.com>
- In-Reply-To
- <20200808075323.36041-1-ray@ameretat.dev>
"Raymond E. Pasco" <ray@ameretat.dev> writes:
Show 25 quoted lines
> When creating "new file" diffs against i-t-a index entries, diff-lib
> erroneously used the mode of the cache entry rather than the mode of the
> file in the worktree. This changes run_diff_files() to correctly use the
> mode of the worktree file in this case.
>
> Signed-off-by: Raymond E. Pasco <ray@ameretat.dev>
> ---
> This is a distinct bugfix from the other changes, so I've sent it as a
> separate patch also based on v2.28.0.
>
> diff-lib.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/diff-lib.c b/diff-lib.c
> index 25fd2dee19..50521e2093 100644
> --- a/diff-lib.c
> +++ b/diff-lib.c
> @@ -219,7 +219,8 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
> continue;
> } else if (revs->diffopt.ita_invisible_in_index &&
> ce_intent_to_add(ce)) {
> - diff_addremove(&revs->diffopt, '+', ce->ce_mode,
> + newmode = ce_mode_from_stat(ce, st.st_mode);
> + diff_addremove(&revs->diffopt, '+', newmode,
> &null_oid, 0, ce->name, 0);;-)
The ita-invisible-in-index option means that Git must ignore anything in the index about the entry, other than just the fact that the path is subject to comparison, so use of ce->ce_mode here is wrong by definition. Makes sense.
> continue; > }