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

Re: [PATCH v2] builtin/describe: introduce --broken flag

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 22, 2017, 17:21 UTC
Message-ID
<xmqqinn1mdlq.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20170321225718.18633-1-sbeller@google.com>
Stefan Beller <sbeller@google.com> writes:
Show 19 quoted lines
> git-describe tells you the version number you're at, or errors out, e.g.
> when you run it outside of a repository, which may happen when downloading
> a tar ball instead of using git to obtain the source code.
>
> To keep this property of only erroring out, when not in a repository,
> severe (submodule) errors must be downgraded to reporting them gently
> instead of having git-describe error out completely.
>
> To achieve that a flag '--broken' is introduced, which is in the same
> vein as '--dirty' but uses an actual child process to check for dirtiness.
> When that child dies unexpectedly, we'll append '-broken' instead of
> '-dirty'.
>
> Signed-off-by: Stefan Beller <sbeller@google.com>
> ---
>  Documentation/git-describe.txt | 11 +++++++---
>  builtin/describe.c             | 47 ++++++++++++++++++++++++++++++++++--------
>  t/t6120-describe.sh            | 20 ++++++++++++++++++
>  3 files changed, 66 insertions(+), 12 deletions(-)

I admit that my suggestion to use pushv() was done without trying it out myself, but I do agree that the result looks better, especially because the "dirty" (not "broken") side does not even have to use a separate argv_array to prepare the command line in the first place (which I failed to spot exactly because I didn't try it myself ;-).

We probably _could_ use cp.argv to point at the diff_index_args() without doing pushv(&cp.args), and that would save a bit of allocation, but it would not matter in practice as this is not a performance critical codepath.

Thanks.
Show 29 quoted lines
> diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh
> index 167491fd5b..16952e44fc 100755
> --- a/t/t6120-describe.sh
> +++ b/t/t6120-describe.sh
> @@ -233,4 +233,24 @@ test_expect_success 'describe --contains and --no-match' '
>  	test_cmp expect actual
>  '
>  
> +test_expect_success 'setup and absorb a submodule' '
> +	test_create_repo sub1 &&
> +	test_commit -C sub1 initial &&
> +	git submodule add ./sub1 &&
> +	git submodule absorbgitdirs &&
> +	git commit -a -m "add submodule" &&
> +	git describe --dirty >expect &&
> +	git describe --broken >out &&
> +	test_cmp expect out
> +'
> +
> +test_expect_success 'describe chokes on severly broken submodules' '
> +	mv .git/modules/sub1/ .git/modules/sub_moved &&
> +	test_must_fail git describe --dirty
> +'
> +test_expect_success 'describe ignoring a borken submodule' '
> +	git describe --broken >out &&
> +	grep broken out
> +'
> +
>  test_done
Previous: Stefan BellerNext: Jakub Narębski
Message 13 of 15 in “git-describe deals gracefully with broken submodules”
  1. 0/3 git-describe deals gracefully with broken submodulesStefan Beller, Mar 21, 2017
  2. 1/3 submodule.c: port is_submodule_modified to use porcelain 2Stefan Beller, Mar 21, 2017
  3. 3/3 builtin/describe: introduce --submodule-error-as-dirty flagStefan Beller, Mar 21, 2017
  4. 2/3 revision machinery: gentle submodule errorsStefan Beller, Mar 21, 2017
  5. Junio C HamanoMar 21, 2017
  6. Junio C HamanoMar 21, 2017
  7. builtin/describe: introduce --broken flagStefan Beller, Mar 21, 2017
  8. Junio C HamanoMar 21, 2017
  9. Stefan BellerMar 21, 2017
  10. Junio C HamanoMar 21, 2017
  11. Stefan BellerMar 21, 2017
  12. builtin/describe: introduce --broken flagStefan Beller, Mar 21, 2017
  13. Junio C HamanoMar 22, 2017
  14. Jakub NarębskiMar 22, 2017
  15. Stefan BellerMar 21, 2017

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.