]> git.proxmox.com Git - libgit2.git/commitdiff
branch: More obvious semantics in `foreach`
authorVicent Marti <tanoku@gmail.com>
Mon, 17 Jun 2013 16:48:02 +0000 (18:48 +0200)
committerVicent Marti <tanoku@gmail.com>
Mon, 17 Jun 2013 16:48:02 +0000 (18:48 +0200)
src/branch.c

index 590cdc027eb0a3014a3132003bb8de5ab0594654..7064fa7fcedc55bddc102d188626a686e500182d 100644 (file)
@@ -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)