Пример #1
0
int git_error_set_regex(const p_regex_t *regex, int error_code)
{
	char error_buf[1024];

	assert(error_code);

	p_regerror(error_code, regex, error_buf, sizeof(error_buf));
	git_error_set_str(GIT_ERROR_REGEX, error_buf);

	if (error_code == P_REG_NOMATCH)
		return GIT_ENOTFOUND;

	return GIT_EINVALIDSPEC;
}
Пример #2
0
// callback: tries the access_token passed in through the payload ONCE
//           and returns GIT_EAUTH if called for a second time
int cb_cred_access_token(git_cred **out, const char *url, const char *username_from_url,
  unsigned int allowed_types, void *payload) {

  GIT_UNUSED(url);
  GIT_UNUSED(username_from_url);

  if (allowed_types & GIT_CREDTYPE_USERPASS_PLAINTEXT) {
    struct credentials_s *credentials = payload;

    if (credentials->count > 0) {
      git_error_set_str(GIT_ERROR_CALLBACK, "Invalid token");
      return GIT_EAUTH;
    } else {
      credentials->count++;
      return git_cred_userpass_plaintext_new(out, "x-access-token", credentials->access_token);
    }
  }

  return GIT_PASSTHROUGH;
}
Пример #3
0
void giterr_set_str(int error_class, const char *string)
{
	git_error_set_str(error_class, string);
}