Skip to content

Commit 7f8481b

Browse files
committed
fetch: add --no-update-remote-refs
To allow running "git fetch" in the background, we want to ensure that users still see when the remote refs update in their user- facing fetch commands. Use a new --no-update-remote-refs option to prevent storing these updates to refs/remotes. Signed-off-by: Derrick Stolee <[email protected]>
1 parent d4f1186 commit 7f8481b

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

Documentation/fetch-options.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,11 @@ endif::git-pull[]
250250
'git-pull' the --ff-only option will still check for forced updates
251251
before attempting a fast-forward update. See linkgit:git-config[1].
252252

253+
--no-update-remote-refs::
254+
By default, git updates the `refs/remotes/` refspace with the refs
255+
advertised by the remotes during a `git fetch` command. With this
256+
option, those refs will be ignored.
257+
253258
-4::
254259
--ipv4::
255260
Use IPv4 addresses only, ignoring IPv6 addresses.

builtin/fetch.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ static struct refspec refmap = REFSPEC_INIT_FETCH;
7979
static struct list_objects_filter_options filter_options;
8080
static struct string_list server_options = STRING_LIST_INIT_DUP;
8181
static struct string_list negotiation_tip = STRING_LIST_INIT_NODUP;
82+
static int update_remote_refs = 1;
8283

8384
static int git_fetch_config(const char *k, const char *v, void *cb)
8485
{
@@ -200,6 +201,8 @@ static struct option builtin_fetch_options[] = {
200201
N_("run 'gc --auto' after fetching")),
201202
OPT_BOOL(0, "show-forced-updates", &fetch_show_forced_updates,
202203
N_("check for forced-updates on all updated branches")),
204+
OPT_BOOL(0, "update-remote-refs", &update_remote_refs,
205+
N_("update the refs/remotes/ refspace")),
203206
OPT_END()
204207
};
205208

@@ -745,6 +748,9 @@ static int update_local_ref(struct ref *ref,
745748
const char *pretty_ref = prettify_refname(ref->name);
746749
int fast_forward = 0;
747750

751+
if (!update_remote_refs && starts_with(ref->name, "refs/remotes/"))
752+
return 0;
753+
748754
type = oid_object_info(the_repository, &ref->new_oid, NULL);
749755
if (type < 0)
750756
die(_("object %s not found"), oid_to_hex(&ref->new_oid));

0 commit comments

Comments
 (0)