Repository.create(boolean bare) should provide a no-arg overload that uses isBare()
@hardikyadav12 đang làm issue này rồi.
Từ ngày 16/9/2026.
Đá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
- 74/100
Hướng nghiên cứu
Bắt đầu với phương thức create(boolean bare) trong org.eclipse.jgit.api.Repository (org.eclipse.jgit/src/org/eclipse/jgit/api/Repository.java) và các nơi gọi nó, bao gồm các test dựa trên FileRepositoryBuilder dưới org.eclipse.jgit.test. Thêm overload không đối số ủy quyền cho create(isBare()), quyết định xem create(boolean) có bị đánh dấu deprecated hay không, và chạy các test tạo repository cùng bất kỳ kiểm tra API/tương thích nào mà dự án sử dụng. Xong nghĩa là overload tồn tại, các vị trí gọi hiện tại vẫn biên dịch được, và trạng thái trên đĩa (bare/non-bare) khớp với isBare().
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
Repository.create(boolean bare) requires the caller to supply the bare flag
explicitly, even though the repository object already knows whether it is bare —
isBare() returns exactly that value, set by the builder via setBare() /
setWorkTree(…).
This creates a subtle footgun: a caller who builds a repository via
FileRepositoryBuilder and correctly sets .setBare() must still remember to pass
the same information again when calling create(), or the result is an inconsistency
between the on-disk layout and what the already-open Repository object reports.
// Consistent but redundant — caller must repeat what the builder already knows:
Repository repo = new FileRepositoryBuilder().setGitDir(dir).setBare().build();
repo.create(repo.isBare());
// If the caller forgets or passes the wrong value, the state is inconsistent:
repo.create(false); // creates a non-bare repo on disk, but repo.isBare() == true
Motivation
A no-arg Repository.create() overload that delegates to create(isBare()) would
remove the redundancy and eliminate the inconsistency risk. The existing
create(boolean bare) can stay for backward compatibility (might be marked deprecated), but the no-arg form
should become the canonical way to initialize a repository whose bare/non-bare nature
was already decided at build time.
Alternatives considered
Calling create(repository.isBare()) by hand — which is what callers currently must
do. This works, but requires knowing the idiom and is easy to get wrong (passing
true hardcoded is a common mistake for code that only tests with bare repositories).
Additional context
Encountered while implementing a utility that accepts a BaseRepositoryBuilder<?, R>
to let the caller control repository configuration. Before the fix, it called
repository.create(true) unconditionally, silently producing wrong behavior for
non-bare builds.
- Ngôn ngữ chính
- Java
- Star
- 427
- Fork
- 116
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của eclipse-jgit/jgit
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
eclipse-jgit/jgit#329 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
eclipse-jgit/jgit#327 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
eclipse-jgit/jgit#293 · 2 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
eclipse-jgit/jgit#288 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
eclipse-jgit/jgit#273 · 1 bình luận ·
Tất cả issue của eclipse-jgit/jgit
Issue tương tự
-
? - Needs Triage bot_watch bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
NVIDIA/cudf-spark-jni#5594 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Upgrade solr to 9.11.0Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
DataONEorg/dataone-indexer#390 ·