Skip to content
This repository has been archived by the owner on Apr 12, 2019. It is now read-only.

Fix retrieve file last commit branchName #98

Merged
merged 4 commits into from
Dec 20, 2017
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions commit_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func targetedSearch(state *getCommitsInfoState, done chan error) {
done <- nil
return
}
command := NewCommand("rev-list", "-1", "HEAD", "--", entryPath)
command := NewCommand("rev-list", "-1", state.headCommit.ID.String(), "--", entryPath)
output, err := command.RunInDir(state.headCommit.repo.Path)
if err != nil {
done <- err
Expand All @@ -90,7 +90,9 @@ func targetedSearch(state *getCommitsInfoState, done chan error) {
done <- err
return
}
state.lock.Lock()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to lock here? I don't see why it would be a problem if two threads run a read-only git command in parallel.

commit, err := state.headCommit.repo.getCommit(id)
state.lock.Unlock()
if err != nil {
done <- err
return
Expand Down Expand Up @@ -192,7 +194,7 @@ func getCommitsInfo(state *getCommitsInfoState) error {
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute)
defer cancel()

args := []string{"log", getCommitsInfoPretty, "--name-status", "-c"}
args := []string{"log", state.headCommit.ID.String(), getCommitsInfoPretty, "--name-status", "-c"}
if len(state.treePath) > 0 {
args = append(args, "--", state.treePath)
}
Expand Down