git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Jeff King <peff@peff.net>
Cc: Jacob Helwig <jacob.helwig@gmail.com>,
	Jack Desert <jackdesert556@gmail.com>,
	git@vger.kernel.org
Subject: Re: Bugreport: Git responds with stderr instead of stdout
Date: Sat, 12 Jun 2010 16:52:34 +0000	[thread overview]
Message-ID: <AANLkTingtgeWuTrocesTIhTPsVz4dfU8CbwZF1TEl6AI@mail.gmail.com> (raw)
In-Reply-To: <20100425193258.GA16171@coredump.intra.peff.net>

On Sun, Apr 25, 2010 at 19:32, Jeff King <peff@peff.net> wrote:
> On Sun, Apr 25, 2010 at 07:32:00PM +0000, Ævar Arnfjörð Bjarmason wrote:
>
>> >> I've had some issues scripting `git fetch` because on error it'll
>> >> print to stdout and not stderr.
>> >
>> > Errors should go to stderr, so I imagine patches would be welcome. Which
>> > messages went to stdout?
>>
>> I can't recall exactly now. Looking at fetch.c I can't see anything
>> obvious, I'll report anything if I spot it in the future.
>
> Thanks. As I mentioned, we've been fixing little things like this as
> time goes on, so it may well have been fixed already.

Actually here's an example with Git 1.7.1:

    # time /etc/github-backup/github-backup
    remote: Counting objects: 76, done.
    remote: Compressing objects: 100% (43/43), done.
    remote: Total 47 (delta 26), reused 18 (delta 4)
    Unpacking objects: 100% (47/47), done.
    From github.com:avar/linode-etc
       75a27cf..09d5ff7  master     -> origin/master
    From github.com:avar/svn-dump-fast-export
     * [new branch]      gh-pages   -> origin/gh-pages
     * [new branch]      git-merge  -> origin/git-merge
     * [new branch]      master     -> origin/master
     * [new branch]      rollout    -> origin/rollout

The script I'm running is github-backup
(http://github.com/avar/github-backup) which just outputs `git fetch`
output as-is.

Looking at the source the problematic code is in builtin/fetch.c's
update_local_ref. That function takes a char *display which it writes
to things that are both errors and just status messages:

Error:

		sprintf(display, "! %-*s %-*s -> %s  (can't fetch in current branch)",
			TRANSPORT_SUMMARY_WIDTH, "[rejected]", REFCOL_WIDTH, remote,
			pretty_ref);

Just a status message (in my case):

		else {
			msg = "storing head";
			what = "[new branch]";
		}

		r = s_update_ref(msg, ref, 0);
		sprintf(display, "%c %-*s %-*s -> %s%s", r ? '!' : '*',
			TRANSPORT_SUMMARY_WIDTH, what, REFCOL_WIDTH, remote, pretty_ref,
			r ? "  (unable to update local ref)" : "");

That function is then called as:

		if (ref) {
			rc |= update_local_ref(ref, what, note);
			free(ref);
		} else
			sprintf(note, "* %-*s %-*s -> FETCH_HEAD",
				TRANSPORT_SUMMARY_WIDTH, *kind ? kind : "branch",
				 REFCOL_WIDTH, *what ? what : "HEAD");
		if (*note) {
			if (verbosity >= 0 && !shown_url) {
				fprintf(stderr, "From %.*s\n",
						url_len, url);
				shown_url = 1;
			}
			if (verbosity >= 0)
				fprintf(stderr, " %s\n", note);
		}

Shouldn't that fprintf() be called as:

    fprintf((rc ? stderr : stdout), ...)

?

  reply	other threads:[~2010-06-12 16:52 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-25 18:06 Bugreport: Git responds with stderr instead of stdout Jack Desert
2010-04-25 18:10 ` Jacob Helwig
2010-04-25 18:24   ` Ævar Arnfjörð Bjarmason
2010-04-25 19:22     ` Jeff King
2010-04-25 19:32       ` Ævar Arnfjörð Bjarmason
2010-04-25 19:32         ` Jeff King
2010-06-12 16:52           ` Ævar Arnfjörð Bjarmason [this message]
2010-06-24 22:34             ` [PATCH] fetch: don't output non-errors on stderr Ævar Arnfjörð Bjarmason
2010-06-25 13:30               ` [PATCH v2] " Ævar Arnfjörð Bjarmason
2010-06-25 17:25               ` [PATCH] " Junio C Hamano
2010-06-25 21:28                 ` Ævar Arnfjörð Bjarmason
2010-06-25 21:43                   ` Junio C Hamano
2010-06-26  6:13                     ` Jeff King
2010-06-26 12:14                       ` Ævar Arnfjörð Bjarmason
2010-06-26 13:40                         ` Tay Ray Chuan
2010-06-26 15:07                           ` Ævar Arnfjörð Bjarmason
2010-06-26 16:46                         ` Jeff King
2010-06-26 16:50                           ` Ævar Arnfjörð Bjarmason
2010-04-25 18:34   ` Bugreport: Git responds with stderr instead of stdout Jack Desert

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=AANLkTingtgeWuTrocesTIhTPsVz4dfU8CbwZF1TEl6AI@mail.gmail.com \
    --to=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=jackdesert556@gmail.com \
    --cc=jacob.helwig@gmail.com \
    --cc=peff@peff.net \
    /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).