@@ -695,7 +695,7 @@ def test_branch_cmd_create_checkout_parameter(
695695 branch_name = f"test-create-{ test_id } "
696696
697697 # Record current branch before creating
698- current_before = git_repo .cmd .symbolic_ref (name = "HEAD" , short = True )
698+ current_before = git_repo .cmd .symbolic_ref (name = "HEAD" , short = True ). strip ()
699699
700700 # Create branch using GitBranchCmd
701701 branch_cmd = git .GitBranchCmd (path = git_repo .path , branch_name = branch_name )
@@ -710,7 +710,7 @@ def test_branch_cmd_create_checkout_parameter(
710710 assert branch_name in branch_names
711711
712712 # Check if HEAD switched
713- current_after = git_repo .cmd .symbolic_ref (name = "HEAD" , short = True )
713+ current_after = git_repo .cmd .symbolic_ref (name = "HEAD" , short = True ). strip ()
714714 if expect_switch :
715715 assert current_after == branch_name
716716 else :
@@ -736,7 +736,7 @@ def test_branch_manager_create_checkout_parameter(
736736 branch_name = f"test-mgr-create-{ test_id } "
737737
738738 # Record current branch before creating
739- current_before = git_repo .cmd .symbolic_ref (name = "HEAD" , short = True )
739+ current_before = git_repo .cmd .symbolic_ref (name = "HEAD" , short = True ). strip ()
740740
741741 # Create branch using GitBranchManager
742742 result = git_repo .cmd .branches .create (branch = branch_name , checkout = checkout )
@@ -750,7 +750,7 @@ def test_branch_manager_create_checkout_parameter(
750750 assert branch_name in branch_names
751751
752752 # Check if HEAD switched
753- current_after = git_repo .cmd .symbolic_ref (name = "HEAD" , short = True )
753+ current_after = git_repo .cmd .symbolic_ref (name = "HEAD" , short = True ). strip ()
754754 if expect_switch :
755755 assert current_after == branch_name
756756 else :
@@ -1894,7 +1894,7 @@ def test_notes_get(git_repo: GitSync) -> None:
18941894 git_repo .cmd .notes .add (message = "Test note for get" , force = True )
18951895
18961896 # Get the HEAD revision
1897- head_sha = git_repo .cmd .rev_parse (args = "HEAD" )
1897+ head_sha = git_repo .cmd .rev_parse (args = "HEAD" ). strip ()
18981898
18991899 # Get the note by object_sha
19001900 note = git_repo .cmd .notes .get (object_sha = head_sha )
@@ -1920,7 +1920,7 @@ def test_notes_show(git_repo: GitSync) -> None:
19201920 git_repo .cmd .notes .add (message = note_message , force = True )
19211921
19221922 # Get the note
1923- head_sha = git_repo .cmd .rev_parse (args = "HEAD" )
1923+ head_sha = git_repo .cmd .rev_parse (args = "HEAD" ). strip ()
19241924 note = git_repo .cmd .notes .get (object_sha = head_sha )
19251925 assert note is not None
19261926
@@ -1936,7 +1936,7 @@ def test_notes_append(git_repo: GitSync) -> None:
19361936 git_repo .cmd .notes .add (message = initial_message , force = True )
19371937
19381938 # Get the note
1939- head_sha = git_repo .cmd .rev_parse (args = "HEAD" )
1939+ head_sha = git_repo .cmd .rev_parse (args = "HEAD" ). strip ()
19401940 note = git_repo .cmd .notes .get (object_sha = head_sha )
19411941 assert note is not None
19421942
@@ -1956,7 +1956,7 @@ def test_notes_remove(git_repo: GitSync) -> None:
19561956 git_repo .cmd .notes .add (message = "Note to be removed" , force = True )
19571957
19581958 # Get the note
1959- head_sha = git_repo .cmd .rev_parse (args = "HEAD" )
1959+ head_sha = git_repo .cmd .rev_parse (args = "HEAD" ). strip ()
19601960 note = git_repo .cmd .notes .get (object_sha = head_sha )
19611961 assert note is not None
19621962
@@ -1998,7 +1998,7 @@ def test_notes_edit(git_repo: GitSync, tmp_path: pathlib.Path) -> None:
19981998 git_repo .cmd .notes .add (message = "Initial note for edit test" , force = True )
19991999
20002000 # Get the note
2001- head_sha = git_repo .cmd .rev_parse (args = "HEAD" )
2001+ head_sha = git_repo .cmd .rev_parse (args = "HEAD" ). strip ()
20022002 note = git_repo .cmd .notes .get (object_sha = head_sha )
20032003 assert note is not None
20042004
@@ -2019,14 +2019,14 @@ def test_notes_copy(git_repo: GitSync) -> None:
20192019 git_repo .cmd .run (["commit" , "-m" , "Commit for copy note test" ])
20202020
20212021 # Get the new commit SHA
2022- new_commit_sha = git_repo .cmd .rev_parse (args = "HEAD" )
2022+ new_commit_sha = git_repo .cmd .rev_parse (args = "HEAD" ). strip ()
20232023
20242024 # Checkout previous commit to add note there
20252025 git_repo .cmd .run (["checkout" , "HEAD~1" ])
20262026 git_repo .cmd .notes .add (message = "Note to copy" , force = True )
20272027
20282028 # Get the note and copy to new commit
2029- old_commit_sha = git_repo .cmd .rev_parse (args = "HEAD" )
2029+ old_commit_sha = git_repo .cmd .rev_parse (args = "HEAD" ). strip ()
20302030 note = git_repo .cmd .notes .get (object_sha = old_commit_sha )
20312031 assert note is not None
20322032
@@ -2760,12 +2760,13 @@ def test_run_trim_false_preserves_blob(git_repo: GitSync) -> None:
27602760 assert blob == base
27612761
27622762
2763- def test_run_default_trims_trailing_newline (git_repo : GitSync ) -> None :
2764- """Default run() keeps the no-trailing-newline contract callers rely on ."""
2765- sha = git_repo .cmd .run (["rev-parse" , "HEAD" ])
2763+ def test_run_default_preserves_trailing_newline (git_repo : GitSync ) -> None :
2764+ """Default run() returns output verbatim, including the trailing newline ."""
2765+ verbatim = git_repo .cmd .run (["rev-parse" , "HEAD" ])
27662766
2767- assert "\n " not in sha
2768- assert sha == sha .strip ()
2767+ assert verbatim .endswith ("\n " )
2768+ # trim=True still yields the convenient bare value.
2769+ assert git_repo .cmd .run (["rev-parse" , "HEAD" ], trim = True ) == verbatim .strip ()
27692770
27702771
27712772def test_run_failure_preserves_stderr_lines (git_repo : GitSync ) -> None :
0 commit comments