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

Re: [PATCH] describe: refresh the index when 'broken' flag is used

From
Abhijeet Sonar <abhijeet.nkt@gmail.com>
Date
Jun 24, 2024, 17:37 UTC
Message-ID
<4224c251-c6f7-4b2a-b182-b0a12ee300c8@gmail.com>
In-Reply-To
<xmqqcyo6cnbb.fsf@gitster.g>
Show 5 quoted lines
> 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:

Show 8 quoted lines
> 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:

Show 39 quoted lines
> 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
Previous: Junio C HamanoNext: Junio C Hamano
Message 8 of 14 in “describe: refresh the index when 'broken' flag is used”
  1. describe: refresh the index when 'broken' flag is usedAbhijeet Sonar, Jun 23, 2024
  2. Abhijeet SonarJun 23, 2024
  3. Karthik NayakJun 24, 2024
  4. Phillip WoodJun 24, 2024
  5. Abhijeet SonarJun 24, 2024
  6. Abhijeet SonarJun 24, 2024
  7. Junio C HamanoJun 24, 2024
  8. Abhijeet SonarJun 24, 2024
  9. Junio C HamanoJun 24, 2024
  10. Abhijeet SonarJun 25, 2024
  11. describe: refresh the index when 'broken' flag is usedAbhijeet Sonar, Jun 25, 2024
  12. Karthik NayakJun 25, 2024
  13. Abhijeet SonarJun 25, 2024
  14. Karthik NayakJun 25, 2024

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.