git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Silent maintenance
@ 2010-08-14 13:11 Enrico Weigelt
  2010-08-14 13:26 ` Ævar Arnfjörð Bjarmason
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Enrico Weigelt @ 2010-08-14 13:11 UTC (permalink / raw)
  To: git

Hi,

are there some flags to make the maintenance commands like
git-repack and git-gc silent, so they only output errors ?


thx
-- 
----------------------------------------------------------------------
 Enrico Weigelt, metux IT service -- http://www.metux.de/

 phone:  +49 36207 519931  email: weigelt@metux.de
 mobile: +49 151 27565287  icq:   210169427         skype: nekrad666
----------------------------------------------------------------------
 Embedded-Linux / Portierung / Opensource-QM / Verteilte Systeme
----------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Silent maintenance
  2010-08-14 13:11 Silent maintenance Enrico Weigelt
@ 2010-08-14 13:26 ` Ævar Arnfjörð Bjarmason
  2010-08-14 16:33 ` Valeo de Vries
  2010-08-14 21:05 ` Jonathan Nieder
  2 siblings, 0 replies; 9+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2010-08-14 13:26 UTC (permalink / raw)
  To: weigelt, git

On Sat, Aug 14, 2010 at 13:11, Enrico Weigelt <weigelt@metux.de> wrote:
> 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?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Silent maintenance
  2010-08-14 13:11 Silent maintenance Enrico Weigelt
  2010-08-14 13:26 ` Ævar Arnfjörð Bjarmason
@ 2010-08-14 16:33 ` Valeo de Vries
  2010-08-14 16:41   ` Ævar Arnfjörð Bjarmason
  2010-08-14 21:05 ` Jonathan Nieder
  2 siblings, 1 reply; 9+ messages in thread
From: Valeo de Vries @ 2010-08-14 16:33 UTC (permalink / raw)
  To: weigelt, git

On 14 August 2010 14:11, Enrico Weigelt <weigelt@metux.de> wrote:
> 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Silent maintenance
  2010-08-14 16:33 ` Valeo de Vries
@ 2010-08-14 16:41   ` Ævar Arnfjörð Bjarmason
  0 siblings, 0 replies; 9+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2010-08-14 16:41 UTC (permalink / raw)
  To: Valeo de Vries; +Cc: weigelt, git

On Sat, Aug 14, 2010 at 16:33, Valeo de Vries <valeo@valeo.co.cc> wrote:
> On 14 August 2010 14:11, Enrico Weigelt <weigelt@metux.de> wrote:
>> 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.

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.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Silent maintenance
  2010-08-14 13:11 Silent maintenance Enrico Weigelt
  2010-08-14 13:26 ` Ævar Arnfjörð Bjarmason
  2010-08-14 16:33 ` Valeo de Vries
@ 2010-08-14 21:05 ` Jonathan Nieder
  2010-08-14 21:41   ` Ævar Arnfjörð Bjarmason
  2 siblings, 1 reply; 9+ messages in thread
From: Jonathan Nieder @ 2010-08-14 21:05 UTC (permalink / raw)
  To: git

Enrico Weigelt wrote:

> 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.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Silent maintenance
  2010-08-14 21:05 ` Jonathan Nieder
@ 2010-08-14 21:41   ` Ævar Arnfjörð Bjarmason
  2010-08-14 22:04     ` Jeff King
  0 siblings, 1 reply; 9+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2010-08-14 21:41 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: git

On Sat, Aug 14, 2010 at 21:05, Jonathan Nieder <jrnieder@gmail.com> wrote:
> Enrico Weigelt wrote:
>
>> 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.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Silent maintenance
  2010-08-14 21:41   ` Ævar Arnfjörð Bjarmason
@ 2010-08-14 22:04     ` Jeff King
  2010-08-15  0:21       ` Ævar Arnfjörð Bjarmason
  0 siblings, 1 reply; 9+ messages in thread
From: Jeff King @ 2010-08-14 22:04 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason; +Cc: Jonathan Nieder, git

On Sat, Aug 14, 2010 at 09:41:44PM +0000, Ævar Arnfjörð Bjarmason wrote:

> On Sat, Aug 14, 2010 at 21:05, Jonathan Nieder <jrnieder@gmail.com> wrote:
> > Enrico Weigelt wrote:
> >
> >> 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?

> 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Silent maintenance
  2010-08-14 22:04     ` Jeff King
@ 2010-08-15  0:21       ` Ævar Arnfjörð Bjarmason
  2010-08-15 13:12         ` Enrico Weigelt
  0 siblings, 1 reply; 9+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2010-08-15  0:21 UTC (permalink / raw)
  To: Jeff King; +Cc: Jonathan Nieder, git

On Sat, Aug 14, 2010 at 22:04, Jeff King <peff@peff.net> wrote:
> On Sat, Aug 14, 2010 at 09:41:44PM +0000, Ævar Arnfjörð Bjarmason wrote:
>
>> On Sat, Aug 14, 2010 at 21:05, Jonathan Nieder <jrnieder@gmail.com> wrote:
>> > Enrico Weigelt wrote:
>> >
>> >> 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?

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.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Silent maintenance
  2010-08-15  0:21       ` Ævar Arnfjörð Bjarmason
@ 2010-08-15 13:12         ` Enrico Weigelt
  0 siblings, 0 replies; 9+ messages in thread
From: Enrico Weigelt @ 2010-08-15 13:12 UTC (permalink / raw)
  To: git

* Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:

Hi folks,

> 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
-- 
----------------------------------------------------------------------
 Enrico Weigelt, metux IT service -- http://www.metux.de/

 phone:  +49 36207 519931  email: weigelt@metux.de
 mobile: +49 151 27565287  icq:   210169427         skype: nekrad666
----------------------------------------------------------------------
 Embedded-Linux / Portierung / Opensource-QM / Verteilte Systeme
----------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2010-08-15 15:22 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-14 13:11 Silent maintenance Enrico Weigelt
2010-08-14 13:26 ` Ævar Arnfjörð Bjarmason
2010-08-14 16:33 ` Valeo de Vries
2010-08-14 16:41   ` Ævar Arnfjörð Bjarmason
2010-08-14 21:05 ` Jonathan Nieder
2010-08-14 21:41   ` Ævar Arnfjörð Bjarmason
2010-08-14 22:04     ` Jeff King
2010-08-15  0:21       ` Ævar Arnfjörð Bjarmason
2010-08-15 13:12         ` Enrico Weigelt

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).