From: Todd Zullinger <tmz@pobox.com>
To: Johan Herland <johan@herland.net>
Cc: Junio C Hamano <gitster@pobox.com>,
Santiago Torres <santiago@nyu.edu>,
git@vger.kernel.org
Subject: [PATCH] notes: send "Automatic notes merge failed" messages to stderr
Date: Tue, 14 Nov 2017 11:17:52 -0500 [thread overview]
Message-ID: <20171114161752.13204-1-tmz@pobox.com> (raw)
In-Reply-To: <CALKQrgc427=JNkkH+k+EohgKYuJSBPbDNR3uUcmGuf_ZyQ0X4Q@mail.gmail.com>
All other error messages from notes use stderr. Do the same when
alerting users of an unresolved notes merge.
Fix the output redirection in t3310 and t3320 as well. Previously, the
tests directed output to a file, but stderr was either not captured or
not sent to the file due to the order of the redirection operators.
Signed-off-by: Todd Zullinger <tmz@pobox.com>
---
Johan Herland wrote:
> ACK :-)
>
> Error messages should go to stderr, and redirection in the tests
> should be fixed.
Excellent, thanks Johan!
Here's what I came up with. Hopefully I caught all the tests that need
adjustment. The test suite passes for me, but it's always possible that I've
missed something.
Style-wise, I'm not sure about the re-wrapping of the error message text. If
that should be avoided to make the patch's change from printf to fprintf
clearer or should be wrapped differently, let me know.
builtin/notes.c | 8 ++++----
t/t3310-notes-merge-manual-resolve.sh | 8 ++++----
t/t3320-notes-merge-worktrees.sh | 2 +-
3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/builtin/notes.c b/builtin/notes.c
index 12afdf1907..4468adaf29 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -865,10 +865,10 @@ static int merge(int argc, const char **argv, const char *prefix)
if (create_symref("NOTES_MERGE_REF", default_notes_ref(), NULL))
die(_("failed to store link to current notes ref (%s)"),
default_notes_ref());
- printf(_("Automatic notes merge failed. Fix conflicts in %s and "
- "commit the result with 'git notes merge --commit', or "
- "abort the merge with 'git notes merge --abort'.\n"),
- git_path(NOTES_MERGE_WORKTREE));
+ fprintf(stderr, _("Automatic notes merge failed. Fix conflicts in %s "
+ "and commit the result with 'git notes merge --commit', "
+ "or abort the merge with 'git notes merge --abort'.\n"),
+ git_path(NOTES_MERGE_WORKTREE));
}
free_notes(t);
diff --git a/t/t3310-notes-merge-manual-resolve.sh b/t/t3310-notes-merge-manual-resolve.sh
index baef2d6924..9c1bf6eb3d 100755
--- a/t/t3310-notes-merge-manual-resolve.sh
+++ b/t/t3310-notes-merge-manual-resolve.sh
@@ -176,7 +176,7 @@ git rev-parse refs/notes/z > pre_merge_z
test_expect_success 'merge z into m (== y) with default ("manual") resolver => Conflicting 3-way merge' '
git update-ref refs/notes/m refs/notes/y &&
git config core.notesRef refs/notes/m &&
- test_must_fail git notes merge z >output &&
+ test_must_fail git notes merge z >output 2>&1 &&
# Output should point to where to resolve conflicts
test_i18ngrep "\\.git/NOTES_MERGE_WORKTREE" output &&
# Inspect merge conflicts
@@ -379,7 +379,7 @@ git rev-parse refs/notes/z > pre_merge_z
test_expect_success 'redo merge of z into m (== y) with default ("manual") resolver => Conflicting 3-way merge' '
git update-ref refs/notes/m refs/notes/y &&
git config core.notesRef refs/notes/m &&
- test_must_fail git notes merge z >output &&
+ test_must_fail git notes merge z >output 2>&1 &&
# Output should point to where to resolve conflicts
test_i18ngrep "\\.git/NOTES_MERGE_WORKTREE" output &&
# Inspect merge conflicts
@@ -413,7 +413,7 @@ git rev-parse refs/notes/y > pre_merge_y
git rev-parse refs/notes/z > pre_merge_z
test_expect_success 'redo merge of z into m (== y) with default ("manual") resolver => Conflicting 3-way merge' '
- test_must_fail git notes merge z >output &&
+ test_must_fail git notes merge z >output 2>&1 &&
# Output should point to where to resolve conflicts
test_i18ngrep "\\.git/NOTES_MERGE_WORKTREE" output &&
# Inspect merge conflicts
@@ -494,7 +494,7 @@ cp expect_log_y expect_log_m
test_expect_success 'redo merge of z into m (== y) with default ("manual") resolver => Conflicting 3-way merge' '
git update-ref refs/notes/m refs/notes/y &&
- test_must_fail git notes merge z >output &&
+ test_must_fail git notes merge z >output 2>&1 &&
# Output should point to where to resolve conflicts
test_i18ngrep "\\.git/NOTES_MERGE_WORKTREE" output &&
# Inspect merge conflicts
diff --git a/t/t3320-notes-merge-worktrees.sh b/t/t3320-notes-merge-worktrees.sh
index b9c3bc2487..10bfc8b947 100755
--- a/t/t3320-notes-merge-worktrees.sh
+++ b/t/t3320-notes-merge-worktrees.sh
@@ -61,7 +61,7 @@ test_expect_success 'merge z into x while mid-merge on y succeeds' '
(
cd worktree2 &&
git config core.notesRef refs/notes/x &&
- test_must_fail git notes merge z 2>&1 >out &&
+ test_must_fail git notes merge z >out 2>&1 &&
test_i18ngrep "Automatic notes merge failed" out &&
grep -v "A notes merge into refs/notes/x is already in-progress in" out
) &&
--
2.15.0
next prev parent reply other threads:[~2017-11-14 16:17 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-13 21:07 [PATCH] t/lib-gpg: fix gpgconf stderr redirect to /dev/null Todd Zullinger
2017-11-13 22:18 ` Santiago Torres
2017-11-13 22:43 ` Todd Zullinger
2017-11-13 23:02 ` Santiago Torres
2017-11-13 23:06 ` Santiago Torres
2017-11-14 3:10 ` Todd Zullinger
2017-11-14 15:35 ` Santiago Torres
2017-11-14 2:49 ` Junio C Hamano
2017-11-14 3:03 ` Todd Zullinger
2017-11-14 3:30 ` Junio C Hamano
2017-11-14 5:15 ` Todd Zullinger
2017-11-14 9:31 ` Johan Herland
2017-11-14 14:52 ` Junio C Hamano
2017-11-14 16:17 ` Todd Zullinger [this message]
2017-11-15 13:13 ` [PATCH] notes: send "Automatic notes merge failed" messages to stderr Johan Herland
2017-11-15 21:09 ` Todd Zullinger
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=20171114161752.13204-1-tmz@pobox.com \
--to=tmz@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=johan@herland.net \
--cc=santiago@nyu.edu \
/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).