Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

cargo builds can corrupt consumer git repos due to env vars

Đang mở Phù hợp với người mới
#527 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
82/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
git, rust
Lĩnh vực
build-system

Hướng nghiên cứu

Bắt đầu trong boring-sys/build/main.rs, tập trung vào hai vị trí gọi git và việc sử dụng hiện có của git rev-parse --local-env-vars. Kiểm tra cách buildscript gọi git khi Cargo chạy từ một hook hoặc worktree. Hoàn thành khi các lần gọi đó không còn kế thừa các biến môi trường Git có thể ảnh hưởng đến repository của consumer.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Problem

The buildscript in boring-sys/build/main.rs calls out to git to set up the BoringSSL sources. When a project using this crate runs cargo from a git hook, git has already set variables like GIT_DIR for the hook. The buildscript here doesn't sanitize those variables, so git init re-initializes the consumer's repo, rather than the BoringSSL repo the buildscript intended.

Normally that's harmless, but when the build is running from a worktree rather than the main checkout, a surprising git interaction causes it to write core.bare = true into the main checkout's config, breaking most git commands in that main checkout until the config is fixed. Unexpected behaviour from git, for sure, but definitely not something we want to trigger from our build.

Proposed fix

Before invoking git in boring-sys/build/main.rs (2 call sites), strip env vars that would alter git's behaviour. git rev-parse --local-env-vars prints a list of those vars; for me, it gives:

GIT_ALTERNATE_OBJECT_DIRECTORIES
GIT_CONFIG
GIT_CONFIG_PARAMETERS
GIT_CONFIG_COUNT
GIT_OBJECT_DIRECTORY
GIT_DIR
GIT_WORK_TREE
GIT_IMPLICIT_WORK_TREE
GIT_GRAFT_FILE
GIT_INDEX_FILE
GIT_NO_REPLACE_OBJECTS
GIT_REPLACE_REF_BASE
GIT_PREFIX
GIT_SHALLOW_FILE
GIT_COMMON_DIR
Ngôn ngữ chính
Rust
Star
526
Fork
178
Merge trung bình
16 giờ 47 phút
Pull request đã merge (30 ngày)
8

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của cloudflare/boring

Tất cả issue của cloudflare/boring

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.