Skip to content

Bad revision fatal error when .git is a symbolic link with symbolic links inside #5426

@MarekPikula

Description

@MarekPikula

Describe the bug

I'm migrating Android repo tree from Gerrit to GitHub and I need to convert some repositories to LFS due to the file size limit. Android uses the repo tool for repository management, which uses symbolic links for .git and directories inside .git for a given repo.

For example .git points to ../../../../../.repo/projects/xyz/core.git/ and inside of it:

-rw-r--r-- 1 docker docker    414 May 12 11:49 .repo_config.json
-rw-r--r-- 1 docker docker    176 Jul 13 21:30 FETCH_HEAD
-rw-r--r-- 1 docker docker     25 Jul 13 21:30 HEAD
drwxr-xr-x 1 docker docker      0 May 12 11:45 branches/
-rw-r--r-- 1 docker docker    408 Jul 13 21:30 config
lrwxrwxrwx 1 docker docker     70 May 12 11:45 description -> ../../../../../../project-objects/platform/system/core.git/description
lrwxrwxrwx 1 docker docker     64 May 12 11:45 hooks -> ../../../../../../project-objects/platform/system/core.git/hooks/
-rw-r--r-- 1 docker docker 215946 Jul 13 21:30 index
lrwxrwxrwx 1 docker docker     63 May 12 11:45 info -> ../../../../../../project-objects/platform/system/core.git/info/
drwxr-xr-x 1 docker docker     16 Jun  7 19:35 logs/
lrwxrwxrwx 1 docker docker     66 May 12 11:45 objects -> ../../../../../../project-objects/platform/system/core.git/objects/
-rw-r--r-- 1 docker docker     39 May 12 11:49 packed-refs
drwxr-xr-x 1 docker docker     32 May 12 12:05 refs/
lrwxrwxrwx 1 docker docker     67 May 12 11:45 rr-cache -> ../../../../../../project-objects/platform/system/core.git/rr-cache/
lrwxrwxrwx 1 docker docker     62 May 12 11:45 svn -> ../../../../../../project-objects/platform/system/core.git/svn/

When trying to perform any git lfs migrate operation, it fails with:

$ git lfs migrate info --skip-fetch
Error in git rev-list --reverse --topo-order --do-walk --stdin --: exit status 128 fatal: bad revision 'refs/heads/upstream'

Once I copy the .git with cp -rL git-lfs works as expected.

To Reproduce
Steps to reproduce the behavior:

  1. Clone a repository, e.g., with the repo tool, so that .git is a relative symlink and all directories inside are relative symlinks.
  2. Try to run git lfs migrate info --skip-fetch

Expected behavior
Migrate tool works.

System environment

Bare metal Ubuntu 22.04.2 LTS

Output of git lfs env

git-lfs/3.0.2 (GitHub; linux amd64; go 1.18.1)
git version 2.34.1

Endpoint (upstream)=xxx/platform/system/core.git/info/lfs (auth=none)
  SSH=xxx:/platform/system/core
Endpoint (github)=xxx/platform_system_core.git/info/lfs (auth=none)
  SSH=xxx/platform_system_core.git
LocalWorkingDir=/opt/src/xxx/LINUX/android/system/core
LocalGitDir=/opt/src/.repo/projects/xxx/LINUX/android/system/core.git
LocalGitStorageDir=/opt/src/.repo/projects/xxx/LINUX/android/system/core.git
LocalMediaDir=/opt/src/.repo/projects/xxx/LINUX/android/system/core.git/lfs/objects
LocalReferenceDirs=
TempDir=/opt/src/.repo/projects/xxx/LINUX/android/system/core.git/lfs/tmp
ConcurrentTransfers=8
TusTransfers=false
BasicTransfersOnly=false
SkipDownloadErrors=false
FetchRecentAlways=false
FetchRecentRefsDays=7
FetchRecentCommitsDays=0
FetchRecentRefsIncludeRemotes=true
PruneOffsetDays=3
PruneVerifyRemoteAlways=false
PruneRemoteName=origin
LfsStorageDir=/opt/src/.repo/projects/xxx/LINUX/android/system/core.git/lfs
AccessDownload=none
AccessUpload=none
DownloadTransfers=basic,lfs-standalone-file,ssh
UploadTransfers=basic,lfs-standalone-file,ssh
GIT_EXEC_PATH=/usr/lib/git-core
git config filter.lfs.process = "git-lfs filter-process"
git config filter.lfs.smudge = "git-lfs smudge -- %f"
git config filter.lfs.clean = "git-lfs clean -- %f"

Additional context

--

Metadata

Metadata

Assignees

No one assigned

    Labels

    migrationRelated to `git lfs migrate`

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions