2009-09-09 19:38:58 +08:00
|
|
|
#ifndef ADVICE_H
|
|
|
|
#define ADVICE_H
|
|
|
|
|
2021-04-09 04:41:27 +08:00
|
|
|
struct string_list;
|
|
|
|
|
2020-03-03 04:01:59 +08: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.
|
|
|
|
*/
|
advice: fix an unexpected leading space
This space was introduced, presumably unintentionally, in b3b18d1621
(advice: revamp advise API, 2020-03-02)
I notice this space due to confuse diff outputs while doing some
changes to enum advice_type.
As a reference, a recent change we have to that enum is:
$ git show 35f0383
...
diff --git a/advice.h b/advice.h
index 0f584163f5..2affbe1426 100644
--- a/advice.h
+++ b/advice.h
@@ -49,6 +49,7 @@ struct string_list;
ADVICE_UPDATE_SPARSE_PATH,
ADVICE_WAITING_FOR_EDITOR,
ADVICE_SKIPPED_CHERRY_PICKS,
+ ADVICE_WORKTREE_ADD_ORPHAN,
};
Note the hunk header, instead of a much more expected:
@@ -49,6 +49,7 @@ enum advice_type
Signed-off-by: Rubén Justo <rjusto@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-01-11 20:40:17 +08:00
|
|
|
enum advice_type {
|
2020-03-03 04:01:59 +08:00
|
|
|
ADVICE_ADD_EMBEDDED_REPO,
|
2021-08-23 18:43:59 +08:00
|
|
|
ADVICE_ADD_EMPTY_PATHSPEC,
|
|
|
|
ADVICE_ADD_IGNORED_FILE,
|
2022-04-01 14:05:13 +08:00
|
|
|
ADVICE_AMBIGUOUS_FETCH_REFSPEC,
|
2024-01-11 20:40:01 +08:00
|
|
|
ADVICE_AM_WORK_DIR,
|
2020-03-03 04:01:59 +08:00
|
|
|
ADVICE_CHECKOUT_AMBIGUOUS_REMOTE_BRANCH_NAME,
|
|
|
|
ADVICE_COMMIT_BEFORE_MERGE,
|
|
|
|
ADVICE_DETACHED_HEAD,
|
2023-03-08 10:48:33 +08:00
|
|
|
ADVICE_DIVERGING,
|
2020-03-03 04:01:59 +08:00
|
|
|
ADVICE_FETCH_SHOW_FORCED_UPDATES,
|
2024-01-11 20:40:34 +08:00
|
|
|
ADVICE_FORCE_DELETE_BRANCH,
|
2020-03-03 04:01:59 +08:00
|
|
|
ADVICE_GRAFT_FILE_DEPRECATED,
|
|
|
|
ADVICE_IGNORED_HOOK,
|
|
|
|
ADVICE_IMPLICIT_IDENTITY,
|
2024-03-17 05:16:29 +08:00
|
|
|
ADVICE_MERGE_CONFLICT,
|
2020-03-03 04:01:59 +08:00
|
|
|
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,
|
2024-01-11 20:40:01 +08:00
|
|
|
ADVICE_PUSH_REF_NEEDS_UPDATE,
|
2020-03-03 04:01:59 +08:00
|
|
|
ADVICE_PUSH_UNQUALIFIED_REF_NAME,
|
|
|
|
ADVICE_PUSH_UPDATE_REJECTED,
|
2024-01-11 20:40:01 +08:00
|
|
|
ADVICE_PUSH_UPDATE_REJECTED_ALIAS,
|
2024-05-30 21:43:50 +08:00
|
|
|
ADVICE_REBASE_TODO_ERROR,
|
2024-03-06 04:29:43 +08:00
|
|
|
ADVICE_REF_SYNTAX,
|
2022-03-15 09:49:40 +08:00
|
|
|
ADVICE_RESET_NO_REFRESH_WARNING,
|
2020-03-03 04:01:59 +08:00
|
|
|
ADVICE_RESOLVE_CONFLICT,
|
|
|
|
ADVICE_RM_HINTS,
|
|
|
|
ADVICE_SEQUENCER_IN_USE,
|
|
|
|
ADVICE_SET_UPSTREAM_FAILURE,
|
2024-01-11 20:40:01 +08:00
|
|
|
ADVICE_SKIPPED_CHERRY_PICKS,
|
advice: warn when sparse index expands
Typically, forcing a sparse index to expand to a full index means that
Git could not determine the status of a file outside of the
sparse-checkout and needed to expand sparse trees into the full list of
sparse blobs. This operation can be very slow when the sparse-checkout
is much smaller than the full tree at HEAD.
When users are in this state, there is usually a modified or untracked
file outside of the sparse-checkout mentioned by the output of 'git
status'. There are a number of reasons why this is insufficient:
1. Users may not have a full understanding of which files are inside or
outside of their sparse-checkout. This is more common in monorepos
that manage the sparse-checkout using custom tools that map build
dependencies into sparse-checkout definitions.
2. In some cases, an empty directory could exist outside the
sparse-checkout and these empty directories are not reported by 'git
status' and friends.
3. If the user has '.gitignore' or 'exclude' files, then 'git status'
will squelch the warnings and not demonstrate any problems.
In order to help users who are in this state, add a new advice message
to indicate that a sparse index is expanded to a full index. This
message should be written at most once per process, so add a static
global 'give_advice_on_expansion' to sparse-index.c. Further, there is a
case in 'git sparse-checkout set' that uses the sparse index as an
in-memory data structure (even when writing a full index) so we need to
disable the message in that kind of case.
The t1092-sparse-checkout-compatibility.sh test script compares the
behavior of several Git commands across full and sparse repositories,
including sparse repositories with and without a sparse index. We need
to disable the advice in the sparse-index repo to avoid differences in
stderr. By leaving the advice on in the sparse-checkout repo (without
the sparse index), we can test the behavior of disabling the advice in
convert_to_sparse(). (Indeed, these tests are how that necessity was
discovered.) Add a test that reenables the advice and demonstrates that
the message is output.
The advice message is defined outside of expand_index() to avoid super-
wide lines. It is also defined as a macro to avoid compile issues with
-Werror=format-security.
Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-07-08 22:13:58 +08:00
|
|
|
ADVICE_SPARSE_INDEX_EXPANDED,
|
2020-03-03 04:01:59 +08:00
|
|
|
ADVICE_STATUS_AHEAD_BEHIND_WARNING,
|
|
|
|
ADVICE_STATUS_HINTS,
|
|
|
|
ADVICE_STATUS_U_OPTION,
|
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 08:04:45 +08:00
|
|
|
ADVICE_SUBMODULES_NOT_UPDATED,
|
2024-01-11 20:40:01 +08:00
|
|
|
ADVICE_SUBMODULE_ALTERNATE_ERROR_STRATEGY_DIE,
|
2024-02-26 21:27:28 +08:00
|
|
|
ADVICE_SUBMODULE_MERGE_CONFLICT,
|
2024-01-11 20:40:01 +08:00
|
|
|
ADVICE_SUGGEST_DETACHING_HEAD,
|
2021-04-09 04:41:27 +08:00
|
|
|
ADVICE_UPDATE_SPARSE_PATH,
|
2020-03-03 04:01:59 +08:00
|
|
|
ADVICE_WAITING_FOR_EDITOR,
|
2023-05-18 05:48:52 +08:00
|
|
|
ADVICE_WORKTREE_ADD_ORPHAN,
|
2020-03-03 04:01:59 +08:00
|
|
|
};
|
|
|
|
|
2009-09-09 19:38:58 +08:00
|
|
|
int git_default_advice_config(const char *var, const char *value);
|
2013-07-10 08:18:40 +08:00
|
|
|
__attribute__((format (printf, 1, 2)))
|
2011-08-04 18:38:59 +08:00
|
|
|
void advise(const char *advice, ...);
|
2020-03-03 04:01:59 +08: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 16:05:20 +08:00
|
|
|
__attribute__((format (printf, 2, 3)))
|
2020-03-03 04:01:59 +08:00
|
|
|
void advise_if_enabled(enum advice_type type, const char *advice, ...);
|
|
|
|
|
2011-08-04 18:38:59 +08:00
|
|
|
int error_resolve_conflict(const char *me);
|
2019-04-29 16:28:14 +08:00
|
|
|
void NORETURN die_resolve_conflict(const char *me);
|
2015-06-18 18:54:04 +08:00
|
|
|
void NORETURN die_conclude_merge(void);
|
2021-07-21 09:42:19 +08:00
|
|
|
void NORETURN die_ff_impossible(void);
|
2021-04-09 04:41:27 +08:00
|
|
|
void advise_on_updating_sparse_paths(struct string_list *pathspec_list);
|
2012-01-16 17:46:16 +08:00
|
|
|
void detach_advice(const char *new_name);
|
2022-08-09 20:09:09 +08:00
|
|
|
void advise_on_moving_dirty_path(struct string_list *pathspec_list);
|
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 17:54:44 +08:00
|
|
|
|
2009-09-09 19:38:58 +08:00
|
|
|
#endif /* ADVICE_H */
|