From: Junio C Hamano <gitster@pobox.com>
To: Stefan Beller <sbeller@google.com>
Cc: git@vger.kernel.org, jrnieder@gmail.com, mfick@codeaurora.org
Subject: Re: [PATCH] builtin/describe: introduce --broken flag
Date: Tue, 21 Mar 2017 14:51:57 -0700 [thread overview]
Message-ID: <xmqq7f3invr6.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20170321185139.8300-1-sbeller@google.com> (Stefan Beller's message of "Tue, 21 Mar 2017 11:51:39 -0700")
Stefan Beller <sbeller@google.com> writes:
> This patch helps to fix the root cause in [1], which tries to work around
> this situation.
I do not necessarily think it is reasonable to give $version-dirty
and proceed when a repository corruption is detected; if there is a
breakage in the repository, "git describe" is correct to die when a
populated submodule is broken. IOW, I do not agree that [1] below
is working with a sensible expectation.
This is a tangent, but how does the Gerrit repository get corrupted
in the way described in [1] in the first place? That might be what
needs to be corrected, perhaps?
> Documentation/git-describe.txt | 7 +++++
> builtin/describe.c | 59 ++++++++++++++++++++++++++++++------------
> t/t6120-describe.sh | 20 ++++++++++++++
> 3 files changed, 70 insertions(+), 16 deletions(-)
>
> diff --git a/Documentation/git-describe.txt b/Documentation/git-describe.txt
> index 8755f3af7b..b71fa7a4ad 100644
> --- a/Documentation/git-describe.txt
> +++ b/Documentation/git-describe.txt
> @@ -34,6 +34,13 @@ OPTIONS
> It means describe HEAD and appends <mark> (`-dirty` by
> default) if the working tree is dirty.
>
> +--broken[=<mark>]::
> + Describe the working tree.
> + It means describe HEAD and appends <mark> (`-broken` by
> + default) if the working tree cannot be examined for dirtiness.
> + This implies `--dirty`, which is the fallback behavior when
> + the working tree examination works.
The wording for the "--dirty" is already awkward, but this one is
even more so ("Describe the working tree. It means" conveys no
useful information). I however cannot come up with something much
better. This is the best I could come up with:
Describe the state of the working tree. When the working
tree matches HEAD, the output is the same as "git describe
HEAD" and "-dirty" is appended to it if the working tree has
local modification. When a repository is corrupt and Git
cannot determine if there is local modification, instead of
dying, append "-broken" instead.
The last sentence can be tweaked to replace the description for
"--dirty".
> diff --git a/builtin/describe.c b/builtin/describe.c
> index 76c18059bf..37a83520c9 100644
> --- a/builtin/describe.c
> +++ b/builtin/describe.c
> @@ -9,6 +9,7 @@
> #include "diff.h"
> #include "hashmap.h"
> #include "argv-array.h"
> +#include "run-command.h"
>
> #define SEEN (1u << 0)
> #define MAX_TAGS (FLAG_BITS - 1)
> @@ -31,12 +32,7 @@ static int have_util;
> static struct string_list patterns = STRING_LIST_INIT_NODUP;
> static struct string_list exclude_patterns = STRING_LIST_INIT_NODUP;
> static int always;
> -static const char *dirty;
> -
> -/* diff-index command arguments to check if working tree is dirty. */
> -static const char *diff_index_args[] = {
> - "diff-index", "--quiet", "HEAD", "--", NULL
> -};
> +static const char *append, *dirty, *broken;
Perhaps call it "suffix" or something?
> + if (broken) {
> + struct child_process cp = CHILD_PROCESS_INIT;
> + argv_array_pushl(&cp.args, "diff-index", "--quiet", "HEAD", "--", NULL);
> ...
> + }
> + } else if (dirty) {
> + struct argv_array args = ARGV_ARRAY_INIT;
> static struct lock_file index_lock;
> int fd;
>
> + argv_array_pushl(&args, "diff-index", "--quiet", "HEAD", "--", NULL);
Somehow it looks like the patch is making the code a lot worse by
losing diff_index_args[] and duplicating the same command line twice
in the code. Wouldn't argv_array_pushv() into these two different args
array from the same template work better?
next prev parent reply other threads:[~2017-03-21 21:52 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-21 0:11 [PATCH 0/3] git-describe deals gracefully with broken submodules Stefan Beller
2017-03-21 0:11 ` [PATCH 1/3] submodule.c: port is_submodule_modified to use porcelain 2 Stefan Beller
2017-03-21 0:11 ` [PATCH 2/3] revision machinery: gentle submodule errors Stefan Beller
2017-03-21 0:11 ` [PATCH 3/3] builtin/describe: introduce --submodule-error-as-dirty flag Stefan Beller
2017-03-21 6:28 ` [PATCH 0/3] git-describe deals gracefully with broken submodules Junio C Hamano
2017-03-21 6:54 ` Junio C Hamano
2017-03-21 18:51 ` [PATCH] builtin/describe: introduce --broken flag Stefan Beller
2017-03-21 21:51 ` Junio C Hamano [this message]
2017-03-21 22:27 ` Stefan Beller
2017-03-21 22:41 ` Junio C Hamano
2017-03-21 22:50 ` Stefan Beller
2017-03-21 22:57 ` [PATCH v2] " Stefan Beller
2017-03-22 17:21 ` Junio C Hamano
2017-03-22 21:50 ` Jakub Narębski
2017-03-21 17:46 ` [PATCH 0/3] git-describe deals gracefully with broken submodules Stefan Beller
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=xmqq7f3invr6.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=jrnieder@gmail.com \
--cc=mfick@codeaurora.org \
--cc=sbeller@google.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.
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).