Repository.create(boolean bare) should provide a no-arg overload that uses isBare()
@hardikyadav12 已經在處理了。
開始於 2026年9月16日。
評估
研究方向
從 org.eclipse.jgit.api.Repository (org.eclipse.jgit/src/org/eclipse/jgit/api/Repository.java) 的 create(boolean bare) 方法及其呼叫者開始,包含 org.eclipse.jgit.test 底下基於 FileRepositoryBuilder 的測試。加入委派至 create(isBare()) 的無參數多載,決定是否將 create(boolean) 標記為棄用,並執行倉庫建立測試以及專案所使用的任何 API/相容性檢查。完成代表該多載存在、現有呼叫點仍可編譯,且磁碟上的 bare/non-bare 狀態與 isBare() 相符。
由索引模型根據 Issue 內容生成。
描述
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.
- 主要語言
- Java
- 星號
- 427
- 分支
- 116
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
eclipse-jgit/jgit 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 83/100
eclipse-jgit/jgit#329 ·
-
難度 2/5 1-3 小時 新手友好度 77/100
eclipse-jgit/jgit#327 ·
-
難度 2/5 1-3 小時 新手友好度 83/100
eclipse-jgit/jgit#293 · 2 則留言 ·
-
難度 2/5 1-3 小時 新手友好度 72/100
eclipse-jgit/jgit#288 ·
-
難度 2/5 1-3 小時 新手友好度 72/100
eclipse-jgit/jgit#273 · 1 則留言 ·
查看 eclipse-jgit/jgit 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 67/100
constellation-app/constellation#2613 ·
維護者通常 2 天內回覆
-
難度 2/5 1-3 小時 新手友好度 69/100
Vakore/ZappierGames#334 ·
-
難度 2/5 1-3 小時 新手友好度 74/100
IETF-Hackathon/pqc-certificates#369 ·
維護者通常 1 天內回覆
-
? - Needs Triage bot_watch bug
難度 2/5 1-3 小時 新手友好度 78/100
NVIDIA/cudf-spark-jni#5594 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 92/100