Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4c21e51

Browse files
authored
Merge pull request#1933 from cardoeng/main
fix: fix incoherent beginning whitespace
2 parents4d07031 +97fad9c commit4c21e51

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

‎git/diff.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ def _handle_diff_line(lines_bytes: bytes, repo: "Repo", index: DiffIndex["Diff"]
695695
change_type:Lit_change_type=cast(Lit_change_type,_change_type[0])
696696
score_str="".join(_change_type[1:])
697697
score=int(score_str)ifscore_str.isdigit()elseNone
698-
path=path.strip()
698+
path=path.strip("\n")
699699
a_path=path.encode(defenc)
700700
b_path=path.encode(defenc)
701701
deleted_file=False

‎test/test_diff.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,3 +529,22 @@ def test_diff_patch_with_external_engine(self, rw_dir):
529529
self.assertEqual(len(index_against_head),1)
530530
index_against_working_tree=repo.index.diff(None,create_patch=True)
531531
self.assertEqual(len(index_against_working_tree),1)
532+
533+
@with_rw_directory
534+
deftest_beginning_space(self,rw_dir):
535+
# Create a file beginning by a whitespace
536+
repo=Repo.init(rw_dir)
537+
file=osp.join(rw_dir," file.txt")
538+
withopen(file,"w")asf:
539+
f.write("hello world")
540+
repo.git.add(Git.polish_url(file))
541+
repo.index.commit("first commit")
542+
543+
# Diff the commit with an empty tree
544+
# and check the paths
545+
diff_index=repo.head.commit.diff(NULL_TREE)
546+
d=diff_index[0]
547+
a_path=d.a_path
548+
b_path=d.b_path
549+
self.assertEqual(a_path," file.txt")
550+
self.assertEqual(b_path," file.txt")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp