From: Jack Desert <hidden> Date: 2016-06-15 22:48:42
I think I found a bug in Git. When I run the command
git checkout -b new_branch
Git does exactly what I've asked, except that Git's response:
Switched to a new branch 'new_branch'
comes through the stderr pipe instead of through the stdout pipe. Where do I file a bug report for this?
I am using Git 1.6.3.3, Ubuntu 9.10
-Jack
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jack Desert -- Writer, Entrepeneur
Author and Spokesman: www.LetsEATalready.com
Software Developer: http://GrooveTask.org
Email: JackDesert556@gmail.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: Jacob Helwig <hidden> Date: 2016-06-15 22:48:42
On Sun, Apr 25, 2010 at 11:06, Jack Desert [off-list ref] wrote:
I think I found a bug in Git. When I run the command
git checkout -b new_branch
Git does exactly what I've asked, except that Git's response:
Switched to a new branch 'new_branch'
comes through the stderr pipe instead of through the stdout pipe. Where do I file a bug report for this?
I am using Git 1.6.3.3, Ubuntu 9.10
-Jack
I can't really say if it's actually a bug, or not, but as to your
question about where to file a bug report: You just did. This mailing
list is the correct place.
On Sun, Apr 25, 2010 at 18:10, Jacob Helwig [off-list ref] wrote:
I can't really say if it's actually a bug, or not, but as to your
question about where to file a bug report: You just did. This mailing
list is the correct place.
I've had some issues scripting `git fetch` because on error it'll
print to stdout and not stderr.
Are there some general guidelines for git's utilities that they follow
in this regard or does each tool just do its own thing?
From: Jack Desert <hidden> Date: 2016-06-15 22:48:42
El Sun, 25 Apr 2010 11:10:47 -0700
Jacob Helwig [off-list ref] escribió:
On Sun, Apr 25, 2010 at 11:06, Jack Desert [off-list ref] wrote:
quoted
I think I found a bug in Git. When I run the command
git checkout -b new_branch
Git does exactly what I've asked, except that Git's response:
Switched to a new branch 'new_branch'
comes through the stderr pipe instead of through the stdout pipe. Where do I file a bug report for this?
I am using Git 1.6.3.3, Ubuntu 9.10
-Jack
I can't really say if it's actually a bug, or not, but as to your
question about where to file a bug report: You just did. This mailing
list is the correct place.
I just finished testing with the latest development version and it has the same issue that 1.6.3.3 has in this regard.
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jack Desert -- Writer, Entrepeneur
Author and Spokesman: www.LetsEATalready.com
Software Developer: http://GrooveTask.org
Email: JackDesert556@gmail.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: Jeff King <hidden> Date: 2016-06-15 22:48:42
On Sun, Apr 25, 2010 at 06:24:43PM +0000, Ævar Arnfjörð Bjarmason wrote:
On Sun, Apr 25, 2010 at 18:10, Jacob Helwig [off-list ref] wrote:
quoted
I can't really say if it's actually a bug, or not, but as to your
question about where to file a bug report: You just did. This mailing
list is the correct place.
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?
Are there some general guidelines for git's utilities that they follow
in this regard or does each tool just do its own thing?
In practice, each tool does its own thing because they evolved
differently and from different authors. I think we are slowly converging
on similar behavior, though, as people fix warts. As to exactly what
that behavior is, I don't know that anybody has ever enumerated it
exactly. Verbose status and progress reports, especially human readable
ones, should probably always go to stderr.
The "Switched to a new branch" message that started this thread is
correct to go to stderr. If you want to silence the message but keep
stderr open for actual errors, the right way is to use "-q".
I tend to think the only thing that should go to stdout is the "main"
output of a command. For something like "ls-files", that is obviously
the list of files. For something like "checkout", which is about
changing the repository and not about querying it, I think there is
probably nothing that makes sense on stdout.
-Peff
On Sun, Apr 25, 2010 at 19:22, Jeff King [off-list ref] wrote:
On Sun, Apr 25, 2010 at 06:24:43PM +0000, Ævar Arnfjörð Bjarmason wrote:
quoted
On Sun, Apr 25, 2010 at 18:10, Jacob Helwig [off-list ref] wrote:
quoted
I can't really say if it's actually a bug, or not, but as to your
question about where to file a bug report: You just did. This mailing
list is the correct place.
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.
On Sun, Apr 25, 2010 at 19:32, Jeff King [off-list ref] wrote:
On Sun, Apr 25, 2010 at 07:32:00PM +0000, Ævar Arnfjörð Bjarmason wrote:
quoted
quoted
quoted
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), ...)
?
Change git-fetch to only print to stderr if it has encountered an
error.
A normal branch update (like "* branch HEAD -> FETCH_HEAD") is no
longer output to stderr but on stdout. Genuine errors (like
"[rejected]" messages) still go to stderr.
With this change I can run a cron script I've been developing
(http://github.com/avar/github-backup) without redirecting stderr to
/dev/null.
Before the change error messages were drowned out by git-fetch's
non-error update notices, which didn't need my attention.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
On Sat, Jun 12, 2010 at 16:52, Ævar Arnfjörð Bjarmason [off-list ref] wrote:
Shouldn't that fprintf() be called as:
fprintf((rc ? stderr : stdout), ...)
To answer my own question: Yes it should. This patch fixes git-fetch
so that it doesn't taint stderr with non-error messages.
The small changes to the test suite that this requires is a testiment
to how bad our test coverage is in this area. As far as I can see the
error messages that update_local_ref can emit aren't being tested
for. Fixing that is outside the scope of this patch, however.
builtin/fetch.c | 5 +++--
t/t5521-pull-options.sh | 12 ++++++------
2 files changed, 9 insertions(+), 8 deletions(-)
Change git-fetch to only print to stderr if it has encountered an
error. A normal branch update (like "* branch HEAD -> FETCH_HEAD") is
no longer output to stderr but on stdout. Genuine errors (like
"[rejected]" messages) still go to stderr.
With this change I can run a cron script I've been developing
(http://github.com/avar/github-backup) without redirecting stderr to
/dev/null.
Before the change error messages were drowned out by git-fetch's
non-error update notices, which didn't need my attention.
The changes in t/t5521-pull-options.sh invert the previously tested
for behavior of checking if normal messages are output on stderr. The
changes in t/t5510-fetch.sh however contain no behavioral changes,
just assertions that will break if git fetch's behavior is changed
again.
There still aren't tests for some of the errors output by
builtin/fetch.c's update_local_ref function.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
On Thu, Jun 24, 2010 at 22:34, Ævar Arnfjörð Bjarmason [off-list ref] wrote:
The small changes to the test suite that this requires is a testiment
to how bad our test coverage is in this area. As far as I can see the
error messages that update_local_ref can emit aren't being tested
for. Fixing that is outside the scope of this patch, however.
Here's an updated patch that has a some of those supposedly out of
scope tests. The new tests have the same behavior, but will start
breaking if this behavior is changed again.
builtin/fetch.c | 5 ++-
t/t5510-fetch.sh | 57 +++++++++++++++++++++++++++++++++-------------
t/t5521-pull-options.sh | 12 +++++-----
3 files changed, 50 insertions(+), 24 deletions(-)
@@ -81,7 +85,9 @@ test_expect_success 'fetch tags when there is no tags' 'cdnotags&&gitinit&&-gitfetch-t..+gitfetch-t..>out2>err&&+test!-serr&&+test!-sout'
@@ -95,7 +101,10 @@ test_expect_success 'fetch following tags' 'cdfour&&gitinit&&-gitfetch..:track&&+gitfetch..:track>out2>err&&+test!-serr&&+test-sout&&+gitshow-ref--verifyrefs/tags/anno&&gitshow-ref--verifyrefs/tags/light
@@ -109,8 +118,9 @@ test_expect_success 'fetch must not resolve short tag name' 'cdfive&&gitinit&&-test_must_failgitfetch..anno:five-+!gitfetch..anno:five>out2>err&&+test-serr&&+test!-sout' test_expect_success'fetch must not resolve short remote name''
@@ -122,7 +132,9 @@ test_expect_success 'fetch must not resolve short remote name' 'cdsix&&gitinit&&-test_must_failgitfetch..six:six+!gitfetch..six:six>out2>err&&+test-serr&&+test!-sout'
@@ -167,7 +181,9 @@ test_expect_success 'bundle 1 has only 3 files ' ' test_expect_success'unbundle 2''cd"$D/bundle"&&-gitfetch../bundle2master:master&&+gitfetch../bundle2master:master>out2>err&&+test!-serr&&+test-sout&&test"tip"="$(gitlog-1--pretty=onelinemaster|cut-b42-)"'
@@ -203,7 +219,9 @@ test_expect_success 'fetch via rsync' 'mkdirrsynced&&(cdrsynced&&gitinit--bare&&-gitfetch"rsync:$(pwd)/../.git"master:refs/heads/master&&+gitfetch"rsync:$(pwd)/../.git"master:refs/heads/master>out2>err&&+test!-serr&&+test-sout&&gitgc--prune&&test$(gitrev-parsemaster)=$(cd..&&gitrev-parsemaster)&&gitfsck--full)
@@ -237,14 +255,17 @@ test_expect_success 'fetch with a non-applying branch.<name>.merge' 'gitconfigbranch.master.mergerefs/heads/bigfoot&&gitconfigremote.blub.urlone&&gitconfigremote.blub.fetch"refs/heads/*:refs/remotes/one/*"&&-gitfetchblub+gitfetchblub>out2>err&&+test!-serr&&+test-sout'# the strange name is: a\!'b test_expect_success'quoting of a strangely named repo''-test_must_failgitfetch"a\\!'\''b">result2>&1&&-catresult&&-grep"fatal: '\''a\\\\!'\''b'\''"result+test_must_failgitfetch"a\\!'\''b">out2>err&&+test-serr&&+test!-sout&&+grep"fatal: '\''a\\\\!'\''b'\''"err' test_expect_success'bundle should record HEAD correctly''
@@ -267,7 +288,9 @@ test_expect_success 'explicit fetch should not update tracking' '(cdthree&&o=$(gitrev-parse--verifyrefs/remotes/origin/master)&&-gitfetchoriginmaster&&+gitfetchoriginmaster>out2>err&&+test!-serr&&+test-sout&&n=$(gitrev-parse--verifyrefs/remotes/origin/master)&&test"$o"="$n"&&test_must_failgitrev-parse--verifyrefs/remotes/origin/side