All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Karthik Nayak <karthik.188@gmail.com>
Cc: Abhijeet Sonar <abhijeet.nkt@gmail.com>,
	 git@vger.kernel.org,  Paul Millar <paul.millar@desy.de>,
	 Phillip Wood <phillip.wood123@gmail.com>,
	Elijah Newren <newren@gmail.com>,  Jeff King <peff@peff.net>
Subject: Re: [PATCH v5] describe: refresh the index when 'broken' flag is used
Date: Wed, 26 Jun 2024 07:59:10 -0700	[thread overview]
Message-ID: <xmqqmsn7698h.fsf@gitster.g> (raw)
In-Reply-To: <CAOLa=ZRz2KEGiBnX1YP6JG1nXXHLfw9A3dHKO3s_ViLhq+bWww@mail.gmail.com> (Karthik Nayak's message of "Wed, 26 Jun 2024 07:30:19 -0400")

Karthik Nayak <karthik.188@gmail.com> writes:

>> +		cat file >file.new &&
>> +		mv file.new file &&
>> +		git describe --dirty >actual &&
>> +		echo "A" >expected &&
>> +		test_cmp expected actual &&
>> +
>> +		cat file >file.new &&
>> +		mv file.new file &&
>> +		git describe --dirty --broken >actual &&
>> +		echo "A" >expected &&
>> +		test_cmp expected actual
>
> Not worth a reroll, but you don't have to create file.new twice.

I think you have to make the "file" stat-dirty again after the first
test, as a successful first test _should_ refresh the index (and
that was why my manual illustration in an earlier message
<xmqqsex2b4ti.fsf@gitster.g> did "--dirty --broken" first before
"--dirty" alone, knowing that the former fails to refresh the
index).

You are right to point out that the expected results for "--dirty"
and "--dirty --broken" are the same and we do not have to create it
twice, though.

If the filesystem has a usable inode number, then replacing "file"
with a copy, i.e. "cat file >file.new && mv file.new file", is an
excellent way to ensure that the stat data becomes dirty even when
it is done as a part of a quick series of commands.  But not all
filesystems we run our tests on may have usable inode number, so it
may not be the best thing to do in an automated test.  We could use
"test-tool chmtime" instead, perhaps like:

    ... make the index and the working tree are clean wrt HEAD ...
    # we do not expect -dirty suffix in the output
    echo A >expect &&

    # make "file" stat-dirty
    test-tool chmtime -10 file &&
    # "describe --dirty" refreshes and does not get fooled
    git describe --dirty >actual &&
    test_cmp expect actual &&

    # make "file" stat-dirty again
    test-tool chmtime -10 file &&
    # "describe --dirty --broken" refreshes and does not get fooled
    git describe --dirty --broken >actual &&
    test_cmp expect actual

with the extra comments stripped (I added them only to explain what
is going on to the readers of this e-mail message).

  parent reply	other threads:[~2024-06-26 14:59 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-25 13:35 [PATCH v3] describe: refresh the index when 'broken' flag is used Abhijeet Sonar
2024-06-25 15:59 ` Junio C Hamano
2024-06-25 16:05   ` Junio C Hamano
2024-06-26 11:16     ` Karthik Nayak
2024-06-26  6:11   ` Abhijeet Sonar
2024-06-26  6:37   ` [PATCH v4] " Abhijeet Sonar
2024-06-26  6:50     ` Abhijeet Sonar
2024-06-26  6:52   ` [PATCH v5] " Abhijeet Sonar
2024-06-26 11:30     ` Karthik Nayak
2024-06-26 12:06       ` Abhijeet Sonar
2024-06-26 15:34         ` Re* " Junio C Hamano
2024-06-26 16:17           ` Junio C Hamano
2024-06-26 17:29             ` Abhijeet Sonar
2024-06-26 17:35               ` Junio C Hamano
2024-06-26 17:45                 ` Junio C Hamano
2024-06-26 18:07                 ` Abhijeet Sonar
2024-06-26 18:49                   ` Junio C Hamano
2024-06-26 20:34                     ` Jeff King
2024-06-27  0:33                       ` Jeff King
2024-06-26 21:23                     ` Karthik Nayak
2024-06-26 14:59       ` Junio C Hamano [this message]
2024-06-26 18:31     ` Junio C Hamano
2024-06-26 19:08       ` [PATCH v7] " Abhijeet Sonar
2024-06-26 19:25         ` Abhijeet Sonar
2024-06-27  6:01           ` Abhijeet Sonar
2024-06-27 15:47           ` Junio C Hamano
2024-06-27 17:33             ` Abhijeet Sonar
2024-06-30 16:12             ` Karthik Nayak
2024-07-01 19:06               ` Junio C Hamano
2024-07-02 10:13                 ` Karthik Nayak
2024-07-03 18:17                   ` Junio C Hamano
2024-07-03 20:41                     ` Karthik Nayak

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=xmqqmsn7698h.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=abhijeet.nkt@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=karthik.188@gmail.com \
    --cc=newren@gmail.com \
    --cc=paul.millar@desy.de \
    --cc=peff@peff.net \
    --cc=phillip.wood123@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.