]> git.ipfire.org Git - thirdparty/git.git/commit
fetch: add configuration for set_head behaviour
authorBence Ferdinandy <bence@ferdinandy.com>
Thu, 28 Nov 2024 23:06:46 +0000 (00:06 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 2 Dec 2024 00:55:17 +0000 (09:55 +0900)
commitb7f7d16562c3c5af31d77254577e4afe9bf3e99a
treec5284b59c1dfe1664b4bf1e43422db445e2789a8
parent761e62a09a8248bbab065a7159977a5de6d12aba
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>
Documentation/config/remote.txt
builtin/fetch.c
remote.c
remote.h
t/t5510-fetch.sh