Skip to content

git lfs migrate import --everything ignores malformed references silently #4810

@wuhaochen

Description

@wuhaochen

Describe the bug
We were trying to migrate a repo to git lfs which had a malformed local reference:
refs/head/some-description instead of refs/heads/some-description
After running git lfs migrate import everything that reference was ignored silently. Then when we tried to push it to the remote, it failed because we still have files larger than the size limit in that reference.

Root cause
In this part of the code

for _, ref := range refs {
switch ref.Type {
case git.RefTypeLocalBranch, git.RefTypeLocalTag,
git.RefTypeRemoteBranch:
include = append(include, ref.Refspec())
case git.RefTypeOther:
parts := strings.SplitN(ref.Refspec(), "/", 3)
if len(parts) < 2 {
continue
}
switch parts[1] {
// The following are GitLab-, GitHub-, VSTS-,
// and BitBucket-specific reference naming
// conventions.
case "merge-requests", "pull", "pull-requests":
include = append(include, ref.Refspec())
}
}
}

The reference was recognized as RefTypeOther and got skipped because it doesn't fit the case "merge-requests", "pull", "pull-requests"

Questions
I understand this is more of an user issue that caused by crazy input but when we are trying to automate things and migrate code bases in batch, errors like this is very hard to debug.
Would be better to give some warnings on the refs that was ignored?
Also is there any concern to just try to migrate all the refs with RefTypeOther?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions