lkml.org 
[lkml]   [2021]   [May]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH 4/5] scripts/setlocalversion: factor out 12-chars hash construction
Date

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

\
 
 \ /
  Last update: 2021-05-23 11:14    [W:2.316 / U:0.268 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site