You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Repository.create(boolean bare) should provide a no-arg overload that uses isBare() #297
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:Repositoryrepo = newFileRepositoryBuilder().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.
Activity
hardikyadav12 commentedon Sep 16, 2026
Hi @oliviercailloux I would like to work on this issue. Could you please assign this to me?