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>
Nguyễn Thái Ngọc Duy committed
May 26, 2018 at 15:55 UTC
431bb23a271ef45e22ad4a2def2e0ba0a1954e98
4 files changed
+5
-6
advice.c
+2
@@ -17,6 +17,7 @@ int advice_implicit_identity = 1;
17
int advice_detached_head = 1;
18
int advice_set_upstream_failure = 1;
19
int advice_object_name_warning = 1;
20
+int advice_amworkdir = 1;
21
int advice_rm_hints = 1;
22
int advice_add_embedded_repo = 1;
23
int advice_ignored_hook = 1;
@@ -68,6 +69,7 @@ static struct {
69
{ "detachedHead", &advice_detached_head },
70
{ "setupStreamFailure", &advice_set_upstream_failure },
71
{ "objectNameWarning", &advice_object_name_warning },
72
+ { "amWorkDir", &advice_amworkdir },
73
{ "rmHints", &advice_rm_hints },
74
{ "addEmbeddedRepo", &advice_add_embedded_repo },
75
{ "ignoredHook", &advice_ignored_hook },
advice.h
+1
@@ -17,6 +17,7 @@ extern int advice_implicit_identity;
17
extern int advice_detached_head;
18
extern int advice_set_upstream_failure;
19
extern int advice_object_name_warning;
20
+extern int advice_amworkdir;
21
extern int advice_rm_hints;
22
extern int advice_add_embedded_repo;
23
extern int advice_ignored_hook;
builtin/am.c
+1
-5
@@ -1827,15 +1827,11 @@ static void am_run(struct am_state *state, int resume)
1827
}
1828
1829
if (apply_status) {
1830
- int advice_amworkdir = 1;
1831
-
1830
printf_ln(_("Patch failed at %s %.*s"), msgnum(state),
1831
linelen(state->msg), state->msg);
1832
1835
- git_config_get_bool("advice.amworkdir", &advice_amworkdir);
1836
-
1833
if (advice_amworkdir)
1838
- printf_ln(_("Use 'git am --show-current-patch' to see the failed patch"));
1834
+ advise(_("Use 'git am --show-current-patch' to see the failed patch"));
1835
1836
die_user_resolve(state);
1837
}
t/t4254-am-corrupt.sh
+1
-1
@@ -25,7 +25,7 @@ test_expect_success setup '
25
# fatal: unable to write file '(null)' mode 100644: Bad address
26
# Also, it had the unwanted side-effect of deleting f.
27
test_expect_success 'try to apply corrupted patch' '
28
- test_must_fail git am bad-patch.diff 2>actual
28
+ test_must_fail git -c advice.amWorkDir=false am bad-patch.diff 2>actual
29
'
30
31
test_expect_success 'compare diagnostic; ensure file is still here' '