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

Commite4582f8

Browse files
committed
fixed Commit.stats retrieval for parentless commits in bare repos
(cherry picked from commit 88852ed7bcde4f4b18c1ae8b6fba7f3fab8e9bf5)
1 parent79cfe05 commite4582f8

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

‎CHANGES

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ Commit
2424
the first line) and a new property ``Commit.summary`` contains the first
2525
line of the commit message.
2626

27+
* Fixed a failure when trying to lookup the stats of a parentless commit from
28+
a bare repo.
29+
2730
Diff
2831
----
2932
* The diff parser is now far faster and also addresses a bug where

‎lib/git/commit.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def list_from_string(cls, repo, text):
165165

166166
message='\n'.join(messages)
167167

168-
commits.append(Commit(repo,id=id,parents=parents,tree=tree,author=author,authored_date=authored_date,
168+
commits.append(Commit(repo,id=id,parents=parents,tree=tree,author=author,authored_date=authored_date,
169169
committer=committer,committed_date=committed_date,message=message))
170170

171171
returncommits
@@ -224,11 +224,11 @@ def diffs(self):
224224
@property
225225
defstats(self):
226226
ifnotself.parents:
227-
text=self.repo.git.diff(self.id,'--',numstat=True)
227+
text=self.repo.git.diff_tree(self.id,'--',numstat=True,root=True)
228228
text2=""
229-
forlineintext.splitlines():
229+
forlineintext.splitlines()[1:]:
230230
(insertions,deletions,filename)=line.split("\t")
231-
text2+="%s\t%s\t%s\n"% (deletions,insertions,filename)
231+
text2+="%s\t%s\t%s\n"% (insertions,deletions,filename)
232232
text=text2
233233
else:
234234
text=self.repo.git.diff(self.parents[0].id,self.id,'--',numstat=True)

‎test/fixtures/diff_tree_numstat_root

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
634396b2f541a9f2d58b00be1a07f0c358b999b3
2+
1829a.txt
3+
50b.txt

‎test/git/test_commit.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def test_diffs(self, git):
129129
assert_equal(True,diffs[5].new_file)
130130

131131
assert_true(git.called)
132-
assert_equal(git.call_args, (('diff','-M',
132+
assert_equal(git.call_args, (('diff','-M',
133133
'038af8c329ef7c1bae4568b98bd5c58510465493',
134134
'91169e1f5fa4de2eaea3f176461f5dc784796769',
135135
), {'full_index':True}))
@@ -190,7 +190,7 @@ def test_diffs_with_mode_only_change(self, git):
190190

191191
@patch_object(Git,'_call_process')
192192
deftest_stats(self,git):
193-
git.return_value=fixture('diff_numstat')
193+
git.return_value=fixture('diff_tree_numstat_root')
194194

195195
commit=Commit(self.repo,id='634396b2f541a9f2d58b00be1a07f0c358b999b3')
196196
commit.__bake_it__()
@@ -201,7 +201,7 @@ def test_stats(self, git):
201201
assert_equal(["a.txt","b.txt"],keys)
202202

203203
assert_true(git.called)
204-
assert_equal(git.call_args, (('diff','634396b2f541a9f2d58b00be1a07f0c358b999b3','--'), {'numstat':True}))
204+
assert_equal(git.call_args, (('diff_tree','634396b2f541a9f2d58b00be1a07f0c358b999b3','--'), {'numstat':True,'root':True}))
205205

206206
@patch_object(Git,'_call_process')
207207
deftest_rev_list_bisect_all(self,git):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp