Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Cai <jcai@gitlab.com>2022-08-05 18:10:20 +0300
committerJohn Cai <jcai@gitlab.com>2022-08-05 18:10:20 +0300
commitc9c3a8b33af988bc027bea0a4e88637faa745741 (patch)
tree5f88eb5c6d70e17672eecffb63db8c3f7752afbb
parent14d427bf6de19d3403539002dc99214f27d49077 (diff)
parentc466baa1c30afd14838f8cba97c6bca958ecc3f1 (diff)
Merge branch 'pks-git-fetch-disable-show-forced-updates' into 'master'
git: Speed up fetches by disabling the logic to show forced updates Closes #4377 See merge request gitlab-org/gitaly!4783
-rw-r--r--internal/git/localrepo/remote.go17
-rw-r--r--internal/git/objectpool/fetch.go9
2 files changed, 26 insertions, 0 deletions
diff --git a/internal/git/localrepo/remote.go b/internal/git/localrepo/remote.go
index 53b1ce67e..236ef3363 100644
--- a/internal/git/localrepo/remote.go
+++ b/internal/git/localrepo/remote.go
@@ -81,6 +81,11 @@ func (repo *Repo) FetchRemote(ctx context.Context, remoteName string, opts Fetch
commandOptions := []git.CmdOpt{
git.WithEnv(opts.Env...),
git.WithStderr(opts.Stderr),
+ git.WithConfig(git.ConfigPair{
+ // Git is so kind to point out that we asked it to not show forced updates
+ // by default, so we need to ask it not to do that.
+ Key: "advice.fetchShowForcedUpdates", Value: "false",
+ }),
}
if opts.DisableTransactions {
commandOptions = append(commandOptions, git.WithDisabledHooks())
@@ -135,6 +140,11 @@ func (repo *Repo) FetchInternal(
GitProtocol: git.ProtocolV2,
},
),
+ git.WithConfig(git.ConfigPair{
+ // Git is so kind to point out that we asked it to not show forced updates
+ // by default, so we need to ask it not to do that.
+ Key: "advice.fetchShowForcedUpdates", Value: "false",
+ }),
}
if opts.DisableTransactions {
@@ -188,6 +198,13 @@ func (opts FetchOpts) buildFlags() []git.Option {
flags = append(flags, git.Flag{Name: "--atomic"})
}
+ // Even if we ask Git to not print any output and to force-update branches it will still
+ // compute whether branches have been force-updated only to discard that information again.
+ // Let's ask it not to given that this check can be quite expensive.
+ if !opts.Verbose && opts.Force {
+ flags = append(flags, git.Flag{Name: "--no-show-forced-updates"})
+ }
+
return flags
}
diff --git a/internal/git/objectpool/fetch.go b/internal/git/objectpool/fetch.go
index 0ee7d6d0a..8dcdfdee2 100644
--- a/internal/git/objectpool/fetch.go
+++ b/internal/git/objectpool/fetch.go
@@ -79,11 +79,20 @@ func (o *ObjectPool) FetchFromOrigin(ctx context.Context, origin *localrepo.Repo
// megabytes when doing a mirror-sync of repos with huge numbers of
// references.
git.Flag{Name: "--no-write-fetch-head"},
+ // Disable showing forced updates, which may take a considerable
+ // amount of time to compute. We don't display any output anyway,
+ // which makes this computation kind of moot.
+ git.Flag{Name: "--no-show-forced-updates"},
},
Args: []string{originPath, objectPoolRefspec},
},
git.WithRefTxHook(o.Repo),
git.WithStderr(&stderr),
+ git.WithConfig(git.ConfigPair{
+ // Git is so kind to point out that we asked it to not show forced updates
+ // by default, so we need to ask it not to do that.
+ Key: "advice.fetchShowForcedUpdates", Value: "false",
+ }),
); err != nil {
return fmt.Errorf("fetch into object pool: %w, stderr: %q", err,
stderr.String())