From: Jonathan Nieder <jrnieder@gmail.com>
To: Patrick Doyle <wpdster@gmail.com>
Cc: git <git@vger.kernel.org>, Jeff King <peff@peff.net>,
Thomas Rast <trast@student.ethz.ch>
Subject: Re: How to "pre-populate" a git message
Date: Fri, 3 Dec 2010 13:29:50 -0600 [thread overview]
Message-ID: <20101203192950.GA14561@burratino> (raw)
In-Reply-To: <AANLkTim=dVxVLL31aEBrjw7OhXpdYOjAO9Sk16gGP3zJ@mail.gmail.com>
(+cc: Jeff and Thomas, pioneers in application of notes)
Hi!
Patrick Doyle wrote:
> Once in a while, I would like to run some scripts that will
> automatically generate some files that I keep maintained in my
> repository. (Yes, I know that I shouldn't have to keep them version
> controlled if I can regenerate them, but it's easier to check out old
> versions of the files than it is to check out old versions of the
> repository, wait 1/2 hour to regenerate the files, and then look at
> them).
Not what you asked, but here's an alternative approach.
The idea is that sometimes you might not want to wait 1/2 hour
for each commit and that keeping generated files in this case is
more about caching than tracking content.
So, wouldn't it be nice if you could ask to remember these
generated files _after_ commiting? It works like this:
An expensive command to generate some files can be run
(asynchronously?) by explicit request, commit hook, or cron job.
First it would check if the file is already available.
if git notes --ref=generated/expensive.result show HEAD >/dev/null 2>&1
then
# already cached
exit 0
elif test $? != 1
then
# exit with error message
exec git notes --ref=generated/expensive.result show HEAD
fi
# no note found; let's make one!
... expensive operation ...
blob=$(git hash-object -w expensive.result) &&
git notes --ref=generated/expensive.result add -C "$blob" HEAD ||
exit
The result could be retrieved on checkout (see the post-checkout hook)
or explicitly.
git notes --ref=generated/expensive.result show HEAD >expensive.result+
mv expensive.result+ expensive.result
See v1.7.2-rc0~159^2~1 (diff: cache textconv output, 2010-04-01) for
a similar (but not identical) example. Unfortunately the notes-cache
facility used there is not currently exposed for scripted use.
Sorry for the digression. To return to your question:
> I also like to review the files before they get committed.
Maybe "git commit -v" or the prepare-commit-msg hook could help?
Thanks for an example.
Jonathan
next prev parent reply other threads:[~2010-12-03 19:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-03 17:51 How to "pre-populate" a git message Patrick Doyle
2010-12-03 19:29 ` Jonathan Nieder [this message]
2010-12-03 19:36 ` Dirk Süsserott
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=20101203192950.GA14561@burratino \
--to=jrnieder@gmail.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
--cc=trast@student.ethz.ch \
--cc=wpdster@gmail.com \
/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).