Skip to content
This repository was archived by the owner on Jan 19, 2021. It is now read-only.

How to stage all files by mask? #4

@MasterGroosha

Description

@MasterGroosha

Hello, I'm having issues staging all files in repo (similar to git add .)

What I see in stdout:

terminate called after throwing an instance of 'std::logic_error'
  what():  basic_string::_M_construct null not valid

My code:
mod_git.h

#include <cppgit2/repository.hpp>

class GitWorker {
public:
    GitWorker(const std::string &path);
    void StageAll();
    
private:
    cppgit2::repository m_Repo;
};

mod_git.cpp

#include "mod_git.h"
#include <string>
#include <vector>
#include <iostream>

using namespace std;

GitWorker::GitWorker(const string &path)
    : m_Repo(cppgit2::repository::open(path)) 
    {
    }

void GitWorker::StageAll() {
    auto index = m_Repo.index();
    const vector<string> test = {"*"};
    index.add_entries_that_match(test, cppgit2::index::add_option::force, NULL);
}

main.cpp

int main(int argc, char* argv[]) {
    GitWorker git = GitWorker(".");
    update_text(); // writes something to file
    git.StageAll();
    return 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions