Beispiel #1
0
int main(int argc, char *argv[]) {
    git_libgit2_init();
    git_repository *repo = NULL;
    git_diff *diff = NULL;

    const char *repo_path = "/home/nghia/.git_packages/cache/version-checker/.git";
    fprintf(stdout, "Current working dir: %s\n", repo_path);
    int error = git_repository_open(&repo, repo_path);
    fprintf(stdout, "error: %d\n", error);
    error = git_diff_index_to_workdir(&diff, repo, NULL, NULL);
    fprintf(stdout, "error: %d\n", error);
    git_diff_print(diff, GIT_DIFF_FORMAT_PATCH, color_printer, NULL);
    git_diff_free(diff);
    git_libgit2_shutdown();
    return 0;



//    error = git_diff_index_to_workdir(&diff, repo, NULL, NULL);
//	struct opts o = {
//		GIT_DIFF_OPTIONS_INIT, GIT_DIFF_FIND_OPTIONS_INIT,
//		-1, 0, 0, GIT_DIFF_FORMAT_PATCH, NULL, NULL, "."
//	};

//	git_libgit2_init();
}
Beispiel #2
0
void initGit()
{
	static bool haveInitialized = false;
	if (!haveInitialized) {
		git_libgit2_init();
	}
}
CTortoiseMergeApp::CTortoiseMergeApp()
	: m_nAppLook(0)
{
	EnableHtmlHelp();
	m_bHiColorIcons = TRUE;
	git_libgit2_init();
}
Beispiel #4
0
int main(int argc, char *argv[])
#endif
{
	int res;

#if defined(GIT_MSVC_CRTDBG)
	_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);

	_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
	_CrtSetReportMode(_CRT_ERROR,  _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
	_CrtSetReportMode(_CRT_WARN,   _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);

	_CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
	_CrtSetReportFile(_CRT_ERROR,  _CRTDBG_FILE_STDERR);
	_CrtSetReportFile(_CRT_WARN,   _CRTDBG_FILE_STDERR);
#endif

	clar_test_init(argc, argv);

	git_libgit2_init();
	cl_global_trace_register();
	cl_sandbox_set_search_path_defaults();

	/* Run the test suite */
	res = clar_test_run();

	clar_test_shutdown();

	cl_global_trace_disable();
	git_libgit2_shutdown();

	return res;
}
Beispiel #5
0
GitRepository::GitRepository(const QString &localDirPath)
    : m_local_dir_path(localDirPath),
      m_repo(NULL),
      m_signature(NULL)
{
    git_libgit2_init();
}
Beispiel #6
0
void RTXIWizard::Panel::initParameters(void)
{

#if LIBGIT2_SOVERSION >= 22
	git_libgit2_init();
#else
	git_threads_init();
#endif

	// syntax here only works in c++11
	exclude_list = std::vector<QString> ({ 
			QString("rtxi"),
			QString("rtxi.github.io"),
			QString("genicam-camera"),
			QString("rtxi-crawler"),
			QString("matlab-tools"),
			QString("tutorials"),
			QString("autapse"),
			QString("camera-control"),
			QString("gen-net"),
			QString("dynamo-examples"),
			QString("plot-lib"),
			QString("python-plugin"),
			QString("poster"),
			QString("user-manual"),
			QString("logos"),
			QString("live-image"),
			QString("conference-2015")
			});
	button_mode = DOWNLOAD;

}
Beispiel #7
0
int main(int argc, char *argv[])
#endif
{
	int res;
	char *at_exit_cmd;

	clar_test_init(argc, argv);

	res = git_libgit2_init();
	if (res < 0) {
		fprintf(stderr, "failed to init libgit2");
		return res;
	}

	cl_global_trace_register();
	cl_sandbox_set_search_path_defaults();

	/* Run the test suite */
	res = clar_test_run();

	clar_test_shutdown();

	cl_global_trace_disable();
	git_libgit2_shutdown();

	at_exit_cmd = getenv("CLAR_AT_EXIT");
	if (at_exit_cmd != NULL) {
		int at_exit = system(at_exit_cmd);
		return res || at_exit;
	}

	return res;
}
void CacheGitDirectory::updateRef() {
  currentGitRef_ = "";
  git_repository *repo = NULL;
  git_reference *head = NULL;

  git_libgit2_init();
  int r = git_repository_open(&repo, gitRepository_.c_str());
  if (r != 0) {
    LOG(INFO) << "Cannot open git repository " << gitRepository_;
    goto cleanup;
  }

  if (git_repository_head_detached(repo)) {
    LOG(INFO) << "We are in detached state";
    goto cleanup;
  }

  r = git_repository_head(&head, repo);
  if (r != 0) {
    LOG(INFO) << "Cannot get current ref head";
    goto cleanup;
  }

  currentGitRef_ = git_reference_name(head);
  LOG(INFO) << "found ref: " << currentGitRef_;

cleanup:
  git_repository_free(repo);
  git_libgit2_shutdown();
}
Beispiel #9
0
int main()
{
    git_libgit2_init();

    git_repository* rep = nullptr;

    git_remote* remote = nullptr;
    git_push_options opts = GIT_PUSH_OPTIONS_INIT;

    int error = 0;

    // git open
    git_repository_open(&rep, path);

    // take remote
    git_remote_lookup(&remote, rep, "origin");

    const char *refs[] = {"refs/heads/master:refs/heads/master"};
    git_strarray strarr = {(char**)refs, 1};

    opts.callbacks.credentials = cred_acquire_cb;
    error = git_remote_push(remote, &strarr, &opts);
    if (error < 0)
    {
        const git_error *e = giterr_last();
        std::cout << "Error: " << error << " / " << e->klass << " : " << e->message << std::endl;

        goto SHUTDOWN;
    }

SHUTDOWN:
    git_repository_free(rep);
    git_libgit2_shutdown();
}
bool CacheGitDirectory::checkIsGitRepository() const {
  git_libgit2_init();
  git_repository *repo = NULL;
  bool found = !git_repository_open(&repo, gitRepository_.c_str());
  git_repository_free(repo);
  git_libgit2_shutdown();
  return found;
}
Beispiel #11
0
int main(int argc, char **argv)
{
	int i;
	bool no_filenames = true;

	init_qt(&argc, &argv);
	QStringList files;
	QStringList importedFiles;
	QStringList arguments = QCoreApplication::arguments();

	bool dedicated_console = arguments.length() > 1 &&
				 (arguments.at(1) == QString("--win32console"));
	subsurface_console_init(dedicated_console);

	for (i = 1; i < arguments.length(); i++) {
		QString a = arguments.at(i);
		if (a.at(0) == '-') {
			parse_argument(a.toLocal8Bit().data());
			continue;
		}
		if (imported) {
			importedFiles.push_back(a);
		} else {
			no_filenames = false;
			files.push_back(a);
		}
	}
#if !LIBGIT2_VER_MAJOR && LIBGIT2_VER_MINOR < 22
	git_threads_init();
#else
	git_libgit2_init();
#endif
	setup_system_prefs();
	prefs = default_prefs;
	fill_profile_color();
	parse_xml_init();
	taglist_init_global();
	init_ui();
	if (no_filenames) {
		QString defaultFile(prefs.default_filename);
		if (!defaultFile.isEmpty())
			files.push_back(QString(prefs.default_filename));
	}

	MainWindow *m = MainWindow::instance();
	m->setLoadedWithFiles(!files.isEmpty() || !importedFiles.isEmpty());
	m->loadFiles(files);
	m->importFiles(importedFiles);
	if (!quit)
		run_ui();
	exit_ui();
	taglist_free(g_tag_list);
	parse_xml_exit();
	subsurface_console_exit();
	free_prefs();
	return 0;
}
Beispiel #12
0
int main(int argc, char **argv)
{
        struct stat st;
        struct timeval start, end;
        char filepath[1024], repodir[64];
        char *dirpath, *filename, *ref = NULL;

        if (argc != 3) {
                fprintf(stderr, "Usage: ./log dirpath filename\n");
                exit(-1);
        }

        dirpath = argv[1];
        filename = argv[2];
        strcpy(repodir, dirpath);
        strcat(repodir, "/.git");
        strcpy(filepath, dirpath);
        strcat(filepath, "/");
        strcat(filepath, filename);
        if (stat(filepath, &st) < 0) {
                fprintf(stderr, "Not valid file path: \"%s\"!\n", filepath);
                exit(-2);
        }

        memset(&s, 0, sizeof(s));
        s.sorting = GIT_SORT_TIME;
        s.hide = 0;
        s.repodir = strlen(repodir) > 0  ? repodir : "/tmp/git/.git";
        s.ref = ref ? ref : "refs/heads/master";

        /* Init libgit2 library */
        git_libgit2_init();

        /* Open repo. */
        check_lg2(git_repository_open_ext(&s.repo, s.repodir, 0, NULL),
                "Could not open repository", s.repodir);

	/* Create revwalker. */
        check_lg2(git_revwalk_new(&s.walker, s.repo),
                "Could not create revision walker", NULL);
        git_revwalk_sorting(s.walker, s.sorting);

        /* Show file's latest commit. */
        printf("filename: %s\n", filename);
        gettimeofday(&start, NULL);
        git_show_last_commit(filename);
        gettimeofday(&end, NULL);
        printf("time span: %ld(ms)\n", (end.tv_sec - start.tv_sec) * 1000 + \
                        (end.tv_usec - start.tv_usec) / 1000);

	git_revwalk_free(s.walker);
	git_repository_free(s.repo);
	git_libgit2_shutdown();

        return 0;
}
Beispiel #13
0
int configctl_git_open()
{
	int error;

	git_libgit2_init();
	error = git_repository_open(&repo, repo_path);
	check_error(error, "opening repository");

	return error;
}
Beispiel #14
0
int _tmain(int argc, _TCHAR* argv[])
{
	git_libgit2_init();
	// Since Google Mock depends on Google Test, InitGoogleMock() is
	// also responsible for initializing Google Test. Therefore there's
	// no need for calling testing::InitGoogleTest() separately.
	testing::InitGoogleMock(&argc, argv);
	int result = RUN_ALL_TESTS();
	git_libgit2_shutdown();
	return result;
}
Beispiel #15
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    git_libgit2_init();
    hasDir = false;
    git_repository* repo = NULL;

    ui->pushButtonInit->setDisabled(true); //don't allow init on start
}
Beispiel #16
0
void test_threads_basic__multiple_init(void)
{
	git_repository *nested_repo;

	git_libgit2_init();
	cl_git_pass(git_repository_open(&nested_repo, cl_fixture("testrepo.git")));
	git_repository_free(nested_repo);

	git_libgit2_shutdown();
	cl_git_pass(git_repository_open(&nested_repo, cl_fixture("testrepo.git")));
	git_repository_free(nested_repo);
}
Beispiel #17
0
int main(int argc, char **argv)
{
	int i;
	int return_code = 1;
	int error;
	git_repository *repo;
	struct args_info args = ARGS_INFO_INIT;
	const char *git_dir = NULL;

	if (argc < 2) {
		fprintf(stderr, "usage: %s <cmd> [repo]\n", argv[0]);
		exit(EXIT_FAILURE);
	}

	git_libgit2_init();

	for (args.pos = 1; args.pos < args.argc; ++args.pos) {
		char *a = args.argv[args.pos];

		if (a[0] != '-') {
			/* non-arg */
			break;
		} else if (optional_str_arg(&git_dir, &args, "--git-dir", ".git")) {
			continue;
		} else if (!strcmp(a, "--")) {
			/* arg separator */
			break;
		}
	}

	/* Before running the actual command, create an instance of the local
	 * repository and pass it to the function. */

	error = git_repository_open(&repo, git_dir);
	if (error < 0)
		repo = NULL;

	for (i = 0; commands[i].name != NULL; ++i) {
		if (!strcmp(args.argv[args.pos], commands[i].name)) {
			return_code = run_command(commands[i].fn, repo, args);
			goto shutdown;
		}
	}

	fprintf(stderr, "Command not found: %s\n", argv[1]);

shutdown:
	git_repository_free(repo);

	git_libgit2_shutdown();

	return return_code;
}
Beispiel #18
0
int main(void)
{
   git_libgit2_init();

   git_repository *repo;
   const char *path = "/home/pcarphin/Documents/GitHub/tests/C_tests/libgit2/.git";
   git_repository_init(&repo, path, 0);

   nftw(path, unlink_callback, 64, FTW_DEPTH | FTW_PHYS);

   return 0;
}
CTortoiseGitBlameApp::CTortoiseGitBlameApp()
{
	SetDllDirectory(L"");
	SetTaskIDPerUUID();
#if ENABLE_CRASHHANLDER
	CCrashReportTGit crasher(L"TortoiseGitBlame " _T(APP_X64_STRING), TGIT_VERMAJOR, TGIT_VERMINOR, TGIT_VERMICRO, TGIT_VERBUILD, TGIT_VERDATE);
	CCrashReport::Instance().AddUserInfoToReport(L"CommandLine", GetCommandLine());
#endif
	EnableHtmlHelp();
	git_libgit2_init();
	m_gdiplusToken = NULL;
	m_bHiColorIcons = TRUE;
}
Beispiel #20
0
//-----------------------------------------------------------------------------------------//
int AdVersion::gitInit(QString gitDirectory)
{

    int ierr;
    git_repository *repository;
    QByteArray tempData = gitDirectory.toLatin1();
    const char *cgitDirectory = tempData.data();

    git_libgit2_init();
    ierr = git_repository_init(&repository,cgitDirectory,0);
    git_repository_free(repository);
    git_libgit2_shutdown();
    return ERROR_NOERROR;
}
Beispiel #21
0
int configctl_git_create_config_dir(char *path)
{
	int rc = 0;
	git_repository *repo = NULL;

	git_libgit2_init();

	git_repository_init(&repo, path, 0);
	rc = create_initial_commit(repo);

	git_repository_free(repo);
	git_libgit2_shutdown();

	return rc;
}
Beispiel #22
0
static void AutomationMain()
{
	// initialize the COM library
	HRESULT hr = ::CoInitialize(nullptr);
	if (FAILED(hr))
		return;

	git_libgit2_init();

	RunOutprocServer();

	git_libgit2_shutdown();

	::CoUninitialize();
}
Beispiel #23
0
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppvOut)
{
	if (ppvOut == 0)
		return E_POINTER;
	*ppvOut = NULL;

	FileState state = FileStateInvalid;
	if (IsEqualIID(rclsid, CLSID_Tortoisegit_UPTODATE))
		state = FileStateVersioned;
	else if (IsEqualIID(rclsid, CLSID_Tortoisegit_MODIFIED))
		state = FileStateModified;
	else if (IsEqualIID(rclsid, CLSID_Tortoisegit_CONFLICTING))
		state = FileStateConflict;
	else if (IsEqualIID(rclsid, CLSID_Tortoisegit_UNCONTROLLED))
		state = FileStateUncontrolled;
	else if (IsEqualIID(rclsid, CLSID_Tortoisegit_DROPHANDLER))
		state = FileStateDropHandler;
	else if (IsEqualIID(rclsid, CLSID_Tortoisegit_DELETED))
		state = FileStateDeleted;
	else if (IsEqualIID(rclsid, CLSID_Tortoisegit_READONLY))
		state = FileStateReadOnly;
	else if (IsEqualIID(rclsid, CLSID_Tortoisegit_LOCKED))
		state = FileStateLockedOverlay;
	else if (IsEqualIID(rclsid, CLSID_Tortoisegit_ADDED))
		state = FileStateAddedOverlay;
	else if (IsEqualIID(rclsid, CLSID_Tortoisegit_IGNORED))
		state = FileStateIgnoredOverlay;
	else if (IsEqualIID(rclsid, CLSID_Tortoisegit_UNVERSIONED))
		state = FileStateUnversionedOverlay;

	if (state != FileStateInvalid)
	{
		CShellExtClassFactory *pcf = new (std::nothrow) CShellExtClassFactory(state);
		if (pcf == NULL)
			return E_OUTOFMEMORY;
		// refcount currently set to 0
		git_libgit2_init();
		const HRESULT hr = pcf->QueryInterface(riid, ppvOut);
		if(FAILED(hr))
			delete pcf;
		return hr;
	}

	return CLASS_E_CLASSNOTAVAILABLE;

}
Beispiel #24
0
SyncState::SyncState(StateStack& stack, Context& context)
: State(stack, context)
, m_thread(&SyncState::sync, this)
{
	m_textStatus.setCharacterSize(14);
	m_textStatus.setFillColor(cpp3ds::Color::White);
	m_textStatus.setOutlineColor(cpp3ds::Color(0, 0, 0, 70));
	m_textStatus.setOutlineThickness(2.f);
	m_textStatus.setPosition(160.f, 155.f);
	TweenEngine::Tween::to(m_textStatus, util3ds::TweenText::OUTLINE_COLOR_ALPHA, 0.15f)
			.target(90)
			.repeatYoyo(-1, 0)
			.start(m_tweenManager);

	git_libgit2_init();
	m_thread.launch();
}
Beispiel #25
0
int QGit::createLocalRepository(const QDir &path)
{
    git_repository *repo = nullptr;
    int err = 0;

    git_libgit2_init();

    err = git_repository_init(&repo, path.absolutePath().toUtf8().constData(), 0);

    if (repo)
    {
        git_repository_free(repo);
        repo = nullptr;
    }

    git_libgit2_shutdown();

    return err;
}
Beispiel #26
0
QString QGit::getBranchNameFromPath(const QString &path)
{
    git_repository *repo = nullptr;
    git_reference *ref = nullptr;
    int result = 0;
    const char *branch = nullptr;
    QString ret;

    git_libgit2_init();

    result = git_repository_open(&repo, path.toUtf8().constData());
    if (result)
    {
        goto cleanup;
    }

    result = git_repository_head(&ref, repo);
    if (result)
    {
        goto cleanup;
    }

    git_branch_name(&branch, ref);
    ret = branch;

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

    if (repo)
    {
        git_repository_free(repo);
        repo = nullptr;
    }

    git_libgit2_shutdown();

    return ret;
}
Beispiel #27
0
int main(int argc, char **argv) {
    if (argc < 2) {
        printf("Usage: %s <repo url>\n", argv[0]);
        return 1;
    }
    git_libgit2_init();

    git_repository *repo = NULL;
    git_clone_options opts = GIT_CLONE_OPTIONS_INIT;
    opts.repository_cb = repository_create_memory_cb;
    const char *url = argv[1];
    const char *path = "repo";
    int error = git_clone(&repo, url, path, &opts);
    if (error) {
        fprintf(stderr, "%s\n", giterr_last()->message);
    }

    git_libgit2_shutdown();
    return 0;
}
Beispiel #28
0
int main(int argc, char **argv)
{
	git_repository *repo;
	describe_options opts;

	git_libgit2_init();

	check_lg2(git_repository_open_ext(&repo, ".", 0, NULL),
			"Could not open repository", NULL);

	describe_options_init(&opts);
	parse_options(&opts, argc, argv);

	do_describe(repo, &opts);

	git_repository_free(repo);
	git_libgit2_shutdown();

	return 0;
}
Beispiel #29
0
int
main (int    argc,
      char **argv)
{
  GError *local_error = NULL;
  GError **error = &local_error;
  struct EvTag self = { NULL, };
  
  /* avoid gvfs (http://bugzilla.gnome.org/show_bug.cgi?id=526454) */
  g_setenv ("GIO_USE_VFS", "local", TRUE);

#ifdef HAVE_GIT_LIBGIT2_INIT
  git_libgit2_init ();
#else
  git_threads_init ();
#endif

  if (!submain (&self, argc, argv, error))
    goto out;

 out:
  if (self.top_repo)
    git_repository_free (self.top_repo);
  if (self.checksum)
    g_checksum_free (self.checksum);
  if (local_error)
    {
      int is_tty = isatty (1);
      const char *prefix = "";
      const char *suffix = "";
      if (is_tty)
        {
          prefix = "\x1b[31m\x1b[1m"; /* red, bold */
          suffix = "\x1b[22m\x1b[0m"; /* bold off, color reset */
        }
      g_printerr ("%serror: %s%s\n", prefix, suffix, local_error->message);
      g_error_free (local_error);
      return 1;
    }
  return 0;
}
Beispiel #30
0
Status
syncInit(const char *szCaCertPath)
{
    AutoSyncLock lock(gSyncMutex);

    if (gbInitialized)
        return ABC_ERROR(ABC_CC_Reinitialization,
                         "ABC_Sync has already been initalized");

    ABC_CHECK_GIT(git_libgit2_init());
    gbInitialized = true;

    if (szCaCertPath)
        ABC_CHECK_GIT(git_libgit2_opts(GIT_OPT_SET_SSL_CERT_LOCATIONS, szCaCertPath,
                                       nullptr));

    // Choose a random server to start with:
    syncServerIndex = time(nullptr);

    return Status();
}