Why is `git describe -dirty` adding a `-dirty` suffix when describing a clean checkout?

前端 未结 3 516
陌清茗
陌清茗 2021-02-09 01:44

I have just discovered the --dirty option to git describe and it looks like it should do something very useful, i.e. append a suffix to the output of <

3条回答
  •  南笙
    南笙 (楼主)
    2021-02-09 02:23

    Git 2.13 (Q2 2017) improves a bit on that --dirty flag with a --broken one, since "git describe --dirty" dies when it cannot be determined if the state in the working tree matches that of HEAD (e.g. broken repository or broken submodule).

    See commit b0176ce (21 Mar 2017) by Stefan Beller (stefanbeller).
    (Merged by Junio C Hamano -- gitster -- in commit 844768a, 27 Mar 2017)

    builtin/describe: introduce --broken flag

    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'.

提交回复
热议问题