Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
git-backup
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
3
Issues
3
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
git-backup
Commits
cc6ac54f
Commit
cc6ac54f
authored
Jun 12, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pull: TODO on how to avoid O(n^2) on every `git fetch` for references
parent
3efed898
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
2 deletions
+20
-2
git-backup.go
git-backup.go
+20
-2
No files found.
git-backup.go
View file @
cc6ac54f
...
...
@@ -493,6 +493,24 @@ func cmd_pull_(gb *git.Repository, pullspecv []PullSpec) {
refv
,
_
,
err
:=
fetch
(
path
,
alreadyHave
)
exc
.
Raiseif
(
err
)
// TODO don't store to git references all references from fetched repository:
//
// We need to store to git references only references that were actually
// fetched - so that next fetch, e.g. from a fork that also has new data
// as its upstream, won't have to transfer what we just have fetched
// from upstream.
//
// For this purpose we can also save references by naming them as their
// sha1, not actual name, which will automatically deduplicate them in
// between several repositories, especially when/if pull will be made to
// work in parallel.
//
// Such changed-only deduplicated references should be O(δ) - usually only
// a few, and this way we will also automatically avoid O(n^2) behaviour
// of every git fetch scanning all local references at its startup.
//
// For backup.refs, we can generate it directly from refv of all fetched
// repositories saved in RAM.
reporefprefix
:=
backup_refs_work
+
// NOTE repo name is escaped as it can contain e.g. spaces, and refs must not
path_refescape
(
reprefix
(
dir
,
prefix
,
path
))
...
...
@@ -616,8 +634,8 @@ func cmd_pull_(gb *git.Repository, pullspecv []PullSpec) {
// TODO Revisit this when reworking fetch to be parallel. Reason is: in
// the process of pulling repositories, the more references we
// accumulate, the longer pull starts to be, so it becomes O(n^2).
//
We can avoid quadratic behaviour via removing refs from just
//
pulled repo right after the pu
ll.
//
//
-> what to do is described nearby fetch/mkref ca
ll.
gitdir
:=
xgit
(
"rev-parse"
,
"--git-dir"
)
err
=
os
.
RemoveAll
(
gitdir
+
"/"
+
backup_refs_work
)
exc
.
Raiseif
(
err
)
// NOTE err is nil if path does not exist
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment