sbt / sbt/sbt-git

MissingObjectException in repos with git alternates

Open
#178 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
355
Forks
104
Avg merge
1d 4h
Merged PRs (30d)
4

Description

It seems JGit's RevWalk doesn't support Git alternates. This leads to sbt-git being unable to load projects checked out by TeamCity's VCS root that has "Use mirrors" mechanism enabled. For example,

$ pwd
/data/buildagent/work/aee92f3311be76c5

$ ls .git/objects/a8/04e5fbec3088c2890667aa46712c96b02b5dea
ls: cannot access .git/objects/a8/04e5fbec3088c2890667aa46712c96b02b5dea: No such file or directory

$ cat .git/objects/info/alternates
/data/homedir/buildAgent/system/git/git-0C318551.git/objects

$ ls /data/homedir/buildAgent/system/git/git-0C318551.git/objects/a8/04e5fbec3088c2890667aa46712c96b02b5dea
/data/homedir/buildAgent/system/git/git-0C318551.git/objects/a8/04e5fbec3088c2890667aa46712c96b02b5dea
org.eclipse.jgit.errors.MissingObjectException: Missing unknown a804e5fbec3088c2890667aa46712c96b02b5dea
at org.eclipse.jgit.internal.storage.file.WindowCursor.open(WindowCursor.java:163)
at org.eclipse.jgit.lib.ObjectReader.open(ObjectReader.java:234)
at org.eclipse.jgit.revwalk.RevWalk.parseAny(RevWalk.java:859)
at org.eclipse.jgit.revwalk.RevWalk.parseCommit(RevWalk.java:772)
at com.typesafe.sbt.git.JGit.$anonfun$headCommitDate$1(JGit.scala:115)
at scala.Option.map(Option.scala:230)
at com.typesafe.sbt.git.JGit.headCommitDate(JGit.scala:114)
at com.typesafe.sbt.SbtGit$.$anonfun$buildSettings$8(SbtGit.scala:117)
at com.typesafe.sbt.git.DefaultReadableGit.withGit(ReadableGit.scala:42)
at com.typesafe.sbt.SbtGit$.$anonfun$buildSettings$7(SbtGit.scala:117)
at scala.Function1.$anonfun$compose$1(Function1.scala:49)
at sbt.internal.util.EvaluateSettings$MixedNode.evaluate0(INode.scala:228)
at sbt.internal.util.EvaluateSettings$INode.evaluate(INode.scala:170)
at sbt.internal.util.EvaluateSettings.$anonfun$submitEvaluate$1(INode.scala:87)
at sbt.internal.util.EvaluateSettings.sbt$internal$util$EvaluateSettings$$run0(INode.scala:99)
at sbt.internal.util.EvaluateSettings$$anon$3.run(INode.scala:94)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in JGit.scala at headCommitDate, where the stack trace shows RevWalk failing to find an object from a repository using .git/objects/info/alternates. Read how the repository and object reader are initialized, then reproduce the TeamCity-style layout. Done means sbt-git can load the project and resolve the referenced commit without MissingObjectException.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, scala
Domain
build-system, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.