I want to create lightweight tag (no annotated). I read this
https://ben.straub.cc/2013/06/03/refs-tags-and-branching/
and it seems to me that all I have to do is to create reference. But how to do that? I tried something like this but git_reference_create() returns GIT_EINVALIDSPEC
git_reference * out;
tag_name = "refs/tags/v1.0";
git_revwalk *walker;
git_revwalk_new(&walker, repo);
git_revwalk_push_ref(walker, tag_name.c_str());
git_oid id;
git_revwalk_next(&id, walker);
if (git_reference_create(&out, repo, tag_name.c_str(),&id, true,NULL) != 0) cerr << "error creating reference : " << tag_name << endl;
git_revwalk_free(walker);
git_reference_free(out);
答案 0 :(得分:0)
我明白了
git_reference * out;
git_oid oid;
tag_name = "refs/tags/v1.0";
if (git_reference_name_to_id(&oid, repo, "HEAD")!=0) cerr << "error git_reference_name_to_id()" << endl;
if (git_reference_create(&out, repo, tag_name.c_str(), &oid, true, NULL)!= 0) cerr << "error creating reference : " << tag_name << endl;
git_reference_free(out);