From d5c24194f7a969a5fb7027036913654c65e2811f Mon Sep 17 00:00:00 2001 From: Ian Thomas Date: Fri, 6 Nov 2026 09:42:07 +0000 Subject: [PATCH] Remove extra output after switching to different branch --- src/subcommand/checkout_subcommand.cpp | 1 + test/test_checkout.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/subcommand/checkout_subcommand.cpp b/src/subcommand/checkout_subcommand.cpp index d2b29cd..7d7b19a 100644 --- a/src/subcommand/checkout_subcommand.cpp +++ b/src/subcommand/checkout_subcommand.cpp @@ -150,6 +150,7 @@ void checkout_subcommand::run() update_head(repo, annotated_commit, target_name); std::cout << "Switched to a new branch '" << target_name << "'" << std::endl; + return; } else if (!pathspecs.empty()) { diff --git a/test/test_checkout.py b/test/test_checkout.py index 1934296..e38efce 100644 --- a/test/test_checkout.py +++ b/test/test_checkout.py @@ -35,6 +35,7 @@ def test_checkout_b(repo_init_with_commit, git2cpp_path, tmp_path): p_checkout = subprocess.run(checkout_cmd, capture_output=True, cwd=tmp_path, text=True) assert p_checkout.returncode == 0 assert "Switched to a new branch 'foregone'" in p_checkout.stdout + assert "Switched to branch 'foregone'" not in p_checkout.stdout branch_cmd = [git2cpp_path, "branch"] p_branch = subprocess.run(branch_cmd, capture_output=True, cwd=tmp_path, text=True) @@ -65,6 +66,7 @@ def test_checkout_B_force_create(repo_init_with_commit, git2cpp_path, tmp_path): p_checkout = subprocess.run(checkout_cmd, capture_output=True, cwd=tmp_path, text=True) assert p_checkout.returncode == 0 assert "Switched to a new branch 'resetme'" in p_checkout.stdout + assert "Switched to branch 'resetme'" not in p_checkout.stdout # Verify we're on the branch branch_cmd = [git2cpp_path, "branch"]