What's wrong
repository.Add().ExecuteAsync() with nothing configured runs git … add with no pathspec. Git prints Nothing specified, nothing added. and exits 0, so the builder returns a GitCompleted as if staging had worked.
GitAddBuilder.AppendVerbArguments (GitIntegration/Builders/GitAddBuilder.cs:69-97) emits add, then --all/--update if set, then operands if any. Nothing checks that there is anything to stage.
The opposite mistake isn't checked either. Add().All().UpdateTrackedOnly() emits add --all --update, which git rejects with fatal: options '-A' and '-u' cannot be used together (exit 128). The caller gets a generic GitCommandException with no hint that two fluent calls conflict.
Verified with git 2.43:
$ git add; echo $?
Nothing specified, nothing added.
hint: Maybe you wanted to say 'git add .'?
0
$ git add --all --update; echo $?
fatal: options '-A' and '-u' cannot be used together
128
Why it matters
A caller who forgets .All() or .ForPath(...) gets a success result. The following Commit(...) then either throws GitNothingToCommitException or commits only what was staged earlier, far from the real mistake.
Other builders already refuse impossible configurations before spawning git:
Suggested fix / acceptance criteria
- An
Add() builder with no paths and neither All() nor UpdateTrackedOnly() throws InvalidOperationException before any process starts, and TryExecuteAsync behaves the same, matching the Fetch guard.
All() combined with UpdateTrackedOnly() is either refused the same way, or documented as last-call-wins like IGitBranchListBuilder.LocalOnly/RemoteOnly. Git's fatal error should not be the only signal.
- If the check goes in
BuildArguments() as Fetch's does, update GitRepositoryMutatingVerbTests.EveryMutatingVerbIsScopedToTheRepositoryPath (GitIntegration.Test/GitRepositoryMutatingVerbTests.cs:28). It calls repository.Add().BuildArguments() bare, so it needs e.g. .All().
- Builder tests cover both refusals, and the existing vectors for
ForPath, All and UpdateTrackedOnly used alone are kept.
What's wrong
repository.Add().ExecuteAsync()with nothing configured runsgit … addwith no pathspec. Git printsNothing specified, nothing added.and exits 0, so the builder returns aGitCompletedas if staging had worked.GitAddBuilder.AppendVerbArguments(GitIntegration/Builders/GitAddBuilder.cs:69-97) emitsadd, then--all/--updateif set, then operands if any. Nothing checks that there is anything to stage.The opposite mistake isn't checked either.
Add().All().UpdateTrackedOnly()emitsadd --all --update, which git rejects withfatal: options '-A' and '-u' cannot be used together(exit 128). The caller gets a genericGitCommandExceptionwith no hint that two fluent calls conflict.Verified with git 2.43:
Why it matters
A caller who forgets
.All()or.ForPath(...)gets a success result. The followingCommit(...)then either throwsGitNothingToCommitExceptionor commits only what was staged earlier, far from the real mistake.Other builders already refuse impossible configurations before spawning git:
GitFetchBuilderrejectsAllRemotes()+FromRemote(...)(GitFetchBuilder.cs:21-38).GitCheckoutBuilderrejectsCreatingBranch()+Detach()(GitCheckoutBuilder does not reject CreatingBranch() + Detach(), which git refuses at runtime #91).Suggested fix / acceptance criteria
Add()builder with no paths and neitherAll()norUpdateTrackedOnly()throwsInvalidOperationExceptionbefore any process starts, andTryExecuteAsyncbehaves the same, matching the Fetch guard.All()combined withUpdateTrackedOnly()is either refused the same way, or documented as last-call-wins likeIGitBranchListBuilder.LocalOnly/RemoteOnly. Git's fatal error should not be the only signal.BuildArguments()as Fetch's does, updateGitRepositoryMutatingVerbTests.EveryMutatingVerbIsScopedToTheRepositoryPath(GitIntegration.Test/GitRepositoryMutatingVerbTests.cs:28). It callsrepository.Add().BuildArguments()bare, so it needs e.g..All().ForPath,AllandUpdateTrackedOnlyused alone are kept.