Skip to content

Commit

Permalink
fetch: add --no-update-remote-refs
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
derrickstolee committed Dec 30, 2019
1 parent ec41d16 commit 1182245
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Documentation/fetch-options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,11 @@ endif::git-pull[]
'git-pull' the --ff-only option will still check for forced updates
before attempting a fast-forward update. See linkgit:git-config[1].

--no-update-remote-refs::
By default, git updates the `refs/remotes/` refspace with the refs
advertised by the remotes during a `git fetch` command. With this
option, those refs will be ignored.

-4::
--ipv4::
Use IPv4 addresses only, ignoring IPv6 addresses.
Expand Down
6 changes: 6 additions & 0 deletions builtin/fetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ static struct list_objects_filter_options filter_options;
static struct string_list server_options = STRING_LIST_INIT_DUP;
static struct string_list negotiation_tip = STRING_LIST_INIT_NODUP;
static int fetch_write_commit_graph = -1;
static int update_remote_refs = 1;

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

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

if (!update_remote_refs && starts_with(ref->name, "refs/remotes/"))
return 0;

type = oid_object_info(the_repository, &ref->new_oid, NULL);
if (type < 0)
die(_("object %s not found"), oid_to_hex(&ref->new_oid));
Expand Down

0 comments on commit 1182245

Please sign in to comment.