Esempio n. 1
0
File: git.c Progetto: ileitch/meanie
void mne_git_load_blobs(const char *path) {
  mne_git_initialize();

  printf("\nLoading blobs...\n\n");
  gettimeofday(&begin, NULL);

  git_repository_open(&repo, path);
  git_repository_odb(&odb, repo);

  git_strarray tag_names;
  git_tag_list(&tag_names, repo);

  total_refs = tag_names.count + 1; /* + 1 for HEAD. */
  ref_names = malloc(sizeof(char*) * total_refs);

  mne_git_walk_ctx ctx;
  ctx.bytes = 0;
  ctx.ref_index = 0;
  
  mne_git_walk_head(&ctx);
  mne_git_walk_tags(&ctx, &tag_names);

  git_strarray_free(&tag_names);
  git_repository_free(repo);

  gettimeofday(&end, NULL);

  float mb = ctx.bytes / 1048576.0;
  printf("\nLoaded %d blobs (%.2fmb) ", g_hash_table_size(blobs), mb);
  mne_print_duration(&end, &begin);
  printf(".\n");
}
Esempio n. 2
0
void MainWindow::on_pushButtonDir_clicked()
{
    QFileDialog dialog;
    dialog.setFileMode(QFileDialog::Directory);
    dialog.setOption(QFileDialog::ShowDirsOnly);
    int res = dialog.exec();
    if (res)
    {
        QString mypath = dialog.selectedFiles()[0];
        ui->textRepoLocation->setText(mypath);
        hasDir = true;
        const char* repo_dir = ui->textRepoLocation->text().toStdString().c_str();


        if (git_repository_open_ext(
                    NULL, repo_dir, GIT_REPOSITORY_OPEN_NO_SEARCH, NULL) == 0)
        {

            //!!!! so apparently the repo_dir value gets changed
            //! when you call open above to check things: .git gets appended to it, so ...
            //! this is ugly sandbox code anyway...

            repo_dir = ui->textRepoLocation->text().toStdString().c_str();
            int ret = git_repository_open(&repo, repo_dir);

            qDebug() << "opening existing repo at " << ui->textRepoLocation->text() << "ret = " << ret;

            ui->pushButtonInit->setDisabled(true);

            //load em tags

            ui->listRevisions->clear();
            git_strarray tags = {0};
            int error = git_tag_list(&tags, repo);
            qDebug() <<"found numTags =" <<tags.count;
            if (error == 0) {
                QString text_str;
                for (int i=0; i<tags.count; i++) {
                    text_str+=tags.strings[i];
                    text_str+="\n";
                    ui->listRevisions->addItem(tags.strings[i]);
                }
            }

            //look up commit info

            lookupCommits();

        }
        else {
            ui->pushButtonInit->setEnabled(true);
        }

    }
}
Esempio n. 3
0
File: list.c Progetto: 0CV0/libgit2
void test_object_tag_list__list_all(void)
{
	// list all tag names from the repository
	git_strarray tag_list;

	cl_git_pass(git_tag_list(&tag_list, g_repo));

	cl_assert_equal_i((int)tag_list.count, 6);

	git_strarray_free(&tag_list);
}
Esempio n. 4
0
void test_object_tag_read__list(void)
{
   // list all tag names from the repository
   git_strarray tag_list;

   cl_git_pass(git_tag_list(&tag_list, g_repo));

   cl_assert(tag_list.count == 3);

   git_strarray_free(&tag_list);
}
Esempio n. 5
0
void test_clone_nonetwork__custom_autotag(void)
{
	git_strarray tags = {0};

	g_options.remote_autotag = GIT_REMOTE_DOWNLOAD_TAGS_NONE;
	cl_git_pass(git_clone(&g_repo, cl_git_fixture_url("testrepo.git"), "./foo", &g_options));

	cl_git_pass(git_tag_list(&tags, g_repo));
	cl_assert_equal_sz(0, tags.count);

	git_strarray_free(&tags);
}
Esempio n. 6
0
emacs_value egit_tag_list(emacs_env *env, emacs_value _repo, emacs_value _pattern)
{
    EGIT_ASSERT_REPOSITORY(_repo);
    EM_ASSERT_STRING_OR_NIL(_pattern);
    git_repository *repo = EGIT_EXTRACT(_repo);
    char *pattern = EM_EXTRACT_STRING_OR_NULL(_pattern);

    git_strarray out = {NULL, 0};
    int retval = pattern ? git_tag_list_match(&out, pattern, repo) : git_tag_list(&out, repo);
    free(pattern);
    EGIT_CHECK_ERROR(retval);

    EGIT_RET_STRARRAY(out);
}
Esempio n. 7
0
void QGit::listBranchesAndTags()
{
    QList<QGitBranch> branches;
    git_repository *repo = nullptr;
    git_branch_iterator *it = nullptr;
    git_reference *ref = nullptr;
    git_branch_t type = GIT_BRANCH_ALL;
    git_strarray tag_names = {nullptr, 0};
    QList<QString> tags;
    int res = 0;

    QGitError error;

    try {

        res = git_repository_open(&repo, m_path.absolutePath().toUtf8().constData());
        if (res)
        {
            throw QGitError("git_repository_open", res);
        }

        res = git_branch_iterator_new(&it, repo, GIT_BRANCH_ALL);
        if (res)
        {
            throw QGitError("git_branch_iterator_new", res);
        }

        while(git_branch_next(&ref, &type, it) == 0)
        {
            const char *ref_name = git_reference_name(ref);

            QGitBranch branch = QGitBranch(ref_name, type);
            branches.append(branch);

            ref_name = nullptr;
            git_reference_free(ref);
            ref = nullptr;
        }

        res = git_tag_list(&tag_names, repo);
        if (res)
        {
            throw QGitError("git_tag_list", res);
        }

        for(size_t c = 0; c < tag_names.count; c++)
        {
            tags.append(QString::fromUtf8(tag_names.strings[c]));
        }


    } catch(const QGitError &ex) {
        error = ex;
    }

    emit listBranchesAndTagsReply(branches, tags, error);

    if (tag_names.strings)
    {
        git_strarray_free(&tag_names);
        tag_names = {nullptr, 0};
    }

    if(ref)
    {
        git_reference_free(ref);
        ref = nullptr;
    }

    if (it)
    {
        git_branch_iterator_free(it);
        it = nullptr;
    }

    if (repo)
    {
        git_repository_free(repo);
        repo = nullptr;
    }
}
Esempio n. 8
0
	must_be_true(commit != NULL);

	must_be_true(git_oid_cmp(&id_commit, git_commit_id(commit)) == 0);

	git_tag_close(tag1);
	git_tag_close(tag2);
	git_commit_close(commit);
	git_repository_free(repo);
END_TEST

BEGIN_TEST(read1, "list all tag names from the repository")
	git_repository *repo;
	git_strarray tag_list;

	must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
	must_pass(git_tag_list(&tag_list, repo));

	must_be_true(tag_list.count == 3);

	git_strarray_free(&tag_list);
	git_repository_free(repo);
END_TEST


#define TAGGER_NAME "Vicent Marti"
#define TAGGER_EMAIL "*****@*****.**"
#define TAGGER_MESSAGE "This is my tag.\n\nThere are many tags, but this one is mine\n"

BEGIN_TEST(write0, "write a tag to the repository and read it again")
	git_repository *repo;
	git_tag *tag;