summaryrefslogtreecommitdiffstats
path: root/remote.c
diff options
context:
space:
mode:
authorBence Ferdinandy <bence@ferdinandy.com>2024-11-29 00:06:46 +0100
committerJunio C Hamano <gitster@pobox.com>2024-12-02 01:55:17 +0100
commitb7f7d16562c3c5af31d77254577e4afe9bf3e99a (patch)
treec5284b59c1dfe1664b4bf1e43422db445e2789a8 /remote.c
parentMerge branch 'bf/set-head-symref' into bf/fetch-set-head-config (diff)
downloadgit-b7f7d16562c3c5af31d77254577e4afe9bf3e99a.tar.xz
git-b7f7d16562c3c5af31d77254577e4afe9bf3e99a.zip
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>
Diffstat (limited to 'remote.c')
-rw-r--r--remote.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/remote.c b/remote.c
index 10104d11e3..0b18840d43 100644
--- a/remote.c
+++ b/remote.c
@@ -514,6 +514,15 @@ static int handle_config(const char *key, const char *value,
} else if (!strcmp(subkey, "serveroption")) {
return parse_transport_option(key, value,
&remote->server_options);
+ } else if (!strcmp(subkey, "followremotehead")) {
+ if (!strcmp(value, "never"))
+ remote->follow_remote_head = FOLLOW_REMOTE_NEVER;
+ else if (!strcmp(value, "create"))
+ remote->follow_remote_head = FOLLOW_REMOTE_CREATE;
+ else if (!strcmp(value, "warn"))
+ remote->follow_remote_head = FOLLOW_REMOTE_WARN;
+ else if (!strcmp(value, "always"))
+ remote->follow_remote_head = FOLLOW_REMOTE_ALWAYS;
}
return 0;
}