2009-09-09 15:38:58 +04:00
|
|
|
#ifndef ADVICE_H
|
|
|
|
#define ADVICE_H
|
|
|
|
|
Be more user-friendly when refusing to do something because of conflict.
Various commands refuse to run in the presence of conflicts (commit,
merge, pull, cherry-pick/revert). They all used to provide rough, and
inconsistant error messages.
A new variable advice.resolveconflict is introduced, and allows more
verbose messages, pointing the user to the appropriate solution.
For commit, the error message used to look like this:
$ git commit
foo.txt: needs merge
foo.txt: unmerged (c34a92682e0394bc0d6f4d4a67a8e2d32395c169)
foo.txt: unmerged (3afcd75de8de0bb5076942fcb17446be50451030)
foo.txt: unmerged (c9785d77b76dfe4fb038bf927ee518f6ae45ede4)
error: Error building trees
The "need merge" line is given by refresh_cache. We add the IN_PORCELAIN
option to make the output more consistant with the other porcelain
commands, and catch the error in return, to stop with a clean error
message. The next lines were displayed by a call to cache_tree_update(),
which is not reached anymore if we noticed the conflict.
The new output looks like:
U foo.txt
fatal: 'commit' is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>' as
appropriate to mark resolution and make a commit, or use 'git commit -a'.
Pull is slightly modified to abort immediately if $GIT_DIR/MERGE_HEAD
exists instead of waiting for merge to complain.
The behavior of merge and the test-case are slightly modified to reflect
the usual flow: start with conflicts, fix them, and afterwards get rid of
MERGE_HEAD, with different error messages at each stage.
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-12 12:54:44 +03:00
|
|
|
#include "git-compat-util.h"
|
|
|
|
|
2021-04-08 23:41:27 +03:00
|
|
|
struct string_list;
|
|
|
|
|
2020-03-02 23:01:59 +03:00
|
|
|
/*
|
|
|
|
* To add a new advice, you need to:
|
|
|
|
* Define a new advice_type.
|
|
|
|
* Add a new entry to advice_setting array.
|
|
|
|
* Add the new config variable to Documentation/config/advice.txt.
|
|
|
|
* Call advise_if_enabled to print your advice.
|
|
|
|
*/
|
|
|
|
enum advice_type {
|
|
|
|
ADVICE_ADD_EMBEDDED_REPO,
|
2021-08-23 13:43:59 +03:00
|
|
|
ADVICE_ADD_EMPTY_PATHSPEC,
|
|
|
|
ADVICE_ADD_IGNORED_FILE,
|
2020-03-02 23:01:59 +03:00
|
|
|
ADVICE_AM_WORK_DIR,
|
|
|
|
ADVICE_CHECKOUT_AMBIGUOUS_REMOTE_BRANCH_NAME,
|
|
|
|
ADVICE_COMMIT_BEFORE_MERGE,
|
|
|
|
ADVICE_DETACHED_HEAD,
|
|
|
|
ADVICE_FETCH_SHOW_FORCED_UPDATES,
|
|
|
|
ADVICE_GRAFT_FILE_DEPRECATED,
|
|
|
|
ADVICE_IGNORED_HOOK,
|
|
|
|
ADVICE_IMPLICIT_IDENTITY,
|
|
|
|
ADVICE_NESTED_TAG,
|
|
|
|
ADVICE_OBJECT_NAME_WARNING,
|
|
|
|
ADVICE_PUSH_ALREADY_EXISTS,
|
|
|
|
ADVICE_PUSH_FETCH_FIRST,
|
|
|
|
ADVICE_PUSH_NEEDS_FORCE,
|
|
|
|
ADVICE_PUSH_NON_FF_CURRENT,
|
|
|
|
ADVICE_PUSH_NON_FF_MATCHING,
|
|
|
|
ADVICE_PUSH_UNQUALIFIED_REF_NAME,
|
|
|
|
ADVICE_PUSH_UPDATE_REJECTED_ALIAS,
|
|
|
|
ADVICE_PUSH_UPDATE_REJECTED,
|
2020-10-03 15:10:45 +03:00
|
|
|
ADVICE_PUSH_REF_NEEDS_UPDATE,
|
2020-03-02 23:01:59 +03:00
|
|
|
ADVICE_RESET_QUIET_WARNING,
|
|
|
|
ADVICE_RESOLVE_CONFLICT,
|
|
|
|
ADVICE_RM_HINTS,
|
|
|
|
ADVICE_SEQUENCER_IN_USE,
|
|
|
|
ADVICE_SET_UPSTREAM_FAILURE,
|
|
|
|
ADVICE_STATUS_AHEAD_BEHIND_WARNING,
|
|
|
|
ADVICE_STATUS_HINTS,
|
|
|
|
ADVICE_STATUS_U_OPTION,
|
|
|
|
ADVICE_SUBMODULE_ALTERNATE_ERROR_STRATEGY_DIE,
|
2021-04-08 23:41:27 +03:00
|
|
|
ADVICE_UPDATE_SPARSE_PATH,
|
2020-03-02 23:01:59 +03:00
|
|
|
ADVICE_WAITING_FOR_EDITOR,
|
2021-08-31 00:46:02 +03:00
|
|
|
ADVICE_SKIPPED_CHERRY_PICKS,
|
2020-03-02 23:01:59 +03:00
|
|
|
};
|
|
|
|
|
2009-09-09 15:38:58 +04:00
|
|
|
int git_default_advice_config(const char *var, const char *value);
|
2013-07-10 04:18:40 +04:00
|
|
|
__attribute__((format (printf, 1, 2)))
|
2011-08-04 14:38:59 +04:00
|
|
|
void advise(const char *advice, ...);
|
2020-03-02 23:01:59 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if advice type is enabled (can be printed to the user).
|
|
|
|
* Should be called before advise().
|
|
|
|
*/
|
|
|
|
int advice_enabled(enum advice_type type);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks the visibility of the advice before printing.
|
|
|
|
*/
|
2021-07-13 11:05:20 +03:00
|
|
|
__attribute__((format (printf, 2, 3)))
|
2020-03-02 23:01:59 +03:00
|
|
|
void advise_if_enabled(enum advice_type type, const char *advice, ...);
|
|
|
|
|
2011-08-04 14:38:59 +04:00
|
|
|
int error_resolve_conflict(const char *me);
|
2019-04-29 11:28:14 +03:00
|
|
|
void NORETURN die_resolve_conflict(const char *me);
|
2015-06-18 13:54:04 +03:00
|
|
|
void NORETURN die_conclude_merge(void);
|
2021-07-21 04:42:19 +03:00
|
|
|
void NORETURN die_ff_impossible(void);
|
2021-04-08 23:41:27 +03:00
|
|
|
void advise_on_updating_sparse_paths(struct string_list *pathspec_list);
|
2012-01-16 13:46:16 +04:00
|
|
|
void detach_advice(const char *new_name);
|
Be more user-friendly when refusing to do something because of conflict.
Various commands refuse to run in the presence of conflicts (commit,
merge, pull, cherry-pick/revert). They all used to provide rough, and
inconsistant error messages.
A new variable advice.resolveconflict is introduced, and allows more
verbose messages, pointing the user to the appropriate solution.
For commit, the error message used to look like this:
$ git commit
foo.txt: needs merge
foo.txt: unmerged (c34a92682e0394bc0d6f4d4a67a8e2d32395c169)
foo.txt: unmerged (3afcd75de8de0bb5076942fcb17446be50451030)
foo.txt: unmerged (c9785d77b76dfe4fb038bf927ee518f6ae45ede4)
error: Error building trees
The "need merge" line is given by refresh_cache. We add the IN_PORCELAIN
option to make the output more consistant with the other porcelain
commands, and catch the error in return, to stop with a clean error
message. The next lines were displayed by a call to cache_tree_update(),
which is not reached anymore if we noticed the conflict.
The new output looks like:
U foo.txt
fatal: 'commit' is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>' as
appropriate to mark resolution and make a commit, or use 'git commit -a'.
Pull is slightly modified to abort immediately if $GIT_DIR/MERGE_HEAD
exists instead of waiting for merge to complain.
The behavior of merge and the test-case are slightly modified to reflect
the usual flow: start with conflicts, fix them, and afterwards get rid of
MERGE_HEAD, with different error messages at each stage.
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-12 12:54:44 +03:00
|
|
|
|
2009-09-09 15:38:58 +04:00
|
|
|
#endif /* ADVICE_H */
|