8000 blame: add blame progress callback by KOLANICH · Pull Request #5728 · libgit2/libgit2 · GitHub
[go: up one dir, main page]

Skip to content

blame: add blame progress callback #5728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions include/git2/blame.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,19 @@ typedef enum {
GIT_BLAME_IGNORE_WHITESPACE = (1<<6),
} git_blame_flag_t;

/**
* Blame progress callback.
*
* Called for each blame suspect.
*
* - 'suspect' is the id of the suspect commit.
*
* Returning a non-zero value will abort the blame.
*/
typedef int (*git_blame_progress_cb)(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Progress" seems like a misnomer to me. Since it only provides the commit ID, that doesn't tell you how far through the process it is. It's really a mechanism for aborting, but I'm not quite clear on the use case.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commits are not mine, they are by @hackhaslam. So, if you are ready to merge them, then merge, if you are not and wanna discuss something, discuss with him, since he already uses this in gitahead and making an incompatible non-fast-forwardable change will only cause more mess. I just try to upstream them in order to make using libgit2 package from a distro instead of a custom fork a bit closer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The patches in the GitAhead fork of libgit2 are not ready to be upstreamed. I've already proposed patches for the changes that I believed to be acceptable. I understand your desire to build GitAhead from a vanilla libgit2, but that's not a realistic goal at this point.

const git_oid *suspect,
void *payload);

/**
* Blame options structure
*
Expand Down Expand Up @@ -87,6 +100,9 @@ typedef struct git_blame_options {
* The default is the last line of the file.
*/
size_t max_line;

git_blame_progress_cb progress_cb;
void *payload;
} git_blame_options;

#define GIT_BLAME_OPTIONS_VERSION 1
Expand Down
8 changes: 8 additions & 0 deletions src/blame_git.c
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,14 @@ int git_blame__like_git(git_blame *blame, uint32_t opt)
if (!suspect)
break;

/* Report progress. */
if (blame->options.progress_cb) {
int error;
const git_oid *id = git_commit_id(suspect->commit);
if ((error = blame->options.progress_cb(id, blame->options.payload)))
return error;
}

/* We'll use this suspect later in the loop, so hold on to it for now. */
origin_incref(suspect);

Expand Down
0