Skip to content

git/githistory: only update local refs#2559

Merged
ttaylorr merged 1 commit intomasterfrom
git-githistory-update-local-refs-only
Sep 7, 2017
Merged

git/githistory: only update local refs#2559
ttaylorr merged 1 commit intomasterfrom
git-githistory-update-local-refs-only

Conversation

@ttaylorr
Copy link
Contributor

@ttaylorr ttaylorr commented Sep 7, 2017

This pull request fixes a correctness issue with ref-updating migration modes where non-local refs would be moved in certain cases.

The problem with moving non-local references is that it is only correct if a 'git push' has been accepted against the remote which owns that reference. For example, if I update my copy of refs/remotes/origin/master, but don't actually push master to that remote, my copy of refs/remotes/origin/master is out of sync.

This can happen when running migrations that update local references which point to the same SHA-1 as a remote reference.

  • When migrating, maintain a cache of old SHA-1's to the points on the graph that they moved to (i.e., I migrated commit X to a new commit of SHA-1 "Y".)
  • Once migration is complete, iterate through all references in a repository.
  • For each reference, lookup the translated location of the SHA-1 that the reference currently points at, and issue a git update-ref creating a reflog entry and moving the reference.

Given the above, if refs/heads/master was migrated (and pointed to the same SHA-1 as refs/remotes/origin/master at the time that the migration occurred) refs/remotes/origin/master will also be migrated, which is incorrect until git push origin master has completed.

To address this, modify the git/githistory.Rewriter to only pass local references to the *refUpdater type, thus not modifying remote references.


/cc @git-lfs/core

@ttaylorr ttaylorr added the review label Sep 7, 2017
@ttaylorr ttaylorr added this to the v2.3.0 milestone Sep 7, 2017
@ttaylorr ttaylorr requested a review from rubyist September 7, 2017 18:00
@ttaylorr ttaylorr merged commit bd06ae8 into master Sep 7, 2017
@ttaylorr ttaylorr deleted the git-githistory-update-local-refs-only branch September 7, 2017 20:38
chrisd8088 added a commit to chrisd8088/git-lfs that referenced this pull request Mar 31, 2023
When using the "git lfs migrate" with its --everything option, all
commits reachable from any refs, local or remote, are considered
for migration; however, per PR git-lfs#2559, only local refs are updated
after the migration to avoid desynchronizing remote refs with the
origin.

We therefore clarify this distinction in the command's manual page,
as well as clarifying that the "git push" command's --all option
refers only to local branches.
chrisd8088 added a commit to chrisd8088/git-lfs that referenced this pull request Mar 31, 2023
When using the "git lfs migrate" command with its --everything option,
all commits reachable from any refs, local or remote, are considered
for migration; however, per PR git-lfs#2559, only local refs are updated
after the migration to avoid desynchronizing remote refs with the
origin.

We therefore clarify this distinction in the command's manual page,
as well as clarifying that the "git push" command's --all option
refers only to local branches.
@Marramp
Copy link

Marramp commented Oct 31, 2023

Mmm

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.

3 participants