From: "Shawn O. Pearce" <spearce@spearce.org>
To: Yasushi SHOJI <yashi@atmark-techno.com>
Cc: git@vger.kernel.org
Subject: Re: [RFC] describe: add option --dirty
Date: Mon, 23 Jul 2007 02:59:12 -0400 [thread overview]
Message-ID: <20070723065912.GG32566@spearce.org> (raw)
In-Reply-To: <87odi3mxtl.wl@mail2.atmark-techno.com>
Yasushi SHOJI <yashi@atmark-techno.com> wrote:
> when --dirty is given, git describe will check the working tree and
> append "-dirty" to describe string if the tree is dirty.
> ---
> I'm not sure this is good idea or the current way (using diff-index in
> shell script) is more prefered.
Yea, I'm actually torn on this. A lot of people like the output of
git-describe for versions (where a lot is at least me!) and yet I
also always tack in the -dirty if the directory is dirty according
to diff-index. So having this built right into git-describe is
actually quite handy. It simplifies a little bit of build rule
logic.
> diff --git a/Documentation/git-describe.txt b/Documentation/git-describe.txt
> @@ -53,6 +53,9 @@ OPTIONS
> being employed to standard error. The tag name will still
> be printed to standard out.
>
> +--dirty::
> + Append "-dirty" to describe string if working tree is dirty.
> +
It requires a working directory. Running this in a bare repository
with --dirty won't work. You might want to discuss that in the
documentation.
> diff --git a/builtin-describe.c b/builtin-describe.c
> @@ -229,12 +231,23 @@ static void describe(const char *arg, int last_one)
> sha1_to_hex(gave_up_on->object.sha1));
> }
> }
> + if (check_dirty) {
> + const char **args = xmalloc(5 * sizeof(char*));
> + args[0] = "diff-index";
> + args[1] = "--quiet";
> + args[2] = "--name-only";
> + args[3] = "HEAD";
> + args[4] = NULL;
> + if (cmd_diff_index(4, args, prefix))
> + dirty_string = "-dirty";
> + }
So if I describe two different commits at once in the same working
tree you are going to run diff-index twice? That's not a great idea.
The outcome of diff-index won't change between those two commits.
Better to compute this up front before calling the describe()
function, and instead of passing in prefix pass in dirty_string.
Or just make it a global, like you did to the option flag.
> if (abbrev == 0)
> - printf("%s\n", all_matches[0].name->path );
> + printf("%s%s\n", all_matches[0].name->path, dirty_string);
> else
> - printf("%s-%d-g%s\n", all_matches[0].name->path,
> + printf("%s-%d-g%s%s\n", all_matches[0].name->path,
> all_matches[0].depth,
> - find_unique_abbrev(cmit->object.sha1, abbrev));
> + find_unique_abbrev(cmit->object.sha1, abbrev),
> + dirty_string);
>
> if (!last_one)
> clear_commit_marks(cmit, -1);
So if HEAD is exactly matching a tag you don't output the -dirty
suffix, even if the working tree is dirty? That's counter to the
documentation above. See l.150-154, we break out of the describe
function very quickly if there is a tag on the input commit.
--
Shawn.
prev parent reply other threads:[~2007-07-23 7:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-23 6:35 [RFC] describe: add option --dirty Yasushi SHOJI
2007-07-23 6:56 ` Junio C Hamano
2007-07-23 7:08 ` Shawn O. Pearce
2007-07-23 7:54 ` Yasushi SHOJI
2007-07-23 7:58 ` Shawn O. Pearce
2007-07-23 8:52 ` Yasushi SHOJI
2007-07-23 6:59 ` Shawn O. Pearce [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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070723065912.GG32566@spearce.org \
--to=spearce@spearce.org \
--cc=git@vger.kernel.org \
--cc=yashi@atmark-techno.com \
/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).