Re: [PATCH 4/5] scripts/setlocalversion: factor out 12-chars hash construction

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hey Masahiro,

Masahiro Yamada <masahiroy@xxxxxxxxxx> 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@xxxxxxxxxxxxxxx>

--
Sustainable and modern Infrastructures by ungleich.ch



[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux