Browse Source

am: move advice.amWorkDir parsing back to advice.c

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>
maint
Nguyễn Thái Ngọc Duy 7 years ago committed by Junio C Hamano
parent
commit
431bb23a27
  1. 2
      advice.c
  2. 1
      advice.h
  3. 6
      builtin/am.c
  4. 2
      t/t4254-am-corrupt.sh

2
advice.c

@ -17,6 +17,7 @@ int advice_implicit_identity = 1; @@ -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;
@ -68,6 +69,7 @@ static struct { @@ -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 },

1
advice.h

@ -17,6 +17,7 @@ extern int advice_implicit_identity; @@ -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;

6
builtin/am.c

@ -1827,15 +1827,11 @@ static void am_run(struct am_state *state, int resume) @@ -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);
}

2
t/t4254-am-corrupt.sh

@ -25,7 +25,7 @@ test_expect_success setup ' @@ -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' '

Loading…
Cancel
Save