Skip to content

Commit

Permalink
git: Add ^commit to rev parse --verify
Browse files Browse the repository at this point in the history
It seems like rev-parse --verify if given a valid full length
sha hash doesn't look it up in the database by default, it just
returns success. In order to force it to verify that it is a commit,
we need to add an addl string to the command.
  • Loading branch information
jerry-skydio committed Jul 11, 2023
1 parent 917438e commit f5e74a1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion revup/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,9 @@ async def rev_list(

@lru_cache(maxsize=None)
async def is_branch_or_commit(self, obj: str) -> bool:
return await self.git_return_code("rev-parse", "--verify", "--quiet", obj) == 0
return (
await self.git_return_code("rev-parse", "--verify", "--quiet", obj + "^{commit}") == 0
)

async def verify_branch_or_commit(self, obj: str) -> None:
if not await self.is_branch_or_commit(obj):
Expand Down

0 comments on commit f5e74a1

Please sign in to comment.