ref: free the last ref when cancelling git_branch_foreach()

Also fixed an assert typo on nulltoken's HEAD