Skip to content

Commit 431bb23

Browse files
pcloudsgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fb6fbff commit 431bb23

File tree

4 files changed

+5
-6
lines changed

4 files changed

+5
-6
lines changed

advice.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ int advice_implicit_identity = 1;
1717
int advice_detached_head = 1;
1818
int advice_set_upstream_failure = 1;
1919
int advice_object_name_warning = 1;
20+
int advice_amworkdir = 1;
2021
int advice_rm_hints = 1;
2122
int advice_add_embedded_repo = 1;
2223
int advice_ignored_hook = 1;
@@ -68,6 +69,7 @@ static struct {
6869
{ "detachedHead", &advice_detached_head },
6970
{ "setupStreamFailure", &advice_set_upstream_failure },
7071
{ "objectNameWarning", &advice_object_name_warning },
72+
{ "amWorkDir", &advice_amworkdir },
7173
{ "rmHints", &advice_rm_hints },
7274
{ "addEmbeddedRepo", &advice_add_embedded_repo },
7375
{ "ignoredHook", &advice_ignored_hook },

advice.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ extern int advice_implicit_identity;
1717
extern int advice_detached_head;
1818
extern int advice_set_upstream_failure;
1919
extern int advice_object_name_warning;
20+
extern int advice_amworkdir;
2021
extern int advice_rm_hints;
2122
extern int advice_add_embedded_repo;
2223
extern int advice_ignored_hook;

builtin/am.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1827,15 +1827,11 @@ static void am_run(struct am_state *state, int resume)
18271827
}
18281828

18291829
if (apply_status) {
1830-
int advice_amworkdir = 1;
1831-
18321830
printf_ln(_("Patch failed at %s %.*s"), msgnum(state),
18331831
linelen(state->msg), state->msg);
18341832

1835-
git_config_get_bool("advice.amworkdir", &advice_amworkdir);
1836-
18371833
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"));
18391835

18401836
die_user_resolve(state);
18411837
}

t/t4254-am-corrupt.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ test_expect_success setup '
2525
# fatal: unable to write file '(null)' mode 100644: Bad address
2626
# Also, it had the unwanted side-effect of deleting f.
2727
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
2929
'
3030

3131
test_expect_success 'compare diagnostic; ensure file is still here' '

0 commit comments

Comments
 (0)