From: Abhijeet Sonar <abhijeet.nkt@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: phillip.wood@dunelm.org.uk, Karthik Nayak <karthik.188@gmail.com>,
git@vger.kernel.org, Paul Millar <paul.millar@desy.de>,
Jeff King <peff@peff.net>
Subject: Re: [PATCH] describe: refresh the index when 'broken' flag is used
Date: Mon, 24 Jun 2024 23:07:07 +0530 [thread overview]
Message-ID: <4224c251-c6f7-4b2a-b182-b0a12ee300c8@gmail.com> (raw)
In-Reply-To: <xmqqcyo6cnbb.fsf@gitster.g>
> What is the reason why you want to change the owner of a file in
> your test?
>
> If it is merely to make sure you cannot write to the .git/index
> file, temporarily doing chmod of the .git directory in a test (with
POSIXPERM prerequisite) may be one way to do so, and you do not need
the second user in the system test is running.
I want to change the owner of a checked-in file and not the `.git`
directory. This is because of what you noted in an earlier message:
> As many attributes of each file (like the
> last modified timestamp and who owns the file) are recorded in the
> index for files that were verified to be unmodified (this is done so
> that by doing lstat() on a path and comparing the result with the
> information saved in the index, we can notice that the path was
> modified without actually opening the file and looking at the
> contents), after doing something (like "git diff") that causes this
> information updated while the files appear to be owned by you
Currently, `git describe --dirty --broken` reports the working tree as
dirty if you change the owner of a file. And as Phillip pointed out,
calling `git update-index --unmerged -q --refresh` to update the index
fixes this.
What I want to test looks something like this:
# initially, the file is owned by a non-root user
chown root file
git describe --dirty --broken # incorrectly suffixes the output with '-dirty'
As mentioned earlier, the dirty suffix goes away if the index is
refreshed before running describe. This is what I really want to
assert -- that there is no '-dirty' suffix when owner of a file is changed.
This kind of simulates the scenario where `git describe` is run in a
docker container as was originally reported by Paul:
> mkdir test-container
>
> cd test-container
>
> cat >Dockerfile <<EOF
>
> FROM docker.io/debian:bookworm-slim
>
> WORKDIR /work
>
> RUN apt-get update && apt-get -y install git
>
> EOF
>
> podman build -t test-image .
>
>
>
> mkdir test-repo
>
> cd test-repo
>
> git init echo "Hello, world" > README
>
> git add README
>
> git commit -m "Initial commit" README
>
> git tag v1.0.0
>
>
>
> git describe --tags --dirty --broken
>
>
>
> podman run -v `pwd`:/work --rm -it --entrypoint '["/usr/bin/git",
>
> "describe", "--tags", "--dirty", "--broken"]' test-image
Thanks
next prev parent reply other threads:[~2024-06-24 17:37 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-23 21:42 [PATCH] describe: refresh the index when 'broken' flag is used Abhijeet Sonar
2024-06-23 21:56 ` Abhijeet Sonar
2024-06-24 10:56 ` Karthik Nayak
2024-06-24 11:20 ` Phillip Wood
2024-06-24 12:20 ` Abhijeet Sonar
2024-06-24 13:48 ` Abhijeet Sonar
2024-06-24 16:34 ` Junio C Hamano
2024-06-24 17:37 ` Abhijeet Sonar [this message]
2024-06-24 17:58 ` Junio C Hamano
2024-06-25 6:40 ` Abhijeet Sonar
2024-06-25 6:44 ` [PATCH v2] " Abhijeet Sonar
2024-06-25 12:27 ` Karthik Nayak
2024-06-25 13:22 ` Abhijeet Sonar
2024-06-25 12:28 ` [PATCH] " 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=4224c251-c6f7-4b2a-b182-b0a12ee300c8@gmail.com \
--to=abhijeet.nkt@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=karthik.188@gmail.com \
--cc=paul.millar@desy.de \
--cc=peff@peff.net \
--cc=phillip.wood@dunelm.org.uk \
/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).