Skip to content

git/githistory: introduce *refUpdater to update references#2340

Merged
ttaylorr merged 8 commits intomasterfrom
githistory-ref-updater
Jun 22, 2017
Merged

git/githistory: introduce *refUpdater to update references#2340
ttaylorr merged 8 commits intomasterfrom
githistory-ref-updater

Conversation

@ttaylorr
Copy link
Contributor

This pull request introduces a new type and option: *refUpdater and UpdateRefs bool, respectively.

In normal migrations up to this point ('info', so far) no commits are re-written, therefore no references need to be moved. However, 'import' (and 'export') migration will rewrite commits, and therefore the references in the original graph must be moved to their corresponding locations in the new graph.

The *refUpdater performs this transition. Given:

  • Refs []*git.Ref: A set of references to move (currently all references in the repository, see git: teach AllRefs() #2338 for discussion), and
  • CacheFn func(old []byte) ([]byte, bool): A function to return the migrated location of a given commit SHA1, or nil if the SHA1 was unmoved.

the *refUpdater iterates through all Refs given, and updates each reference if the SHA1 that reference is pointing to has moved. If the reference has moved, the *RefUpdater will create a reflog entry, as well as log to the *git/githistory/log.Logger instance (if one was given).

A few notes:

  • CacheFn is given from the *HistoryRewriter, since copying the map would be expensive (20*2*N(commits)), and using the existing map allows us to maintain the *sync.Mutex locking guarantees.
  • Refs is given to be all references in a repository, since displaying which refs point at a given commit in the output of git-rev-list(1) is difficult without using git-log(1), which isn't machine-readable. Git would be doing the same operation in the background (if --format="%D" is given to git-rev-list(1)), so the performance cost is that of spawning a new subprocess.

/cc @git-lfs/core
/cc #2146

@ttaylorr ttaylorr added this to the v2.2.0 milestone Jun 20, 2017
@ttaylorr ttaylorr requested a review from technoweenie June 20, 2017 16:55
@ttaylorr ttaylorr merged commit cdd17d0 into master Jun 22, 2017
@ttaylorr ttaylorr deleted the githistory-ref-updater branch June 22, 2017 00:55
chrisd8088 added a commit to chrisd8088/git-lfs that referenced this pull request Feb 25, 2025
The refUpdater structure and related methods were introduced to the
"githistory" package in PR git-lfs#2340, as part of the series of PRs that
implemented the "git lfs migrate" command.  The structure is not
exported outside of the package, as it is only used by the Rewrite()
method of the Rewriter structure in the same package.  (The Rewriter
structure and methods are the principal external interface of the
"githistory" package.)

While the structure itself is not exported, most of its elements are
exported, as is its UpdateRefs() method.  However, none of these are
referenced outside of the "githistory" package, so we rename them
now to clarify that they are only used within the package.
chrisd8088 added a commit to chrisd8088/git-lfs that referenced this pull request Feb 25, 2025
The refUpdater structure and related methods were introduced to the
"githistory" package in PR git-lfs#2340, as part of the series of PRs that
implemented the "git lfs migrate" command.  The structure is not
exported outside of the package, as it is only used by the Rewrite()
method of the Rewriter structure in the same package.  (The Rewriter
structure and methods are the principal external interface of the
"githistory" package.)

While the structure itself is not exported, most of its elements are
exported, as is its UpdateRefs() method.  However, none of these are
referenced outside of the "githistory" package, so we rename them
now to clarify that they are only used within the package.
chrisd8088 added a commit to chrisd8088/git-lfs that referenced this pull request Feb 25, 2025
The refUpdater structure and related methods were introduced to the
"githistory" package in PR git-lfs#2340, as part of the series of PRs that
implemented the "git lfs migrate" command.  The structure is not
exported outside of the package, as it is only used by the Rewrite()
method of the Rewriter structure in the same package.  (The Rewriter
structure and methods are the principal external interface of the
"githistory" package.)

While the structure itself is not exported, most of its elements are
exported, as is its UpdateRefs() method.  However, none of these are
referenced outside of the "githistory" package, so we rename them
now to clarify that they are only used within the package.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant