Skip to content

Commit 8602ba2

Browse files
authored
fix: searching for tree/blob hash never-ending (#1472)
Searching for a tree or blob hash instead of a commit hash created a seemingly never-ending search (internally an exception was thrown). Examples for non-ending searches in the SourceGit repository itself are searching for 6b83a0a (that is the tree "src" of commit 190d2ee) or e686a53 (that is the file ".gitignore" in the tree of commit 190d2ee).
1 parent aa6ef80 commit 8602ba2

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/Commands/QuerySingleCommit.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,20 @@ public class QuerySingleCommit : Command
66
{
77
public QuerySingleCommit(string repo, string sha)
88
{
9+
_repo = repo;
10+
_sha = sha;
11+
912
WorkingDirectory = repo;
1013
Context = repo;
1114
Args = $"show --no-show-signature --decorate=full --format=%H%n%P%n%D%n%aN±%aE%n%at%n%cN±%cE%n%ct%n%s -s {sha}";
1215
}
1316

1417
public Models.Commit Result()
1518
{
19+
var isCommitSHA = new IsCommitSHA(_repo, _sha).Result();
20+
if (!isCommitSHA)
21+
return null;
22+
1623
var rs = ReadToEnd();
1724
if (rs.IsSuccess && !string.IsNullOrEmpty(rs.StdOut))
1825
{
@@ -37,5 +44,8 @@ public Models.Commit Result()
3744

3845
return null;
3946
}
47+
48+
private readonly string _repo;
49+
private readonly string _sha;
4050
}
4151
}

0 commit comments

Comments
 (0)