git/githistory: introduce *refUpdater to update references#2340
Merged
git/githistory: introduce *refUpdater to update references#2340
*refUpdater to update references#2340Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new type and option:
*refUpdaterandUpdateRefs 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
*refUpdaterperforms 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), andCacheFn 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
*refUpdateriterates through allRefsgiven, and updates each reference if the SHA1 that reference is pointing to has moved. If the reference has moved, the*RefUpdaterwill create a reflog entry, as well as log to the*git/githistory/log.Loggerinstance (if one was given).A few notes:
CacheFnis 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.Mutexlocking guarantees.Refsis given to be all references in a repository, since displaying which refs point at a given commit in the output ofgit-rev-list(1)is difficult without usinggit-log(1), which isn't machine-readable. Git would be doing the same operation in the background (if--format="%D"is given togit-rev-list(1)), so the performance cost is that of spawning a new subprocess./cc @git-lfs/core
/cc #2146