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

Re: [PATCH 1/2] version-gen: cleanup

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 9, 2013, 06:03 UTC
Message-ID
<7vppsiila6.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1378702889-21638-2-git-send-email-felipe.contreras@gmail.com>
Felipe Contreras <felipe.contreras@gmail.com> writes:
Show 28 quoted lines
> No functional changes.
>
> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> ---
>  GIT-VERSION-GEN | 24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
> index 06026ea..b0db139 100755
> --- a/GIT-VERSION-GEN
> +++ b/GIT-VERSION-GEN
> @@ -7,21 +7,24 @@ LF='
>  '
>  
>  # First see if there is a version file (included in release tarballs),
> -# then try git-describe, then default.
> +# then try 'git describe', then default.
>  if test -f version
>  then
>  	VN=$(cat version) || VN="$DEF_VER"
>  elif test -d ${GIT_DIR:-.git} -o -f .git &&
> -	VN=$(git describe --match "v[0-9]*" --abbrev=7 HEAD 2>/dev/null) &&
> +	VN=$(git describe --match "v[0-9]*" --abbrev=7 HEAD 2>/dev/null)
> +then
>  	case "$VN" in
> -	*$LF*) (exit 1) ;;
> +	*$LF*)
> +		exit 1

The funnily written "false" is misleading and a clean-up may be a good idea to turn it to a straight "false".

I however think this actually changes the behaviour.

In any case, if you want to keep this step a "no functional change" rewrite, this section has to be part of the condition of this "elif" (because it logically is). If describe couldn't describe HEAD, or even if it could, if its output was multi-line for any reason, we wanted to punt and let the DEF_VER in the last "else" clause kick in.

After the update, describe output that is not a single-liner will fail the entire script, instead of falling back to DEF_VER. I actually think it is a good change to fail it (even though it is unlikely that the "describe" command give above would give more than one line).

Show 14 quoted lines
> +		;;
>  	v[0-9]*)
>  		git update-index -q --refresh
>  		test -z "$(git diff-index --name-only HEAD --)" ||
> -		VN="$VN-dirty" ;;
> +		VN="$VN-dirty"
> +		;;
>  	esac
> -then
> -	VN=$(echo "$VN" | sed -e 's/-/./g');
> +	VN=$(echo "$VN" | sed -e 's/-/./g')
>  else
>  	VN="$DEF_VER"
>  fi
Previous: Felipe ContrerasNext: Felipe Contreras
Message 3 of 8 in “version-gen: fixes and cleanups”
  1. 0/2 version-gen: fixes and cleanupsFelipe Contreras, Sep 9, 2013
  2. 1/2 version-gen: cleanupFelipe Contreras, Sep 9, 2013
  3. Junio C HamanoSep 9, 2013
  4. 2/2 version-gen: avoid messing the versionFelipe Contreras, Sep 9, 2013
  5. Junio C HamanoSep 9, 2013
  6. Felipe ContrerasSep 9, 2013
  7. brian m. carlsonSep 9, 2013
  8. Felipe ContrerasSep 10, 2013

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.