예제 #1
0
파일: dlggit.cpp 프로젝트: yfvc/dlggit
int CDlggitApp::ExitInstance() 
{
	// TODO: Add your specialized code here and/or call the base class
	git_threads_shutdown();
	
	return CWinApp::ExitInstance();
}
예제 #2
0
파일: rev-parse.c 프로젝트: aep/libgit2
int main(int argc, char *argv[])
{
	int i;
	char *a;
	struct parse_state ps;

	git_threads_init();

	memset(&ps, 0, sizeof(ps));

	for (i = 1; i < argc; ++i) {
		a = argv[i];

		if (a[0] != '-') {
			if (parse_revision(&ps, a) != 0)
				break;
		} else if (!strcmp(a, "--not"))
			ps.not = !ps.not;
		else if (!strncmp(a, "--git-dir=", strlen("--git-dir=")))
			ps.repodir = a + strlen("--git-dir=");
		else
			usage("Cannot handle argument", a);
	}

	git_repository_free(ps.repo);
	git_threads_shutdown();

	return 0;
}
예제 #3
0
int main(int argc, char** argv){
  setlocale(LC_ALL, "en_US.utf8");  
  initial_check();
  get_files_list();

  ESCDELAY = 1;
  menu_index = 0;
  previous_index = -1;
  
  initscr();
  noecho();
  keypad(stdscr, TRUE);
  getmaxyx(stdscr,rows,cols);
  diff_col_width = cols/2-1;
  start_color();
  use_default_colors();
  init_pair(1, COLOR_RED,     -1);
  init_pair(2, COLOR_GREEN,   -1);
  init_pair(3, COLOR_CYAN,    -1);
  refresh();

  print_files_menu();
  show_git_diff();

  ch = getch();  
  while(ch != 27 && ch != 'q'){
    switch(ch){
      case KEY_UP: 
        move_menu(-1);
        break;
      case KEY_DOWN: 
        move_menu(1);
        break;
      case 'h':
        show_help();
        break;
      case '?':
        show_help();
        break;
      case ' ':
        check_row();
        break;
      case 'a':
        check_all();
        break;
      case 'c':
        open_system_index_add_window();
        break;
    }
    ch = getch();  
  }
  
  endwin();
  git_threads_shutdown();
  return(EXIT_SUCCESS);
}
예제 #4
0
파일: basic.c 프로젝트: SeijiIto/libgit2
void test_threads_basic__multiple_init(void)
{
	git_repository *nested_repo;

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

	git_threads_shutdown();
	cl_git_pass(git_repository_open(&nested_repo, cl_fixture("testrepo.git")));
	git_repository_free(nested_repo);
}
예제 #5
0
파일: describe.c 프로젝트: ahfytao/libgit2
int main(int argc, char **argv)
{
	git_repository *repo;
	describe_options opts;

	git_threads_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_threads_shutdown();

	return 0;
}
예제 #6
0
파일: add.c 프로젝트: DaneTheory/libgit2
int main (int argc, char** argv)
{
	git_index_matched_path_cb matched_cb = NULL;
	git_repository *repo = NULL;
	git_index *index;
	git_strarray array = {0};
	int options = 0, count = 0;
	struct print_payload payload = {0};

	git_threads_init();

	parse_opts(&options, &count, argc, argv);

	init_array(&array, argc-count, argv+count);

	check_lg2(git_repository_open(&repo, "."), "No git repository", NULL);
	check_lg2(git_repository_index(&index, repo), "Could not open repository index", NULL);

	if (options&VERBOSE || options&SKIP) {
		matched_cb = &print_matched_cb;
	}

	payload.options = options;
	payload.repo = repo;

	if (options&UPDATE) {
		git_index_update_all(index, &array, matched_cb, &payload);
	} else {
		git_index_add_all(index, &array, 0, matched_cb, &payload);
	}

	git_index_write(index);
	git_index_free(index);
	git_repository_free(repo);

	git_threads_shutdown();

	return 0;
}
예제 #7
0
파일: tag.c 프로젝트: DaneTheory/libgit2
int main(int argc, char **argv)
{
	git_repository *repo;
	tag_options opts;
	tag_action action;
	tag_state state;

	git_threads_init();

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

	tag_options_init(&opts);
	parse_options(&action, &opts, argc, argv);

	state.repo = repo;
	state.opts = &opts;
	action(&state);

	git_repository_free(repo);
	git_threads_shutdown();

	return 0;
}
예제 #8
0
Application::~Application()
{
    #ifdef WITH_LIBGIT2
        git_threads_shutdown();
    #endif
}
예제 #9
0
파일: level1.c 프로젝트: Posnet/gpu-cuda
int main (int argc, char **argv) {
    git_index *index = NULL;
    pthread_t updateThread, hashThread;
    int rc, difficulty;
    void *status;
    hash_args args;
    timing_info timing;
    git_oid curr_commit;

    reset_timing(&timing);

    pthread_mutex_init(&commit_mutex, NULL);
    pthread_mutex_init(&update_mutex, NULL);
    push_commit = NULL;

    difficulty = init_args(&args);
    init_git(&index);

    init_hasher(difficulty);

    check_updates();
    reset_hard();

    puts("Starting update thread");
    rc = pthread_create(&updateThread, NULL, check_updates_worker, NULL);
    if (rc){
        printf("ERROR creating update thread %d\n", rc);
        exit(-1);
    }

    signal (SIGINT, int_handler);

    while(!stop){
        start_timing(&timing);

        args.found = 0;

        time_point(&timing);

        pthread_mutex_lock(&commit_mutex);
        pthread_mutex_lock(&update_mutex);
        if(updated){
            reset_hard();
            updated = 0;
            push_commit = NULL;
        }
        pthread_mutex_unlock(&update_mutex);
        pthread_mutex_unlock(&commit_mutex);

        time_point(&timing);

        puts("Preparing index");
        prepare_index(index, args.msg);
        time_point(&timing);

        puts("Starting brute force thread");
        rc = pthread_create(&hashThread, NULL, force_hash, &args);

        time_point(&timing);

        if (rc){
            printf("ERROR creating hash thread %d\n", rc);
            stop = 1;
        } else {
            pthread_join(hashThread, &status);
        }

        time_point(&timing);

        if(!stop && !updated && args.found){
            puts("Found one!");

            while(push_commit){
                usleep(10);
            }

            time_point(&timing);

            if(!stop && !updated){
                pthread_mutex_lock(&commit_mutex);

                commit_result(args.msg, &curr_commit);
                push_commit = &curr_commit;

                pthread_mutex_unlock(&commit_mutex);
            }
        } else {
            puts("Reset while looking for a hash");
            time_point(&timing);
        }

        time_point(&timing);
        print_timing(&timing);
    }

    pthread_join(updateThread, &status);

    free_hasher();
    free(args.msg);

    git_index_free(index);
    git_repository_free(repo);

    git_threads_shutdown();

    return 0;
}
예제 #10
0
/** Entry point for this command */
int main(int argc, char *argv[])
{
	git_repository *repo;
	struct opts o = { ".", NULL, 0, 0 };
	git_object *obj = NULL;
	char oidstr[GIT_OID_HEXSZ + 1];

	git_threads_init();

	parse_opts(&o, argc, argv);

	check_lg2(git_repository_open_ext(&repo, o.dir, 0, NULL),
			"Could not open repository", NULL);
	check_lg2(git_revparse_single(&obj, repo, o.rev),
			"Could not resolve", o.rev);

	if (o.verbose) {
		char oidstr[GIT_OID_HEXSZ + 1];
		git_oid_tostr(oidstr, sizeof(oidstr), git_object_id(obj));

		printf("%s %s\n--\n",
			git_object_type2string(git_object_type(obj)), oidstr);
	}

	switch (o.action) {
	case SHOW_TYPE:
		printf("%s\n", git_object_type2string(git_object_type(obj)));
		break;
	case SHOW_SIZE: {
		git_odb *odb;
		git_odb_object *odbobj;

		check_lg2(git_repository_odb(&odb, repo), "Could not open ODB", NULL);
		check_lg2(git_odb_read(&odbobj, odb, git_object_id(obj)),
			"Could not find obj", NULL);

		printf("%ld\n", (long)git_odb_object_size(odbobj));

		git_odb_object_free(odbobj);
		git_odb_free(odb);
		}
		break;
	case SHOW_NONE:
		/* just want return result */
		break;
	case SHOW_PRETTY:

		switch (git_object_type(obj)) {
		case GIT_OBJ_BLOB:
			show_blob((const git_blob *)obj);
			break;
		case GIT_OBJ_COMMIT:
			show_commit((const git_commit *)obj);
			break;
		case GIT_OBJ_TREE:
			show_tree((const git_tree *)obj);
			break;
		case GIT_OBJ_TAG:
			show_tag((const git_tag *)obj);
			break;
		default:
			printf("unknown %s\n", oidstr);
			break;
		}
		break;
	}

	git_object_free(obj);
	git_repository_free(repo);

	git_threads_shutdown();

	return 0;
}
예제 #11
0
static void cleanup_cb(void *unused)
{
	(void)unused;
	git_threads_shutdown();
}
예제 #12
0
파일: cat-file.c 프로젝트: 0CV0/libgit2
int main(int argc, char *argv[])
{
	const char *dir = ".", *rev = NULL;
	int i, action = 0, verbose = 0;
	git_object *obj = NULL;
	char oidstr[GIT_OID_HEXSZ + 1];

	git_threads_init();

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

		if (a[0] != '-') {
			if (rev != NULL)
				usage("Only one rev should be provided", NULL);
			else
				rev = a;
		}
		else if (!strcmp(a, "-t"))
			action = SHOW_TYPE;
		else if (!strcmp(a, "-s"))
			action = SHOW_SIZE;
		else if (!strcmp(a, "-e"))
			action = SHOW_NONE;
		else if (!strcmp(a, "-p"))
			action = SHOW_PRETTY;
		else if (!strcmp(a, "-q"))
			verbose = 0;
		else if (!strcmp(a, "-v"))
			verbose = 1;
		else if (!strcmp(a, "--help") || !strcmp(a, "-h"))
			usage(NULL, NULL);
		else if (!check_str_param(a, "--git-dir=", &dir))
			usage("Unknown option", a);
	}

	if (!action || !rev)
		usage(NULL, NULL);

	check(git_repository_open_ext(&g_repo, dir, 0, NULL),
		"Could not open repository");

	if (git_revparse_single(&obj, g_repo, rev) < 0) {
		fprintf(stderr, "Could not resolve '%s'\n", rev);
		exit(1);
	}
	if (verbose) {
		char oidstr[GIT_OID_HEXSZ + 1];
		git_oid_tostr(oidstr, sizeof(oidstr), git_object_id(obj));

		printf("%s %s\n--\n",
			git_object_type2string(git_object_type(obj)), oidstr);
	}

	switch (action) {
	case SHOW_TYPE:
		printf("%s\n", git_object_type2string(git_object_type(obj)));
		break;
	case SHOW_SIZE: {
		git_odb *odb;
		git_odb_object *odbobj;

		check(git_repository_odb(&odb, g_repo), "Could not open ODB");
		check(git_odb_read(&odbobj, odb, git_object_id(obj)),
			"Could not find obj");

		printf("%ld\n", (long)git_odb_object_size(odbobj));

		git_odb_object_free(odbobj);
		git_odb_free(odb);
		}
		break;
	case SHOW_NONE:
		/* just want return result */
		break;
	case SHOW_PRETTY:

		switch (git_object_type(obj)) {
		case GIT_OBJ_BLOB:
			show_blob((const git_blob *)obj);
			break;
		case GIT_OBJ_COMMIT:
			show_commit((const git_commit *)obj);
			break;
		case GIT_OBJ_TREE:
			show_tree((const git_tree *)obj);
			break;
		case GIT_OBJ_TAG:
			show_tag((const git_tag *)obj);
			break;
		default:
			printf("unknown %s\n", oidstr);
			break;
		}
		break;
	}

	git_object_free(obj);
	git_repository_free(g_repo);

	git_threads_shutdown();

	return 0;
}
예제 #13
0
CTortoiseGitBlameApp::~CTortoiseGitBlameApp()
{
	git_threads_shutdown();
}
예제 #14
0
CTortoiseProcApp::~CTortoiseProcApp()
{
	CHooks::Destroy();
	SYS_IMAGE_LIST().Cleanup();
	git_threads_shutdown();
}
예제 #15
0
gitCore::~gitCore()
{
  git_threads_shutdown();
}