Skip to content

Commit 21965b0

Browse files
committed
cmd/git(fix[rev_list]) Reference _all parameter instead of builtin all
why: The flag processing loop used bare `all` (Python builtin, always truthy) instead of the `_all` parameter, causing --all to be appended unconditionally twice to every rev-list command. what: - Change (all, "--all") to (_all, "--all") at both occurrences - Add test_rev_list_all_parameter to verify _all flag behavior
1 parent ad647f6 commit 21965b0

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

src/libvcs/cmd/git.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2193,7 +2193,7 @@ def rev_list(
21932193

21942194
for flag, shell_flag in [
21952195
# Limiting output
2196-
(all, "--all"),
2196+
(_all, "--all"),
21972197
(author, "--author"),
21982198
(committer, "--committer"),
21992199
(grep, "--grep"),
@@ -2212,7 +2212,7 @@ def rev_list(
22122212
(first_parent, "--first-parent"),
22132213
(exclude_first_parent_only, "--exclude-first-parent-only"),
22142214
(_not, "--not"),
2215-
(all, "--all"),
2215+
(_all, "--all"),
22162216
(exclude, "--exclude"),
22172217
(reflog, "--reflog"),
22182218
(alternative_refs, "--alternative-refs"),

tests/cmd/test_git.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2625,3 +2625,22 @@ def test_submodule_entry_absorbgitdirs(
26252625

26262626
# Should succeed (empty string or info message)
26272627
assert result == "" or isinstance(result, str)
2628+
2629+
2630+
def test_rev_list_all_parameter(git_repo: GitSync) -> None:
2631+
"""Test that _all parameter controls --all flag in rev-list."""
2632+
# Create a branch with an extra commit not reachable from master
2633+
git_repo.cmd.run(["checkout", "-b", "other-branch"])
2634+
git_repo.cmd.run(["commit", "--allow-empty", "-m", "other-branch-commit"])
2635+
git_repo.cmd.run(["checkout", "master"])
2636+
2637+
# Without _all: only commits reachable from HEAD (master)
2638+
result_no_all = git_repo.cmd.rev_list(commit="HEAD")
2639+
count_no_all = len(result_no_all.strip().split("\n"))
2640+
2641+
# With _all=True: includes commits from all branches
2642+
result_with_all = git_repo.cmd.rev_list(commit="HEAD", _all=True)
2643+
count_with_all = len(result_with_all.strip().split("\n"))
2644+
2645+
# _all=True should return strictly more commits (the other-branch commit)
2646+
assert count_with_all > count_no_all

0 commit comments

Comments
 (0)