fetch: add configuration for set_head behaviour
In the current implementation, if refs/remotes/$remote/HEAD does not exist, running fetch will create it, but if it does exist it will not do anything, which is a somewhat safe and minimal approach. Unfortunately, for users who wish to NOT have refs/remotes/$remote/HEAD set for any reason (e.g. so that `git rev-parse origin` doesn't accidentally point them somewhere they do not want to), there is no way to remove this behaviour. On the other side of the spectrum, users may want fetch to automatically update HEAD or at least give them a warning if something changed on the remote. Introduce a new setting, remote.$remote.followRemoteHEAD with four options: - "never": do not ever do anything, not even create - "create": the current behaviour, now the default behaviour - "warn": print a message if remote and local HEAD is different - "always": silently update HEAD on every change Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
761e62a09a
commit
b7f7d16562
9
remote.h
9
remote.h
@ -59,6 +59,13 @@ struct remote_state {
|
||||
void remote_state_clear(struct remote_state *remote_state);
|
||||
struct remote_state *remote_state_new(void);
|
||||
|
||||
enum follow_remote_head_settings {
|
||||
FOLLOW_REMOTE_NEVER = -1,
|
||||
FOLLOW_REMOTE_CREATE = 0,
|
||||
FOLLOW_REMOTE_WARN = 1,
|
||||
FOLLOW_REMOTE_ALWAYS = 2,
|
||||
};
|
||||
|
||||
struct remote {
|
||||
struct hashmap_entry ent;
|
||||
|
||||
@ -107,6 +114,8 @@ struct remote {
|
||||
char *http_proxy_authmethod;
|
||||
|
||||
struct string_list server_options;
|
||||
|
||||
enum follow_remote_head_settings follow_remote_head;
|
||||
};
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user