Merge pull request #1655 from yorah/fix/ref-memleak ref: free the last ref when cancelling git_branch_foreach()