From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Cc: Ash Holland <ash@sorrel.sh>, Aaron Schrab <aaron@schrab.com>
Subject: Re: `git describe --dirty` doesn't consider untracked files to be dirty
Date: Sat, 19 Sep 2020 19:12:20 -0700 [thread overview]
Message-ID: <xmqq1rixi4cb.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <xmqq5z89i5j3.fsf@gitster.c.googlers.com> (Junio C. Hamano's message of "Sat, 19 Sep 2020 18:46:40 -0700")
Junio C Hamano <gitster@pobox.com> writes:
> The first step would be to allow those who want their "git describe
> --dirty --ignore=none" (untracked files are counted as dirtiness, to
> be consistent with how "git diff" sees submodule directories by
> default) to use presence of untracked files as dirty. This is a
> safe first step and can be done without breaking any existing users.
It is worse than I thought. There is zero-th step we need to have,
to fix "git describe --dirty" itself.
Because the command internally uses "diff-index", and by default it
considers that a submodule with untracked path *is* dirty. Because
of that, you get an inexplicable inconsistent behaviour.
* If you start from a pristine checkout, and then add an untracked
path to the current project, "git describe --dirty" won't give
the -dirty suffix.
* But if you add an untracked path in its submodule, the command
does give you the -dirty suffix.
A fix, without the first-step to give the command configurable
definition of what makes a repository 'dirty', would probably look
like the attached untested patch. A fix to "diff" machinery to make
"--ignore-submodules=untracked" the default would also make "describe"
internally consistent, too.
builtin/describe.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/describe.c b/builtin/describe.c
index 7668591d57..af08d7d8cf 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -45,7 +45,7 @@ static struct commit_names commit_names;
/* diff-index command arguments to check if working tree is dirty. */
static const char *diff_index_args[] = {
- "diff-index", "--quiet", "HEAD", "--", NULL
+ "diff-index", "--quiet", "--ignore-submodules=untracked", "HEAD", "--", NULL
};
struct commit_name {
prev parent reply other threads:[~2020-09-20 2:12 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-07 9:04 `git describe --dirty` doesn't consider untracked files to be dirty Ash Holland
2020-09-08 7:40 ` Raymond E. Pasco
2020-09-08 16:33 ` Junio C Hamano
2020-09-08 23:16 ` Aaron Schrab
2020-09-08 23:59 ` Junio C Hamano
2020-09-19 18:12 ` Junio C Hamano
2020-09-20 0:17 ` Ash Holland
2020-09-20 1:46 ` Junio C Hamano
2020-09-20 2:12 ` Junio C Hamano [this message]
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq1rixi4cb.fsf@gitster.c.googlers.com \
--to=gitster@pobox.com \
--cc=aaron@schrab.com \
--cc=ash@sorrel.sh \
--cc=git@vger.kernel.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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).