diff mbox series

build-sys: fix git version from -version

Message ID 20200929134237.514286-1-marcandre.lureau@redhat.com
State Superseded
Headers show
Series build-sys: fix git version from -version | expand

Commit Message

Marc-André Lureau Sept. 29, 2020, 1:42 p.m. UTC
From: Marc-André Lureau <marcandre.lureau@redhat.com>

Typo introduced with the script.

Fixes: 2c273f32d3 ("meson: generate qemu-version.h")
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 scripts/qemu-version.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Eric Blake Sept. 29, 2020, 2:06 p.m. UTC | #1
On 9/29/20 8:42 AM, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>

> 

> Typo introduced with the script.

> 

> Fixes: 2c273f32d3 ("meson: generate qemu-version.h")

> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

> ---

>   scripts/qemu-version.sh | 2 +-

>   1 file changed, 1 insertion(+), 1 deletion(-)

> 

> diff --git a/scripts/qemu-version.sh b/scripts/qemu-version.sh

> index 03128c56a2..430a7fc581 100755

> --- a/scripts/qemu-version.sh

> +++ b/scripts/qemu-version.sh

> @@ -9,7 +9,7 @@ version="$3"

>   if [ -z "$pkgversion" ]; then

>       cd "$dir"

>       if [ -e .git ]; then

> -        pkgversion=$(git describe --match 'v*' --dirty | echo "")


This always produces pkgversion="" (the git describe output is ignored 
when it is piped to echo).

> +        pkgversion=$(git describe --match 'v*' --dirty || echo "")


But this just looks weird. $(echo "") is the same as "".  The REAL goal 
here appears to be that you want 'set -e' to not die if git describe has 
a non-zero exit status.  But that's shorter to write as:

pkgversion=$(git describe --match 'v*' --dirty || :)

or even

pkgversion=$(git describe --match 'v*' --dirty) || :


-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
Marc-André Lureau Sept. 29, 2020, 2:32 p.m. UTC | #2
Hi

On Tue, Sep 29, 2020 at 6:07 PM Eric Blake <eblake@redhat.com> wrote:

> On 9/29/20 8:42 AM, marcandre.lureau@redhat.com wrote:

> > From: Marc-André Lureau <marcandre.lureau@redhat.com>

> >

> > Typo introduced with the script.

> >

> > Fixes: 2c273f32d3 ("meson: generate qemu-version.h")

> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

> > ---

> >   scripts/qemu-version.sh | 2 +-

> >   1 file changed, 1 insertion(+), 1 deletion(-)

> >

> > diff --git a/scripts/qemu-version.sh b/scripts/qemu-version.sh

> > index 03128c56a2..430a7fc581 100755

> > --- a/scripts/qemu-version.sh

> > +++ b/scripts/qemu-version.sh

> > @@ -9,7 +9,7 @@ version="$3"

> >   if [ -z "$pkgversion" ]; then

> >       cd "$dir"

> >       if [ -e .git ]; then

> > -        pkgversion=$(git describe --match 'v*' --dirty | echo "")

>

> This always produces pkgversion="" (the git describe output is ignored

> when it is piped to echo).

>

> > +        pkgversion=$(git describe --match 'v*' --dirty || echo "")

>

> But this just looks weird. $(echo "") is the same as "".  The REAL goal

> here appears to be that you want 'set -e' to not die if git describe has

> a non-zero exit status.  But that's shorter to write as:

>

> pkgversion=$(git describe --match 'v*' --dirty || :)

>

> or even

>

> pkgversion=$(git describe --match 'v*' --dirty) || :

>

>

>

Works for me too. I am sending v2.

thanks

-- 
Marc-André Lureau
<div dir="ltr"><div dir="ltr">Hi<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Sep 29, 2020 at 6:07 PM Eric Blake &lt;<a href="mailto:eblake@redhat.com">eblake@redhat.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 9/29/20 8:42 AM, <a href="mailto:marcandre.lureau@redhat.com" target="_blank">marcandre.lureau@redhat.com</a> wrote:<br>
&gt; From: Marc-André Lureau &lt;<a href="mailto:marcandre.lureau@redhat.com" target="_blank">marcandre.lureau@redhat.com</a>&gt;<br>
&gt; <br>
&gt; Typo introduced with the script.<br>
&gt; <br>
&gt; Fixes: 2c273f32d3 (&quot;meson: generate qemu-version.h&quot;)<br>
&gt; Signed-off-by: Marc-André Lureau &lt;<a href="mailto:marcandre.lureau@redhat.com" target="_blank">marcandre.lureau@redhat.com</a>&gt;<br>
&gt; ---<br>
&gt;   scripts/qemu-version.sh | 2 +-<br>
&gt;   1 file changed, 1 insertion(+), 1 deletion(-)<br>
&gt; <br>
&gt; diff --git a/scripts/qemu-version.sh b/scripts/qemu-version.sh<br>
&gt; index 03128c56a2..430a7fc581 100755<br>
&gt; --- a/scripts/qemu-version.sh<br>
&gt; +++ b/scripts/qemu-version.sh<br>
&gt; @@ -9,7 +9,7 @@ version=&quot;$3&quot;<br>
&gt;   if [ -z &quot;$pkgversion&quot; ]; then<br>
&gt;       cd &quot;$dir&quot;<br>
&gt;       if [ -e .git ]; then<br>
&gt; -        pkgversion=$(git describe --match &#39;v*&#39; --dirty | echo &quot;&quot;)<br>
<br>
This always produces pkgversion=&quot;&quot; (the git describe output is ignored <br>
when it is piped to echo).<br>
<br>
&gt; +        pkgversion=$(git describe --match &#39;v*&#39; --dirty || echo &quot;&quot;)<br>
<br>
But this just looks weird. $(echo &quot;&quot;) is the same as &quot;&quot;.  The REAL goal <br>
here appears to be that you want &#39;set -e&#39; to not die if git describe has <br>
a non-zero exit status.  But that&#39;s shorter to write as:<br>
<br>
pkgversion=$(git describe --match &#39;v*&#39; --dirty || :)<br>
<br>
or even<br>
<br>
pkgversion=$(git describe --match &#39;v*&#39; --dirty) || :<br>
<br>
<br></blockquote><div><br></div><div>Works for me too. I am sending v2.</div><div><br></div><div>thanks<br></div></div><div class="gmail_quote"><br></div><div class="gmail_quote">-- <br></div><div dir="ltr" class="gmail_signature">Marc-André Lureau<br></div></div>
diff mbox series

Patch

diff --git a/scripts/qemu-version.sh b/scripts/qemu-version.sh
index 03128c56a2..430a7fc581 100755
--- a/scripts/qemu-version.sh
+++ b/scripts/qemu-version.sh
@@ -9,7 +9,7 @@  version="$3"
 if [ -z "$pkgversion" ]; then
     cd "$dir"
     if [ -e .git ]; then
-        pkgversion=$(git describe --match 'v*' --dirty | echo "")
+        pkgversion=$(git describe --match 'v*' --dirty || echo "")
     fi
 fi