]> git.ipfire.org Git - thirdparty/git.git/commit
fetch set_head: add warn-if-not-$branch option
authorBence Ferdinandy <bence@ferdinandy.com>
Thu, 5 Dec 2024 12:16:21 +0000 (13:16 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 5 Dec 2024 17:59:40 +0000 (02:59 +0900)
commit9e2b7005becaf730ff75f6efbef4542cc4454107
tree75b4750235ec9903939b4f3655cacbf8b03c472b
parentad739f525eec917198887055f1a815e78d7c66be
fetch set_head: add warn-if-not-$branch option

Currently if we want to have a remote/HEAD locally that is different
from the one on the remote, but we still want to get a warning if remote
changes HEAD, our only option is to have an indiscriminate warning with
"follow_remote_head" set to "warn". Add a new option
"warn-if-not-$branch", where $branch is a branch name we do not wish to
get a warning about. If the remote HEAD is $branch do not warn,
otherwise, behave as "warn".

E.g. let's assume, that our remote origin has HEAD
set to "master", but locally we have "git remote set-head origin seen".
Setting 'remote.origin.followRemoteHEAD = "warn"' will always print
a warning, even though the remote has not changed HEAD from "master".
Setting 'remote.origin.followRemoteHEAD = "warn-if-not-master" will
squelch the warning message, unless the remote changes HEAD from
"master". Note, that should the remote change HEAD to "seen" (which we
have locally), there will still be no warning.

Improve the advice message in report_set_head to also include silencing
the warning message with "warn-if-not-$branch".

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