-
Notifications
You must be signed in to change notification settings - Fork 2
/
cherry.cpp
executable file
·39 lines (37 loc) · 1.16 KB
/
cherry.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
* Cherry pick commits.
*/
#include <stdafx.h>
/**
* Cherry-picks into the current index and WT.
*/
SCCRTN LGitCherryPickCommit(LGitContext *ctx,
HWND hwnd,
const git_oid *commit_oid)
{
LGitLog("**LGitCherryPickCommit** Context=%p\n", ctx);
LGitLog(" oid %s\n", git_oid_tostr_s(commit_oid));
SCCRTN ret = SCC_E_NONSPECIFICERROR;
git_cherrypick_options cherry_opts;
git_cherrypick_options_init(&cherry_opts, GIT_CHERRYPICK_OPTIONS_VERSION);
LGitInitCheckoutProgressCallback(ctx, &cherry_opts.checkout_opts);
LGitInitCheckoutNotifyCallbacks(ctx, hwnd, &cherry_opts.checkout_opts);
git_commit *commit = NULL;
if (git_commit_lookup(&commit, ctx->repo, commit_oid) != 0) {
LGitLibraryError(hwnd, "git_commit_lookup");
goto err;
}
LGitProgressInit(ctx, "Cherry Picking Commit", 0);
LGitProgressStart(ctx, hwnd, TRUE);
if (git_cherrypick(ctx->repo, commit, &cherry_opts) != 0) {
LGitProgressDeinit(ctx);
LGitLibraryError(hwnd, "git_cherrypick");
goto err;
}
LGitProgressDeinit(ctx);
ret = SCC_OK;
err:
LGitFinishCheckoutNotify(ctx, hwnd, &cherry_opts.checkout_opts);
git_commit_free(commit);
return ret;
}