mirror of
https://github.com/git/git.git
synced 2024-11-01 06:47:52 +01:00
532139940c
It's an easy mistake to add a repository inside another repository, like: git clone $url git add . The resulting entry is a gitlink, but there's no matching .gitmodules entry. Trying to use "submodule init" (or clone with --recursive) doesn't do anything useful. Prior to v2.13, such an entry caused git-submodule to barf entirely. In v2.13, the entry is considered "inactive" and quietly ignored. Either way, no clone of your repository can do anything useful with the gitlink without the user manually adding the submodule config. In most cases, the user probably meant to either add a real submodule, or they forgot to put the embedded repository in their .gitignore file. Let's issue a warning when we see this case. There are a few things to note: - the warning will go in the git-add porcelain; anybody wanting to do low-level manipulation of the index is welcome to create whatever funny states they want. - we detect the case by looking for a newly added gitlink; updates via "git add submodule" are perfectly reasonable, and this avoids us having to investigate .gitmodules entirely - there's a command-line option to suppress the warning. This is needed for git-submodule itself (which adds the entry before adding any submodule config), but also provides a mechanism for other scripts doing submodule-like things. We could make this a hard error instead of a warning. However, we do add lots of sub-repos in our test suite. It's not _wrong_ to do so. It just creates a state where users may be surprised. Pointing them in the right direction with a gentle hint is probably the best option. There is a config knob that can disable the (long) hint. But I intentionally omitted a config knob to disable the warning entirely. Whether the warning is sensible or not is generally about context, not about the user's preferences. If there's a tool or workflow that adds gitlinks without matching .gitmodules, it should probably be taught about the new command-line option, rather than blanket-disabling the warning. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
31 lines
1,004 B
C
31 lines
1,004 B
C
#ifndef ADVICE_H
|
|
#define ADVICE_H
|
|
|
|
#include "git-compat-util.h"
|
|
|
|
extern int advice_push_update_rejected;
|
|
extern int advice_push_non_ff_current;
|
|
extern int advice_push_non_ff_matching;
|
|
extern int advice_push_already_exists;
|
|
extern int advice_push_fetch_first;
|
|
extern int advice_push_needs_force;
|
|
extern int advice_status_hints;
|
|
extern int advice_status_u_option;
|
|
extern int advice_commit_before_merge;
|
|
extern int advice_resolve_conflict;
|
|
extern int advice_implicit_identity;
|
|
extern int advice_detached_head;
|
|
extern int advice_set_upstream_failure;
|
|
extern int advice_object_name_warning;
|
|
extern int advice_rm_hints;
|
|
extern int advice_add_embedded_repo;
|
|
|
|
int git_default_advice_config(const char *var, const char *value);
|
|
__attribute__((format (printf, 1, 2)))
|
|
void advise(const char *advice, ...);
|
|
int error_resolve_conflict(const char *me);
|
|
extern void NORETURN die_resolve_conflict(const char *me);
|
|
void NORETURN die_conclude_merge(void);
|
|
void detach_advice(const char *new_name);
|
|
|
|
#endif /* ADVICE_H */
|