git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Mark Mentovai <mark@chromium.org>
Cc: Git Development <git@vger.kernel.org>,
	 Chandra Pratap <chandrapratap3519@gmail.com>,
	 Johannes Schindelin <johannes.schindelin@gmx.de>,
	 Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>
Subject: Re: [PATCH] apply: set file mode when --reverse creates a deleted file
Date: Fri, 23 May 2025 07:49:06 -0700	[thread overview]
Message-ID: <xmqq1psf1ixp.fsf@gitster.g> (raw)
In-Reply-To: <76ce493d-d5bd-fc63-8942-76d0b3cebbf9@chromium.org> (Mark Mentovai's message of "Thu, 22 May 2025 19:48:05 -0400 (EDT)")

Mark Mentovai <mark@chromium.org> writes:

> Junio C Hamano wrote:
>> Mark Mentovai <mark@chromium.org> writes:
>
>>> +     git checkout -- data.txt &&
>>
>> This should be a no-op, right?  What are we testing here?
>
> This syncs the executable bit to the working tree.

Ah, OK, you are simulating a filesystem that is unaware of
executable bit, so the bit on the file is ignored as long as the
file is registered in the index, and the executable bit in the index
is used instead.  There is no need to sync, and it would truely be a
no-op on a filesystem without executable hit, but when emulating
with forced core.filemode on a filesystem with executable bit, doing
so may make test writer feel better for whatever reason, since they
can look at the "ls -l" output insteadof "ls-files -s" output to see
if it is executable.

> I found it useful when developing the test, but it's probably not
> strictly necessary as the test is intentionally independent of the
> executable bit in the local filesystem. I can drop this if you think
> it's unnecessary.

Yeah, I understand the intention.  It is more like debugging printf
left over from development of the test.  It is misleading in the
final product, though---makes it look as if the executable bit on
the filesystem must match that of the index entry when running with
core.filemode=off on executable-capable filesystems (to be honest, I
am not sure how burdensome it is to the code base to support this
mode of operation, where core.filemode lies to the system---but it
is handy so let's keep the promise, "filesystem executable bits do
not matter when core.filemode is off, even if you are on a
filesystem that does store execuable bits", which the current code
makes).

> The file that I deleted at the end of the previous (apply "forward")
> test was not executable. It's important that this (apply --reverse)
> test begin by reversing a delete of an executable file.

Yes, if we are trying to see how "removal of an executable" when
applied in reverse turns into "addition of an executable", we need a
sample patch that removes an executable.

But you can certainly flip the order in the first test to commit an
unexecutable, turn it to executable, and then remove ;-)

In any case, for a better coverage, you'd probably want to do both,
i.e. reverse apply a patch that removes an executable, another patch
that removes a non-executable, yet another patch that adds an
executable, and the fourth patch that adds a non-executable.

And the two tests that applies additions in reverse would probably
need three states to start from (i.e. the file does not exist, the
file does exist but with a wrong mode, the file exists with the
right mode).

> I wanted
> to give better coverage to git-apply setting the executable bit when
> it creates a file, whether it's in the forward direction or reversing
> a deletion, because that's the harder case (and the one which wasn't
> working correctly, and which prompted this patch).

Understood.

> On the balance, I chose to keep the tests more isolated,
> but I'm happy to revise if that's what you prefer.

I would prefer more smaller tests than fewer larger tests, so that a
breakage can be identified more easily.  &&- chaining 20 related
tests that checks 20 different conditions is rather cumbersome--you
need to find which step failed first.

Thanks.

  reply	other threads:[~2025-05-23 14:49 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-22 22:02 [PATCH] apply: set file mode when --reverse creates a deleted file Mark Mentovai
2025-05-22 22:24 ` Kristoffer Haugsbakk
2025-05-22 23:15   ` Junio C Hamano
2025-05-22 22:58 ` Junio C Hamano
2025-05-22 23:48   ` Mark Mentovai
2025-05-23 14:49     ` Junio C Hamano [this message]
2025-05-23 17:21 ` [PATCH v2 0/2] " Mark Mentovai
2025-05-23 17:21   ` [PATCH v2 1/2] t4129: test that git apply warns for unexpected mode changes Mark Mentovai
2025-05-23 23:32     ` Junio C Hamano
2025-05-24  3:10       ` Mark Mentovai
2025-05-23 17:21   ` [PATCH v2 2/2] apply: set file mode when --reverse creates a deleted file Mark Mentovai
2025-05-23 23:44     ` Junio C Hamano
2025-05-24  3:19       ` Mark Mentovai
2025-05-24  3:40   ` [PATCH v3 0/2] " Mark Mentovai
2025-05-24  3:40     ` [PATCH v3 1/2] t4129: test that git apply warns for unexpected mode changes Mark Mentovai
2025-05-24  3:40     ` [PATCH v3 2/2] apply: set file mode when --reverse creates a deleted file Mark Mentovai
2025-05-27 13:56     ` [PATCH v3 0/2] " Junio C Hamano

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq1psf1ixp.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=chandrapratap3519@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=johannes.schindelin@gmx.de \
    --cc=kristofferhaugsbakk@fastmail.com \
    --cc=mark@chromium.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).