From d8de4e070e4d20eef5c6a2eac334562ecb01c40a Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Mon, 15 Apr 2024 16:41:11 +0200 Subject: [PATCH] PullRepository(): call fetch and merge --- CalculatorCInterface/git_library.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/CalculatorCInterface/git_library.cpp b/CalculatorCInterface/git_library.cpp index 6466343..db8e77f 100644 --- a/CalculatorCInterface/git_library.cpp +++ b/CalculatorCInterface/git_library.cpp @@ -1001,9 +1001,25 @@ int GitLibrary::PushRepository(char const *localRepoName, char const *branchName return error; } -int GitLibrary::PullRepository(char const *localRepoName, char const *branchName, - char const *userName, char const *userPassword) { - // "git pull" is a basiclly a "git fetch" followed by a "git merge" +int GitLibrary::PullRepository(char const *localRepoName, char const *remoteRepoName) { + // "git pull" is a basically a "git fetch" followed by a "git merge" + git_repository *repo = nullptr; + int error = 0; - return 0; + if ((error = git_repository_open(&repo, localRepoName)) != 0) { + // error + } + // remoteRepoName typically "origin" + if ((error = fetch(repo, remoteRepoName)) != 0) { + // error + } + if ((error = merge(repo) { + // error + } + + if (repo) { + git_repository_free(repo); + } + + return error; }