]> git.ipfire.org Git - thirdparty/git.git/commit
describe: refresh the index when 'broken' flag is used
authorAbhijeet Sonar <abhijeet.nkt@gmail.com>
Wed, 26 Jun 2024 19:08:00 +0000 (00:38 +0530)
committerJunio C Hamano <gitster@pobox.com>
Wed, 26 Jun 2024 20:04:08 +0000 (13:04 -0700)
commitb8ae42e292c51348b8d8730225396ac9ef72f550
tree0239b437e552aa14cbeb8c6abec4d7431f0add9d
parent786a3e4b8d754d2b14b1208b98eeb0a554ef19a8
describe: refresh the index when 'broken' flag is used

When describe is run with 'dirty' flag, we refresh the index
to make sure it is in sync with the filesystem before
determining if the working tree is dirty.  However, this is
not done for the codepath where the 'broken' flag is used.

This causes `git describe --broken --dirty` to false
positively report the worktree being dirty if a file has
different stat info than what is recorded in the index.
Running `git update-index -q --refresh` to refresh the index
before running diff-index fixes the problem.

Also add tests to deliberately update stat info of a
file before running describe to verify it behaves correctly.

Reported-by: Paul Millar <paul.millar@desy.de>
Suggested-by: Junio C Hamano <gitster@pobox.com>
Helped-by: Junio C Hamano <gitster@pobox.com>
Helped-by: Phillip Wood <phillip.wood123@gmail.com>
Signed-off-by: Abhijeet Sonar <abhijeet.nkt@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/describe.c
t/t6120-describe.sh