8000 blame: add blame progress callback · Murmele/libgit2@66053c0 · GitHub
[go: up one dir, main page]

8000
Skip to content

Commit 66053c0

Browse files
author
Martin Marmsoler
committed
blame: add blame progress callback
1 parent 12b53eb commit 66053c0

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

include/git2/blame.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,19 @@ typedef enum {
7676
GIT_BLAME_IGNORE_WHITESPACE = (1<<6)
7777
} git_blame_flag_t;
7878

79+
/**
80+
* Blame progress callback.
81+
*
82+
* Called for each blame suspect.
83+
*
84+
* - 'suspect' is the id of the suspect commit.
85+
*
86+
* Returning a non-zero value will abort the blame.
87+
*/
88+
typedef int (*git_blame_progress_cb)(
89+
const git_oid *suspect,
90+
void *payload);
91+
7992
/**
8093
* Blame options structure
8194
*
@@ -120,6 +133,9 @@ typedef struct git_blame_options {
120133
* The default is the last line of the file.
121134
*/
122135
size_t max_line;
136+
137+
git_blame_progress_cb progress_cb;
138+
void *payload;
123139
} git_blame_options;
124140

125141
#define GIT_BLAME_OPTIONS_VERSION 1

src/blame_git.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,14 @@ int git_blame__like_git(git_blame *blame, uint32_t opt)
653653
if (!suspect)
654654
break;
655655

656+
/* Report progress. */
657+
if (blame->options.progress_cb) {
658+
int error;
659+
const git_oid *id = git_commit_id(suspect->commit);
660+
if ((error = blame->options.progress_cb(id, blame->options.payload)))
661+ return error;
662+
}
663+
656664
/* We'll use this suspect later in the loop, so hold on to it for now. */
657665
origin_incref(suspect);
658666

0 commit comments

Comments
 (0)
0