Messages in this thread |  | | From | Nico Schottelius <> | Subject | Re: [PATCH 4/5] scripts/setlocalversion: factor out 12-chars hash construction | Date | Sun, 23 May 2021 11:04:40 +0200 |
| |
Hey Masahiro,
Masahiro Yamada <masahiroy@kernel.org> writes: > - if atag="$(git describe --abbrev=12 2>/dev/null)"; then > - echo "$atag" | awk -F- '{printf("-%05d-%s", $(NF-1),substr($(NF),0,13))}' > - > - # If we don't have a tag at all we print -g{commitish}, > - # again using exactly 12 hex chars. > - else > - head="$(echo $head | cut -c1-12)" > - printf '%s%s' -g $head > + if atag="$(git describe 2>/dev/null)"; then > + echo "$atag" | awk -F- '{printf("-%05d", $(NF-1))}' > fi > + > + # Add -g and exactly 12 hex chars. > + printf '%s%s' -g "$(echo $head | cut -c1-12)" > fi > > # Check for uncommitted changes.
That was quite fun reviewing and wrapping my head around ~20y old code.
I had a very long mail prepared looking at all the corner cases, just to see they are actually handled before the actual change.
Nicely simplified, for all 5 of them:
Reviewed-by: Nico Schottelius <nico-linuxsetlocalversion@schottelius.org>
-- Sustainable and modern Infrastructures by ungleich.ch
|  |