diff options
| author | Junio C Hamano <gitster@pobox.com> | 2024-12-19 10:58:29 -0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-12-19 10:58:30 -0800 |
| commit | a1f34d5955035dc64f2e25da0ba2cc0a0c73c21c (patch) | |
| tree | 0ef621c787630848212eb27671891bc9ba2a2a58 /builtin/remote.c | |
| parent | ae75cefd94075045edeb1d23283a47e4e48a9360 (diff) | |
| parent | 012bc566bad79876f4809d1e730a348b419772d0 (diff) | |
| download | git-a1f34d5955035dc64f2e25da0ba2cc0a0c73c21c.tar.gz | |
Merge branch 'bf/fetch-set-head-config'
"git fetch" honors "remote.<remote>.followRemoteHEAD" settings to
tweak the remote-tracking HEAD in "refs/remotes/<remote>/HEAD".
* bf/fetch-set-head-config:
remote set-head: set followRemoteHEAD to "warn" if "always"
fetch set_head: add warn-if-not-$branch option
fetch set_head: move warn advice into advise_if_enabled
fetch: add configuration for set_head behaviour
Diffstat (limited to 'builtin/remote.c')
| -rw-r--r-- | builtin/remote.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/builtin/remote.c b/builtin/remote.c index d5b81445f2..32d02ca4a0 100644 --- a/builtin/remote.c +++ b/builtin/remote.c @@ -1438,6 +1438,7 @@ static int set_head(int argc, const char **argv, const char *prefix, b_local_head = STRBUF_INIT; char *head_name = NULL; struct ref_store *refs = get_main_ref_store(the_repository); + struct remote *remote; struct option options[] = { OPT_BOOL('a', "auto", &opt_a, @@ -1448,8 +1449,10 @@ static int set_head(int argc, const char **argv, const char *prefix, }; argc = parse_options(argc, argv, prefix, options, builtin_remote_sethead_usage, 0); - if (argc) + if (argc) { strbuf_addf(&b_head, "refs/remotes/%s/HEAD", argv[0]); + remote = remote_get(argv[0]); + } if (!opt_a && !opt_d && argc == 2) { head_name = xstrdup(argv[1]); @@ -1488,6 +1491,13 @@ static int set_head(int argc, const char **argv, const char *prefix, } if (opt_a) report_set_head_auto(argv[0], head_name, &b_local_head, was_detached); + if (remote->follow_remote_head == FOLLOW_REMOTE_ALWAYS) { + struct strbuf config_name = STRBUF_INIT; + strbuf_addf(&config_name, + "remote.%s.followremotehead", remote->name); + git_config_set(config_name.buf, "warn"); + strbuf_release(&config_name); + } cleanup: free(head_name); |
