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

Re: [PATCH] doc: set actual revdate for manpages

From
Jeff King <peff@peff.net>
Date
Apr 14, 2023, 21:35 UTC
Message-ID
<20230414213537.GA640081@coredump.intra.peff.net>
In-Reply-To
<643949a57396c_5b7e62948d@chronos.notmuch>
On Fri, Apr 14, 2023 at 06:40:05AM -0600, Felipe Contreras wrote:
Show 10 quoted lines
> > It would be nicer to populate the date variable in that case, like we do
> > for GIT_VERSION. I think that could look something like this:
> 
> Indeed, that would be better, but that totally can be done in a separate patch,
> or a separate series even.
> 
> The perfect doesn't have to be the enemy of the good, and that can be done
> later.
> 
> In the meantime something is better than nothing.

Sometimes, as long as it is not making the status quo worse in the meantime. In this case, if the tarball build continues to use the current date (which it appears to), then it's not changing. It does become inconsistent with the output you get from building in-repo, which is unfortunate. But that might be acceptable.

If so, it would make sense to document that decision in the commit message. We'd also want to suppress stderr from the Git invocation so that tarball builders don't see a confusing error message. And probably we should avoid using the "git show" porcelain in a script. I think:

  git rev-list -1 --no-commit-header --format=%as HEAD
would do what you want (or %cs; I don't have a strong opinion there).
Show 15 quoted lines
> > --- a/GIT-VERSION-GEN
> > +++ b/GIT-VERSION-GEN
> > @@ -10,7 +10,8 @@ LF='
> >  # then try git-describe, then default.
> >  if test -f version
> >  then
> > -	VN=$(cat version) || VN="$DEF_VER"
> > +	VN=$(cut -d" " -f1 version) || VN="$DEF_VER"
> > +	DN=$(cut -d" " -f2 version) || DN=""
> 
> Although this works, I have an issue with doing multiple unnecessary forks.
> 
> This does the same, no?
> 
>   read VN DN <version

Yeah, that should be fine. The original could probably be using "read" in the first place. In general it's worth micro-optimizing this script because it runs on every single "make" invocation, though this code path in particular is only run for tarball builders (who presumably build a lot less than developers).

It might also be worth just putting the two fields in two separate files, if there's any question of spaces in the version field.

-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 10 of 14 in “doc: set actual revdate for manpages”
  1. doc: set actual revdate for manpagesFelipe Contreras, Apr 13, 2023
  2. Jeff KingApr 14, 2023
  3. Felipe ContrerasApr 14, 2023
  4. Junio C HamanoApr 14, 2023
  5. Junio C HamanoApr 14, 2023
  6. Felipe ContrerasApr 14, 2023
  7. Felipe ContrerasApr 14, 2023
  8. Jeff KingApr 14, 2023
  9. Junio C HamanoApr 14, 2023
  10. Jeff KingApr 14, 2023
  11. Junio C HamanoApr 14, 2023
  12. Felipe ContrerasApr 14, 2023
  13. Junio C HamanoApr 14, 2023
  14. Felipe ContrerasApr 14, 2023

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.