diff options
author | Vicent Marti <tanoku@gmail.com> | 2013-06-17 18:48:02 +0200 |
---|---|---|
committer | Vicent Marti <tanoku@gmail.com> | 2013-06-17 18:48:02 +0200 |
commit | 09c2f91c150a4862c9189d9e08d0dc111d4d706c (patch) | |
tree | 9e6b29da9c4e69c82c6cdfc7e554a54754df4ea6 /src/branch.c | |
parent | bd2319c839fcc9fa85cd726b424bac345b4da1a4 (diff) | |
download | libgit2-09c2f91c150a4862c9189d9e08d0dc111d4d706c.tar.gz |
branch: More obvious semantics in `foreach`
Diffstat (limited to 'src/branch.c')
-rw-r--r-- | src/branch.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/branch.c b/src/branch.c index 590cdc027..7064fa7fc 100644 --- a/src/branch.c +++ b/src/branch.c @@ -137,7 +137,7 @@ int git_branch_foreach( if (git_reference_iterator_new(&iter, repo) < 0) return -1; - while (!error && (error = git_reference_next(&ref, iter)) == 0) { + while ((error = git_reference_next(&ref, iter)) == 0) { if (list_flags & GIT_BRANCH_LOCAL && git__prefixcmp(ref->name, GIT_REFS_HEADS_DIR) == 0) { if (callback(ref->name + strlen(GIT_REFS_HEADS_DIR), @@ -155,6 +155,10 @@ int git_branch_foreach( } git_reference_free(ref); + + /* check if the callback has cancelled iteration */ + if (error == GIT_EUSER) + break; } if (error == GIT_ITEROVER) |