Nir Soffer
2021-Nov-29 13:37 UTC
[Libguestfs] [PATCH libnbd] podwrapper.pl.in: Use short commit date
On Mon, Nov 29, 2021 at 3:12 PM Richard W.M. Jones <rjones at redhat.com> wrote:> > On Mon, Nov 08, 2021 at 06:06:40PM +0000, Richard W.M. Jones wrote: > > On Mon, Nov 08, 2021 at 07:55:51PM +0200, Nir Soffer wrote: > > > We can use git short commit date format $cs. Maybe it was not available > > > when podwrapper.pl was create. > > > > > > Signed-off-by: Nir Soffer <nsoffer at redhat.com> > > > --- > > > podwrapper.pl.in | 3 +-- > > > 1 file changed, 1 insertion(+), 2 deletions(-) > > > > > > diff --git a/podwrapper.pl.in b/podwrapper.pl.in > > > index 9b39d7c..86ef452 100755 > > > --- a/podwrapper.pl.in > > > +++ b/podwrapper.pl.in > > > @@ -233,8 +233,7 @@ my $date; > > > my $filename = "$abs_top_srcdir/.git"; > > > if (!$date && -d $filename) { > > > local $ENV{GIT_DIR} = $filename; > > > - $_ = `git show -O/dev/null -s --format=%ci`; > > > - $date = $1 if /^(\d+-\d+-\d+)\s/; > > > + $date = `git show -O/dev/null -s --format=%cs`; > > > } > > > if (!$date) { > > > my ($day, $month, $year) = (gmtime($ENV{SOURCE_DATE_EPOCH} || time))[3,4,5]; > > > > This is fine. Same patch should go into nbdkit too. > > Actually this caused a problem and I had to revert the commits in > nbdkit & libnbd. See: > > https://gitlab.com/nbdkit/nbdkit/-/commit/750ad5972bb082d188f17f8f71ef1ec0c616c676Sorry, I tested the generated man pages with "man /path/to/manpage" and they looked correct. I think this should work: - $_ = `git show -O/dev/null -s --format=%ci`; + $_ = `git show -O/dev/null -s --format=%cs`; Nir
Richard W.M. Jones
2021-Nov-29 14:49 UTC
[Libguestfs] [PATCH libnbd] podwrapper.pl.in: Use short commit date
On Mon, Nov 29, 2021 at 03:37:47PM +0200, Nir Soffer wrote:> On Mon, Nov 29, 2021 at 3:12 PM Richard W.M. Jones <rjones at redhat.com> wrote: > > > > On Mon, Nov 08, 2021 at 06:06:40PM +0000, Richard W.M. Jones wrote: > > > On Mon, Nov 08, 2021 at 07:55:51PM +0200, Nir Soffer wrote: > > > > We can use git short commit date format $cs. Maybe it was not available > > > > when podwrapper.pl was create. > > > > > > > > Signed-off-by: Nir Soffer <nsoffer at redhat.com> > > > > --- > > > > podwrapper.pl.in | 3 +-- > > > > 1 file changed, 1 insertion(+), 2 deletions(-) > > > > > > > > diff --git a/podwrapper.pl.in b/podwrapper.pl.in > > > > index 9b39d7c..86ef452 100755 > > > > --- a/podwrapper.pl.in > > > > +++ b/podwrapper.pl.in > > > > @@ -233,8 +233,7 @@ my $date; > > > > my $filename = "$abs_top_srcdir/.git"; > > > > if (!$date && -d $filename) { > > > > local $ENV{GIT_DIR} = $filename; > > > > - $_ = `git show -O/dev/null -s --format=%ci`; > > > > - $date = $1 if /^(\d+-\d+-\d+)\s/; > > > > + $date = `git show -O/dev/null -s --format=%cs`; > > > > } > > > > if (!$date) { > > > > my ($day, $month, $year) = (gmtime($ENV{SOURCE_DATE_EPOCH} || time))[3,4,5]; > > > > > > This is fine. Same patch should go into nbdkit too. > > > > Actually this caused a problem and I had to revert the commits in > > nbdkit & libnbd. See: > > > > https://gitlab.com/nbdkit/nbdkit/-/commit/750ad5972bb082d188f17f8f71ef1ec0c616c676 > > Sorry, I tested the generated man pages with "man /path/to/manpage" and > they looked correct. > > I think this should work: > > - $_ = `git show -O/dev/null -s --format=%ci`; > + $_ = `git show -O/dev/null -s --format=%cs`;Yes, I think so. As long as the $date = $1 if .. line is left alone (because that implicitly removes the \n). Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://people.redhat.com/~rjones/virt-df/
Eric Blake
2021-Nov-30 16:16 UTC
[Libguestfs] [PATCH libnbd] podwrapper.pl.in: Use short commit date
On Mon, Nov 29, 2021 at 03:37:47PM +0200, Nir Soffer wrote:> > > > if (!$date && -d $filename) { > > > > local $ENV{GIT_DIR} = $filename; > > > > - $_ = `git show -O/dev/null -s --format=%ci`; > > > > - $date = $1 if /^(\d+-\d+-\d+)\s/; > > > > + $date = `git show -O/dev/null -s --format=%cs`; > > > > } > > > > if (!$date) { > > > > my ($day, $month, $year) = (gmtime($ENV{SOURCE_DATE_EPOCH} || time))[3,4,5]; > > > > > > This is fine. Same patch should go into nbdkit too. > > > > Actually this caused a problem and I had to revert the commits in > > nbdkit & libnbd. See: > > > > https://gitlab.com/nbdkit/nbdkit/-/commit/750ad5972bb082d188f17f8f71ef1ec0c616c676 > > Sorry, I tested the generated man pages with "man /path/to/manpage" and > they looked correct. > > I think this should work: > > - $_ = `git show -O/dev/null -s --format=%ci`; > + $_ = `git show -O/dev/null -s --format=%cs`;%cs is correct, but what you missed was that --format=%cs outputs 'yyyy-mm-dd\n', and the \n hurts. Reading 'git format --help', that is short for --format=tformat:%cs, but we need --format=format:%cs (that is, we do not want the trailing newline). I've reinstated your patch as bdcf0765 on nbdkit, and will shortly follow up on libnbd. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org