Skip to content

Commit

Permalink
am: move advice.amWorkDir parsing back to advice.c
Browse files Browse the repository at this point in the history
The only benefit from this move (apart from cleaner code) is that
advice.amWorkDir should now show up in `git help --config`. There
should be no regression since advice config is always read by the
git_default_config().

While at there, use advise() like other code. We now get "hint: "
prefix and the output is stderr instead of stdout (which is also the
reason for the test update because stderr is checked in a following
test and the extra advice can fail it).

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
pclouds authored and gitster committed May 29, 2018
1 parent fb6fbff commit 431bb23
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
2 changes: 2 additions & 0 deletions advice.c
Expand Up @@ -17,6 +17,7 @@ int advice_implicit_identity = 1;
int advice_detached_head = 1;
int advice_set_upstream_failure = 1;
int advice_object_name_warning = 1;
int advice_amworkdir = 1;
int advice_rm_hints = 1;
int advice_add_embedded_repo = 1;
int advice_ignored_hook = 1;
Expand Down Expand Up @@ -68,6 +69,7 @@ static struct {
{ "detachedHead", &advice_detached_head },
{ "setupStreamFailure", &advice_set_upstream_failure },
{ "objectNameWarning", &advice_object_name_warning },
{ "amWorkDir", &advice_amworkdir },
{ "rmHints", &advice_rm_hints },
{ "addEmbeddedRepo", &advice_add_embedded_repo },
{ "ignoredHook", &advice_ignored_hook },
Expand Down
1 change: 1 addition & 0 deletions advice.h
Expand Up @@ -17,6 +17,7 @@ extern int advice_implicit_identity;
extern int advice_detached_head;
extern int advice_set_upstream_failure;
extern int advice_object_name_warning;
extern int advice_amworkdir;
extern int advice_rm_hints;
extern int advice_add_embedded_repo;
extern int advice_ignored_hook;
Expand Down
6 changes: 1 addition & 5 deletions builtin/am.c
Expand Up @@ -1827,15 +1827,11 @@ static void am_run(struct am_state *state, int resume)
}

if (apply_status) {
int advice_amworkdir = 1;

printf_ln(_("Patch failed at %s %.*s"), msgnum(state),
linelen(state->msg), state->msg);

git_config_get_bool("advice.amworkdir", &advice_amworkdir);

if (advice_amworkdir)
printf_ln(_("Use 'git am --show-current-patch' to see the failed patch"));
advise(_("Use 'git am --show-current-patch' to see the failed patch"));

die_user_resolve(state);
}
Expand Down
2 changes: 1 addition & 1 deletion t/t4254-am-corrupt.sh
Expand Up @@ -25,7 +25,7 @@ test_expect_success setup '
# fatal: unable to write file '(null)' mode 100644: Bad address
# Also, it had the unwanted side-effect of deleting f.
test_expect_success 'try to apply corrupted patch' '
test_must_fail git am bad-patch.diff 2>actual
test_must_fail git -c advice.amWorkDir=false am bad-patch.diff 2>actual
'

test_expect_success 'compare diagnostic; ensure file is still here' '
Expand Down

0 comments on commit 431bb23

Please sign in to comment.