git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Sipek <jeffpc@josefsipek.net>
To: Per Cederqvist <cederp@opera.com>
Cc: git@vger.kernel.org
Subject: Re: [GUILT 1/5] Fix generation of Documentation/usage-%.txt.
Date: Fri, 23 Jan 2015 09:21:03 -0500	[thread overview]
Message-ID: <20150123142103.GA101465@meili.jeffnet.31bits.net> (raw)
In-Reply-To: <1422019499-2012-2-git-send-email-cederp@opera.com>

On Fri, Jan 23, 2015 at 02:24:55PM +0100, Per Cederqvist wrote:
> The old rule worked, most of the time, but had several issues:
> 
>  - It depended on the corresponding guilt-*.txt file, but the usage.sh
>    script actually reads ../guilt-foo.
> 
>  - Actually, each usage-%.txt depended on all guilt-*.txt files, so
>    make had to do more work than necessary if a single file was
>    altered.
> 
>  - The construct broke parallel make, which would spawn several
>    usage.sh at once.  This leads to unnecessary work, and could
>    potentially result in broken usage files if the "echo some_string >
>    some_file" construct used by usage.sh isn't atomic.
>
> Fixed by letting the usage.sh script update a single file, and writing
> a proper implicit make rule.  This makes parallel make work a lot
> better.

Nice!

> There is a small downside, though, as usage.sh will now be run once
> for each command (if everything is regenerated).  I think it is worth
> to pay that price to get the correctness.  This command is still very
> fast compared to the docbook processing.

Given how much simple usage.sh got, I'm thinking it might be worth it to
just remove it, and just shove the rule into the makefile itself.

Ok, I tried to write it.  I came up with the following.  (Note: I have *not*
tested it.)  It's not *that* ugly.

usage-guilt-%.txt: ../guilt-% usage.sh
	echo "'$(basename $<)' `sed -n -e '/^USAGE=/{s/USAGE="//; s/"$//; p; q}' $<`" > $@

What do you think?  Too opaque?  Your change looks good.

Jeff.

> Signed-off-by: Per Cederqvist <cederp@opera.com>
> ---
>  Documentation/Makefile | 4 ++--
>  Documentation/usage.sh | 8 +++-----
>  2 files changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/Documentation/Makefile b/Documentation/Makefile
> index b6c3285..ec3c9e8 100644
> --- a/Documentation/Makefile
> +++ b/Documentation/Makefile
> @@ -66,8 +66,8 @@ clean:
>  	rm -f usage-*.txt
>  	rm -f version.txt
>  
> -usage-%.txt: $(MAN1_TXT) usage.sh
> -	sh ./usage.sh
> +usage-guilt-%.txt: ../guilt-% usage.sh
> +	sh ./usage.sh $<
>
>  %.html : %.txt footer.txt version.txt
>  	$(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf $(ASCIIDOC_EXTRA) $<
> diff --git a/Documentation/usage.sh b/Documentation/usage.sh
> index 20fdca4..629f546 100644
> --- a/Documentation/usage.sh
> +++ b/Documentation/usage.sh
> @@ -1,7 +1,5 @@
>  #!/bin/sh
>  
> -for i in `ls ../guilt-*`; do
> -	name=$(basename $i)
> -	u=$(grep USAGE $i |  sed 's/USAGE="//' | sed 's/"$//') 
> -	echo "'$name' $u"  > usage-$name.txt
> -done
> +name=$(basename $1)
> +u=$(grep USAGE $1 |  sed 's/USAGE="//' | sed 's/"$//') 
> +echo "'$name' $u"  > usage-$name.txt
> -- 
> 2.1.0
> 

-- 
The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all progress
depends on the unreasonable man.
		- George Bernard Shaw

  reply	other threads:[~2015-01-23 14:21 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-23 13:24 [GUILT 0/5] doc: less guilt-foo invocations, minor Makefile fixes Per Cederqvist
2015-01-23 13:24 ` [GUILT 1/5] Fix generation of Documentation/usage-%.txt Per Cederqvist
2015-01-23 14:21   ` Jeff Sipek [this message]
2015-01-23 14:33     ` Per Cederqvist
2015-01-23 14:36       ` Jeff Sipek
2015-01-23 13:24 ` [GUILT 2/5] doc: guilt.xml depends on cmds.txt Per Cederqvist
2015-01-23 14:23   ` Jeff Sipek
2015-01-23 13:24 ` [GUILT 3/5] doc: don't use guilt-foo invocations in examples Per Cederqvist
2015-01-23 14:25   ` Jeff Sipek
2015-01-23 13:24 ` [GUILT 4/5] doc: don't use guilt-foo invocations in usage messages Per Cederqvist
2015-01-23 14:27   ` Jeff Sipek
2015-01-23 13:24 ` [GUILT 5/5] doc: git doesn't use git-foo invocations Per Cederqvist
2015-01-23 14:29   ` Jeff Sipek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150123142103.GA101465@meili.jeffnet.31bits.net \
    --to=jeffpc@josefsipek.net \
    --cc=cederp@opera.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).