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

Re: [PATCH RFC] git describe without refs distinguishes dirty working tree

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 16, 2009, 17:26 UTC
Message-ID
<7vd44nuu6g.fsf@alter.siamese.dyndns.org>
In-Reply-To
<dffdbd190910160812h6d6a876el8261a622b5439b30@mail.gmail.com>
Jean Privat <jean@pryen.org> writes:
Show 30 quoted lines
> ...
> This new behavior could affect existing scripts by producing version
> number like v1.0.4-14-g2414721-dirty-dirty.
> These scripts could be easily fixed by explicitly using HEAD when calling
> `git describe` and works with any version of git.
>
> Signed-off-by: Jean Privat <jean@pryen.org>
> ---
>
> Initially, I wanted to add an option `--worktree` that works on HEAD and
> appends "-dirty" when the working tree is dirty. After rethink I
> realized that users (me included) should prefer to describe the working
> tree by default, and only describe HEAD if HEAD was explicitly specified.
>
> Note that documentation of `git describe` did not mentioned the behavior
> of the command when no committish is specified.
> However, since it is still a behavior change. If the patch is accepted,
> it could target version 1.7.
> ---
>  Documentation/git-describe.txt |    5 ++++-
>  builtin-describe.c             |   18 +++++++++++++++++-
>  t/t6120-describe.sh            |    8 ++++++++
>  3 files changed, 29 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/git-describe.txt b/Documentation/git-describe.txt
> index b231dbb..c49ecc8 100644
> --- a/Documentation/git-describe.txt
> +++ b/Documentation/git-describe.txt
> @@ -8,7 +8,7 @@ git-describe - Show the most recent tag that is
> reachable from a commit

Here is an indication of a linewrapped and broken patch that discourages me to look further.

As to the new _ability_, I think it would make sense to reduce the need for an extra invocation of "is the work tree dirty" and this addition is a welcomed one in that sense. However, as you already are aware of, this will break existing scripts; it should not trigger for them.

How about "describe --dirty" and "describe --dirty=-mod" (the latter creates v1.6.5-15-gc274db7-mod"), possibly with a short version of options if this proves to be useful and frequently used from interactive sessions?

I personally think this does not deserve to have a short option (as you said in the log message, it is primarily a way to make up a version number string, and give interactive users a sense of where in the history he is. If you want to know if your tree is dirty, depending on the reason _why_ you want to know it and what you want to do with the information after learning your tree is dirty, "status", "diff --stat", "add -i" are more appropriate and useful tools) but you (and others) may bring up use cases that I didn't think of when I wrote the beginning of this sentence ;-)

Previous: Jean PrivatNext: Shawn O. Pearce
Message 2 of 8 in “git describe without refs distinguishes dirty working tree”
  1. git describe without refs distinguishes dirty working treeJean Privat, Oct 16, 2009
  2. Junio C HamanoOct 16, 2009
  3. Shawn O. PearceOct 16, 2009
  4. Junio C HamanoOct 16, 2009
  5. Jean PrivatOct 16, 2009
  6. Shawn O. PearceOct 16, 2009
  7. Junio C HamanoOct 16, 2009
  8. Nicolas PitreOct 17, 2009

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.