Silent maintenance
Hi,
are there some flags to make the maintenance commands like git-repack and git-gc silent, so they only output errors ?
thx
Signature · 8 lines
---------------------------------------------------------------------- Enrico Weigelt, metux IT service -- http://www.metux.de/ phone: +49 36207 519931 email: [email protected] mobile: +49 151 27565287 icq: 210169427 skype: nekrad666 ---------------------------------------------------------------------- Embedded-Linux / Portierung / Opensource-QM / Verteilte Systeme ----------------------------------------------------------------------
Quoted 2 lines · Enrico Weigelt
are there some flags to make the maintenance commands like git-repack and git-gc silent, so they only output errors ?
Does --quiet work? If not, patches would be welcome.
Quoted 6 lines · Jonathan Nieder
Quoted 2 lines · Enrico Weigelt
are there some flags to make the maintenance commands like git-repack and git-gc silent, so they only output errors ?
Does --quiet work? If not, patches would be welcome.
I intentionally neglected to mention that. That inevitably leads to cases where something fails, but you didn't record the output.
Instead (copy/paste from a recent post of mine to an unrelated mailing list, funny how these things come up at the same time), do:
Just install this: http://search.cpan.org/dist/App-Cronjob/
Then put something like this in your crontab:
@daily cronjob -E -j josm-build -E /path/to/build.sh
cronjob(1) will consume all the output, and either print it all or nothing, depending on the exit code of the program it's running.
If you're running a POSIX shell script you can add this to the top of the script:
# Exit on errors
trap 'fail' ERR
fail () {
code=$?
echo "Failed with exit code $code"
exit 1
}Then you don't have to check the exit code of everything individually.
I use this for all my cronjobs, see
e.g. http://github.com/avar/openstreetmap-mirror for an example, it's what I use to get E-Mails when the JOSM GitHub mirror fails, but *only* when it fails.
Quoted 10 lines · Ævar Arnfjörð Bjarmason
Quoted 6 lines · Jonathan Nieder
Quoted 2 lines · Enrico Weigelt
are there some flags to make the maintenance commands like git-repack and git-gc silent, so they only output errors ?
Does --quiet work? If not, patches would be welcome.
I intentionally neglected to mention that. That inevitably leads to cases where something fails, but you didn't record the output.
I'm confused. Isn't the point of quiet to silence all of the cruft, and leave only actual errors?
$ git gc Counting objects: 128, done. Compressing objects: 100% (49/49), done. Writing objects: 100% (128/128), done. Total 128 (delta 71), reused 121 (delta 68)
$ git gc --quiet
$ chmod -w .git/objects/pack $ git gc --quiet fatal: Unable to create temporary file: Permission denied error: failed to run repack
Isn't that what the OP wanted?
Quoted 2 lines
cronjob(1) will consume all the output, and either print it all or nothing, depending on the exit code of the program it's running.
That is a good solution for broken programs that have no "print only errors" mode, but I don't think git is one of those (and if it is, we should fix it).
-Peff
Quoted 22 lines · Jeff King
Quoted 10 lines · Ævar Arnfjörð Bjarmason
Quoted 6 lines · Jonathan Nieder
Quoted 2 lines · Enrico Weigelt
are there some flags to make the maintenance commands like git-repack and git-gc silent, so they only output errors ?
Does --quiet work? If not, patches would be welcome.
I intentionally neglected to mention that. That inevitably leads to cases where something fails, but you didn't record the output.
I'm confused. Isn't the point of quiet to silence all of the cruft, and leave only actual errors?
$ git gc Counting objects: 128, done. Compressing objects: 100% (49/49), done. Writing objects: 100% (128/128), done. Total 128 (delta 71), reused 121 (delta 68)
Quoted 8 lines
$ git gc --quiet$ chmod -w .git/objects/pack $ git gc --quiet fatal: Unable to create temporary file: Permission denied error: failed to run repackIsn't that what the OP wanted?
Maybe, personally I prefer to get all or nothing. If you specify --quiet you'll only get errors, so it doesn't give you much context. But if you use cronjob(1) you can see at a glance the normal output of all the successfully executed commands that led up to your failure.
E.g. the output of a successful "cherry-pick" right before a failing merge can be really helpful to see the state of the failing program.
* Ævar Arnfjörð Bjarmason <[email protected]> wrote:
Hi folks,
Quoted 5 lines
Maybe, personally I prefer to get all or nothing. If you specify --quiet you'll only get errors, so it doesn't give you much context. But if you use cronjob(1) you can see at a glance the normal output of all the successfully executed commands that led up to your failure.
for my purpose, this should be sufficient, as I'll have to step in manually in case of errors anyways.
thx to all.
cu
Signature · 8 lines
---------------------------------------------------------------------- Enrico Weigelt, metux IT service -- http://www.metux.de/ phone: +49 36207 519931 email: [email protected] mobile: +49 151 27565287 icq: 210169427 skype: nekrad666 ---------------------------------------------------------------------- Embedded-Linux / Portierung / Opensource-QM / Verteilte Systeme ----------------------------------------------------------------------
Quoted 4 lines · Enrico Weigelt
Hi,
are there some flags to make the maintenance commands like git-repack and git-gc silent, so they only output errors ?
Just redirect stdout to /dev/null and check git's return status, as Ævar said.
Valeo
Quoted 7 lines · Valeo de Vries
Quoted 4 lines · Enrico Weigelt
Hi,
are there some flags to make the maintenance commands like git-repack and git-gc silent, so they only output errors ?
Just redirect stdout to
/dev/nulland check git's return status, as Ęvar said.
It's better to not redirect anything, set a trap that checks if anything exited with non-zero, and then look at all the output if anything fails.
Quoted 2 lines · Enrico Weigelt
are there some flags to make the maintenance commands like git-repack and git-gc silent, so they only output errors ?
With Git you should check the exit code of commands, not if they're silent or not.
Are you running something via cron?