Skip to content

Commit 61def50

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 84b1aa8 commit 61def50

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
@@ -254,6 +254,11 @@ endif::git-pull[]
254254
'git-pull' the --ff-only option will still check for forced updates
255255
before attempting a fast-forward update. See linkgit:git-config[1].
256256

257+
--no-update-remote-refs::
258+
By default, git updates the `refs/remotes/` refspace with the refs
259+
advertised by the remotes during a `git fetch` command. With this
260+
option, those refs will be ignored.
261+
257262
-4::
258263
--ipv4::
259264
Use IPv4 addresses only, ignoring IPv6 addresses.

builtin/fetch.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ 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;
8282
static int fetch_write_commit_graph = -1;
83+
static int update_remote_refs = 1;
8384

8485
static int git_fetch_config(const char *k, const char *v, void *cb)
8586
{
@@ -203,6 +204,8 @@ static struct option builtin_fetch_options[] = {
203204
N_("check for forced-updates on all updated branches")),
204205
OPT_BOOL(0, "write-commit-graph", &fetch_write_commit_graph,
205206
N_("write the commit-graph after fetching")),
207+
OPT_BOOL(0, "update-remote-refs", &update_remote_refs,
208+
N_("update the refs/remotes/ refspace")),
206209
OPT_END()
207210
};
208211

@@ -748,6 +751,9 @@ static int update_local_ref(struct ref *ref,
748751
const char *pretty_ref = prettify_refname(ref->name);
749752
int fast_forward = 0;
750753

754+
if (!update_remote_refs && starts_with(ref->name, "refs/remotes/"))
755+
return 0;
756+
751757
type = oid_object_info(the_repository, &ref->new_oid, NULL);
752758
if (type < 0)
753759
die(_("object %s not found"), oid_to_hex(&ref->new_oid));

0 commit comments

Comments
 (0)