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

Commit8dd51f1

Browse files
committed
Improved refparse error handling in case of out-of-bound indices
1 parent7029773 commit8dd51f1

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

‎repo/fun.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,12 @@ def rev_parse(repo, rev):
190190
raiseNotImplementedError("Support for additional @{...} modes not implemented")
191191
#END handle revlog index
192192

193-
entry=ref.log()[revlog_index]
193+
try:
194+
entry=ref.log()[revlog_index]
195+
exceptIndexError:
196+
raiseBadObject("Invalid revlog index: %i"%revlog_index)
197+
#END handle index out of bound
198+
194199
obj=Object.new_from_sha(repo,hex_to_bin(entry.newhexsha))
195200

196201
# make it pass the following checks

‎test/test_repo.py‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,12 +557,19 @@ def test_rev_parse(self):
557557
# uses HEAD.ref by default
558558
assertrev_parse('@{0}')==head.commit
559559
ifnothead.is_detached:
560-
assertrev_parse('%s@{0}'%head.ref.name)==head.ref.commit
560+
refspec='%s@{0}'%head.ref.name
561+
assertrev_parse(refspec)==head.ref.commit
562+
# all additional specs work as well
563+
assertrev_parse(refspec+"^{tree}")==head.commit.tree
564+
assertrev_parse(refspec+":CHANGES").type=='blob'
561565
#END operate on non-detached head
562566

563567
# the last position
564568
assertrev_parse('@{1}')!=head.commit
565569

570+
# position doesn't exist
571+
self.failUnlessRaises(BadObject,rev_parse,'@{10000}')
572+
566573
# currently, nothing more is supported
567574
self.failUnlessRaises(NotImplementedError,rev_parse,"@{1 week ago}")
568575

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp