2009-09-09 13:38:58 +02: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 10:54:44 +01:00
|
|
|
#include "git-compat-util.h"
|
|
|
|
|
2021-04-08 22:41:27 +02:00
|
|
|
struct string_list;
|
|
|
|
|
2020-03-02 21:01:59 +01: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 12:43:59 +02:00
|
|
|
ADVICE_ADD_EMPTY_PATHSPEC,
|
|
|
|
ADVICE_ADD_IGNORED_FILE,
|
2020-03-02 21:01:59 +01:00
|
|
|
ADVICE_AM_WORK_DIR,
|
|
|
|
ADVICE_CHECKOUT_AMBIGUOUS_REMOTE_BRANCH_NAME,
|
|
|
|
ADVICE_COMMIT_BEFORE_MERGE,
|
|
|
|
ADVICE_DETACHED_HEAD,
|
2022-02-26 07:12:13 +01:00
|
|
|
ADVICE_SUGGEST_DETACHING_HEAD,
|
2020-03-02 21:01:59 +01:00
|
|
|
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 14:10:45 +02:00
|
|
|
ADVICE_PUSH_REF_NEEDS_UPDATE,
|
2020-03-02 21:01:59 +01: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,
|
branch: add --recurse-submodules option for branch creation
To improve the submodules UX, we would like to teach Git to handle
branches in submodules. Start this process by teaching "git branch" the
--recurse-submodules option so that "git branch --recurse-submodules
topic" will create the `topic` branch in the superproject and its
submodules.
Although this commit does not introduce breaking changes, it does not
work well with existing --recurse-submodules commands because "git
branch --recurse-submodules" writes to the submodule ref store, but most
commands only consider the superproject gitlink and ignore the submodule
ref store. For example, "git checkout --recurse-submodules" will check
out the commits in the superproject gitlinks (and put the submodules in
detached HEAD) instead of checking out the submodule branches.
Because of this, this commit introduces a new configuration value,
`submodule.propagateBranches`. The plan is for Git commands to
prioritize submodule ref store information over superproject gitlinks if
this value is true. Because "git branch --recurse-submodules" writes to
submodule ref stores, for the sake of clarity, it will not function
unless this configuration value is set.
This commit also includes changes that support working with submodules
from a superproject commit because "branch --recurse-submodules" (and
future commands) need to read .gitmodules and gitlinks from the
superproject commit, but submodules are typically read from the
filesystem's .gitmodules and the index's gitlinks. These changes are:
* add a submodules_of_tree() helper that gives the relevant
information of an in-tree submodule (e.g. path and oid) and
initializes the repository
* add is_tree_submodule_active() by adding a treeish_name parameter to
is_submodule_active()
* add the "submoduleNotUpdated" advice to advise users to update the
submodules in their trees
Incidentally, fix an incorrect usage string that combined the 'list'
usage of git branch (-l) with the 'create' usage; this string has been
incorrect since its inception, a8dfd5eac4 (Make builtin-branch.c use
parse_options., 2007-10-07).
Helped-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Glen Choo <chooglen@google.com>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-01-29 01:04:45 +01:00
|
|
|
ADVICE_SUBMODULES_NOT_UPDATED,
|
2021-04-08 22:41:27 +02:00
|
|
|
ADVICE_UPDATE_SPARSE_PATH,
|
2020-03-02 21:01:59 +01:00
|
|
|
ADVICE_WAITING_FOR_EDITOR,
|
2021-08-30 23:46:02 +02:00
|
|
|
ADVICE_SKIPPED_CHERRY_PICKS,
|
2020-03-02 21:01:59 +01:00
|
|
|
};
|
|
|
|
|
2009-09-09 13:38:58 +02:00
|
|
|
int git_default_advice_config(const char *var, const char *value);
|
2013-07-10 02:18:40 +02:00
|
|
|
__attribute__((format (printf, 1, 2)))
|
2011-08-04 12:38:59 +02:00
|
|
|
void advise(const char *advice, ...);
|
2020-03-02 21:01:59 +01: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 10:05:20 +02:00
|
|
|
__attribute__((format (printf, 2, 3)))
|
2020-03-02 21:01:59 +01:00
|
|
|
void advise_if_enabled(enum advice_type type, const char *advice, ...);
|
|
|
|
|
2011-08-04 12:38:59 +02:00
|
|
|
int error_resolve_conflict(const char *me);
|
2019-04-29 10:28:14 +02:00
|
|
|
void NORETURN die_resolve_conflict(const char *me);
|
2015-06-18 12:54:04 +02:00
|
|
|
void NORETURN die_conclude_merge(void);
|
2021-07-21 03:42:19 +02:00
|
|
|
void NORETURN die_ff_impossible(void);
|
2021-04-08 22:41:27 +02:00
|
|
|
void advise_on_updating_sparse_paths(struct string_list *pathspec_list);
|
2012-01-16 10:46:16 +01: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 10:54:44 +01:00
|
|
|
|
2009-09-09 13:38:58 +02:00
|
|
|
#endif /* ADVICE_H */
|