* How to "pre-populate" a git message
@ 2010-12-03 17:51 Patrick Doyle
2010-12-03 19:29 ` Jonathan Nieder
2010-12-03 19:36 ` Dirk Süsserott
0 siblings, 2 replies; 3+ messages in thread
From: Patrick Doyle @ 2010-12-03 17:51 UTC (permalink / raw)
To: git
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).
I also like to review the files before they get committed.
Is there any way I can "pre-populate" the commit message so that I can
run my "regenerate" command, review the differences, and then commit
the changes with my prewritten message?
--wpd
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How to "pre-populate" a git message
2010-12-03 17:51 How to "pre-populate" a git message Patrick Doyle
@ 2010-12-03 19:29 ` Jonathan Nieder
2010-12-03 19:36 ` Dirk Süsserott
1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Nieder @ 2010-12-03 19:29 UTC (permalink / raw)
To: Patrick Doyle; +Cc: git, Jeff King, Thomas Rast
(+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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How to "pre-populate" a git message
2010-12-03 17:51 How to "pre-populate" a git message Patrick Doyle
2010-12-03 19:29 ` Jonathan Nieder
@ 2010-12-03 19:36 ` Dirk Süsserott
1 sibling, 0 replies; 3+ messages in thread
From: Dirk Süsserott @ 2010-12-03 19:36 UTC (permalink / raw)
To: Patrick Doyle; +Cc: git
Am 03.12.2010 18:51 schrieb Patrick Doyle:
> Once in a while, I would like to run some scripts that will
> automatically generate some files that I keep maintained in my
> repository.
>
> I also like to review the files before they get committed.
>
> Is there any way I can "pre-populate" the commit message so that I can
> run my "regenerate" command, review the differences, and then commit
> the changes with my prewritten message?
>
> --wpd
You can either commit the changes with the "-m <msg>" or with the
"-F <file>" switch. In your case I'd suggest the latter:
1. regenerate your files and include a step that generates
a commit message and stores that in a file, say "commit.msg".
2. review the changes
3. add all your files (except for "commit.msg", of course)
4. commit:
$ git commit -F commit.msg
The other way would be the -m switch, but then you'd have to supply
the message by yourself somehow:
$ git commit -m "These files were generated at ..."
HTH,
Dirk
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-12-03 19:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-03 17:51 How to "pre-populate" a git message Patrick Doyle
2010-12-03 19:29 ` Jonathan Nieder
2010-12-03 19:36 ` Dirk Süsserott
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).