Skip to content

fix: build git 2.56.1 from the official source tarball [TAR-265] - #78

Merged
lolgab merged 4 commits into
masterfrom
fix/git-from-source
Nov 26, 2026
Merged

lolgab merged 4 commits into
masterfrom
fix/git-from-source

Conversation

@lolgab

@lolgab lolgab commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Base 7.0.1 (Amazon Linux 2023) replaced the git-core PPA build (git 2.56.1) with AL2023's git-core rpm, which is git 2.50.1 and has no newer version in any maintained rpm repo. After repository-listener 17.6.16 picked it up, git fetch into the listener's partial clones (--filter=tree:0 / blob:none) started failing in prod with BUG: builtin/pack-objects.c:4453: should_include_obj should only be called on existing objects. That line is the 2.50.x position of the check run by index-pack --promisor → pack-objects --exclude-promisor-objects-best-effort. TAR-265

  • git is built from the kernel.org release tarball, with the version and sha256 pinned in the Makefile (sha256 cross-checked against kernel.org's sha256sums.asc on two mirrors).
  • It is built with NO_RUST (Rust stays optional until Git 3.0) and downloaded from cdn.kernel.org, with mirrors.edge.kernel.org as fallback.
  • It installs under /usr, so /usr/bin/git and /etc/gitconfig stay where the rpm put them.
  • docker_verify fails unless the image reports exactly the pinned git version, and runs a git ls-remote over https.

Trade-off: Docker Scout doesn't see a source-built git, so git CVEs no longer fail docker_scan. Bumping GIT_VERSION is a manual step now.

Rollout:

  • Release as base 7.0.2, then bump repository-listener to jre17-7.0.2
  • codacy-tools is also on 7.x: bump it too

To verify:

  • CI docker_build + docker_verify + docker_scan green
  • Listener on dev: git fetch --all --prune --force into an existing partial clone succeeds

Amazon Linux 2023 ships git 2.50.1, which hits
BUG: builtin/pack-objects.c:4453 when fetching into the
repository-listener's partial clones. Build the pinned upstream
release instead and fail docker_verify on any other version.
@codacy-production

codacy-production Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

@lolgab
lolgab marked this pull request as ready for review November 26, 2026 13:23

@codacy-production codacy-production Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

⚠️ Resolve issues before merging

The build-stage package selection may prevent the image from building because the development dependency requires full libcurl while curl-minimal provides the conflicting package. This should be resolved before merging.

Codacy also found:

  • A Dockerfile warning about package metadata not being cleaned from the build stage.
  • A Dockerfile warning about the parameterized base image lacking an explicit version (the Makefile supplies pinned arguments).

Test suggestions

  • Each produced image reports exactly Git 2.56.1 and can execute git ls-remote over HTTPS.
  • A tarball with an incorrect SHA-256 digest causes the build to fail.
  • The source-built installation provides Git and preserves the expected SSH, unzip, useradd, and tini functionality across all image variants.
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. A tarball with an incorrect SHA-256 digest causes the build to fail.

TIP Add review instructions in .codacy/instructions/review.md, or an AGENTS.md, so the reviewer knows your conventions.
TIP How was this review? Give us feedback

Comment thread Dockerfile Outdated
ARG GIT_VERSION
ARG GIT_SHA256
RUN \
dnf -y install --allowerasing gcc make tar xz curl-minimal zlib-devel libcurl-devel expat-devel && \

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 HIGH RISK

The Git build can fail during package installation because libcurl-devel requires full libcurl while curl-minimal requires the conflicting minimal package. Consider installing curl instead of curl-minimal in the build stage.

TIP React 👍 if this review is right, or reply with what's wrong and how it could be better to help improve the reviewer.

@lolgab
lolgab requested a review from a team November 26, 2026 13:24
@lolgab
lolgab marked this pull request as draft November 26, 2026 13:25
@lolgab
lolgab marked this pull request as ready for review November 26, 2026 13:53

@codacy-production codacy-production Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

⚠️ Resolve issues before merging

The download step can hang indefinitely if a mirror accepts the connection but stalls during transfer, preventing the configured fallback from being attempted. Add a transfer timeout so mirror failover remains reliable.

Test suggestions

  • Build succeeds using the pinned tarball and rejects a checksum mismatch.
  • Download falls back to the secondary mirror when the primary mirror fails.
  • The resulting images report exactly Git 2.56.1 and expose Git over HTTPS.
  • Git is installed at the expected /usr locations and remains usable in all image targets.
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Build succeeds using the pinned tarball and rejects a checksum mismatch.
2. Download falls back to the secondary mirror when the primary mirror fails.
3. The resulting images report exactly Git 2.56.1 and expose Git over HTTPS.
4. Git is installed at the expected /usr locations and remains usable in all image targets.

TIP Add review instructions in .codacy/instructions/review.md, or an AGENTS.md, so the reviewer knows your conventions.
TIP How was this review? Give us feedback

Comment thread Dockerfile
RUN \
dnf -y install --allowerasing gcc make tar xz diffutils curl-minimal zlib-devel libcurl-devel expat-devel && \
for mirror in https://cdn.kernel.org https://mirrors.edge.kernel.org; do \
curl -fsSL --retry 5 --retry-all-errors --connect-timeout 20 -o /tmp/git.tar.xz \

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 MEDIUM RISK

A mirror that accepts the connection but stalls while sending the tarball can hang the build indefinitely, preventing fallback to the second mirror. Consider adding a transfer timeout to the curl command.

TIP React 👍 if this review is right, or reply with what's wrong and how it could be better to help improve the reviewer.

@lolgab
lolgab enabled auto-merge (squash) November 26, 2026 14:03

@machadoit machadoit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🫡

@lolgab
lolgab merged commit 0060da8 into master Nov 26, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants