Commit 4aa7de15 by Russell Belfer

Convert indexer, notes, sha1_lookup, and signature

More files moved to new error handling style.
parent 7c7ff7d1
...@@ -49,17 +49,22 @@ static int parse_header(git_indexer *idx) ...@@ -49,17 +49,22 @@ static int parse_header(git_indexer *idx)
int error; int error;
/* Verify we recognize this pack file format. */ /* Verify we recognize this pack file format. */
if ((error = p_read(idx->pack->mwf.fd, &idx->hdr, sizeof(idx->hdr))) < GIT_SUCCESS) if ((error = p_read(idx->pack->mwf.fd, &idx->hdr, sizeof(idx->hdr))) < 0) {
return git__rethrow(error, "Failed to read in pack header"); giterr_set(GITERR_OS, "Failed to read in pack header");
return error;
if (idx->hdr.hdr_signature != ntohl(PACK_SIGNATURE)) }
return git__throw(GIT_EOBJCORRUPTED, "Wrong pack signature");
if (!pack_version_ok(idx->hdr.hdr_version)) if (idx->hdr.hdr_signature != ntohl(PACK_SIGNATURE)) {
return git__throw(GIT_EOBJCORRUPTED, "Wrong pack version"); giterr_set(GITERR_INVALID, "Wrong pack signature");
return -1;
}
if (!pack_version_ok(idx->hdr.hdr_version)) {
giterr_set(GITERR_INVALID, "Wrong pack version");
return -1;
}
return GIT_SUCCESS; return 0;
} }
static int objects_cmp(const void *a, const void *b) static int objects_cmp(const void *a, const void *b)
...@@ -87,49 +92,43 @@ int git_indexer_new(git_indexer **out, const char *packname) ...@@ -87,49 +92,43 @@ int git_indexer_new(git_indexer **out, const char *packname)
assert(out && packname); assert(out && packname);
if (git_path_root(packname) < 0) if (git_path_root(packname) < 0) {
return git__throw(GIT_EINVALIDPATH, "Path is not absolute"); giterr_set(GITERR_INVALID, "Path is not absolute");
return -1;
idx = git__malloc(sizeof(git_indexer)); }
if (idx == NULL)
return GIT_ENOMEM;
memset(idx, 0x0, sizeof(*idx)); idx = git__calloc(1, sizeof(git_indexer));
GITERR_CHECK_ALLOC(idx);
namelen = strlen(packname); namelen = strlen(packname);
idx->pack = git__malloc(sizeof(struct git_pack_file) + namelen + 1); idx->pack = git__calloc(1, sizeof(struct git_pack_file) + namelen + 1);
if (idx->pack == NULL) { GITERR_CHECK_ALLOC(idx->pack);
error = GIT_ENOMEM;
goto cleanup;
}
memset(idx->pack, 0x0, sizeof(struct git_pack_file));
memcpy(idx->pack->pack_name, packname, namelen + 1); memcpy(idx->pack->pack_name, packname, namelen + 1);
ret = p_stat(packname, &idx->st); if ((ret = p_stat(packname, &idx->st)) < 0) {
if (ret < 0) { if (errno == ENOENT) {
if (errno == ENOENT) giterr_set(GITERR_OS, "Failed to stat packfile. File not found");
error = git__throw(GIT_ENOTFOUND, "Failed to stat packfile. File not found"); error = GIT_ENOTFOUND;
else } else {
error = git__throw(GIT_EOSERR, "Failed to stat packfile."); giterr_set(GITERR_OS, "Failed to stat packfile.");
error = -1;
}
goto cleanup; goto cleanup;
} }
ret = p_open(idx->pack->pack_name, O_RDONLY); if ((ret = p_open(idx->pack->pack_name, O_RDONLY)) < 0) {
if (ret < 0) { giterr_set(GITERR_OS, "Failed to open packfile.");
error = git__throw(GIT_EOSERR, "Failed to open packfile"); error = -1;
goto cleanup; goto cleanup;
} }
idx->pack->mwf.fd = ret; idx->pack->mwf.fd = ret;
idx->pack->mwf.size = (git_off_t)idx->st.st_size; idx->pack->mwf.size = (git_off_t)idx->st.st_size;
error = parse_header(idx); if ((error = parse_header(idx)) < 0)
if (error < GIT_SUCCESS) {
error = git__rethrow(error, "Failed to parse packfile header");
goto cleanup; goto cleanup;
}
idx->nr_objects = ntohl(idx->hdr.hdr_entries); idx->nr_objects = ntohl(idx->hdr.hdr_entries);
...@@ -137,17 +136,17 @@ int git_indexer_new(git_indexer **out, const char *packname) ...@@ -137,17 +136,17 @@ int git_indexer_new(git_indexer **out, const char *packname)
assert(idx->nr_objects == (size_t)((unsigned int)idx->nr_objects)); assert(idx->nr_objects == (size_t)((unsigned int)idx->nr_objects));
error = git_vector_init(&idx->pack->cache, (unsigned int)idx->nr_objects, cache_cmp); error = git_vector_init(&idx->pack->cache, (unsigned int)idx->nr_objects, cache_cmp);
if (error < GIT_SUCCESS) if (error < 0)
goto cleanup; goto cleanup;
idx->pack->has_cache = 1; idx->pack->has_cache = 1;
error = git_vector_init(&idx->objects, (unsigned int)idx->nr_objects, objects_cmp); error = git_vector_init(&idx->objects, (unsigned int)idx->nr_objects, objects_cmp);
if (error < GIT_SUCCESS) if (error < 0)
goto cleanup; goto cleanup;
*out = idx; *out = idx;
return GIT_SUCCESS; return 0;
cleanup: cleanup:
git_indexer_free(idx); git_indexer_free(idx);
...@@ -165,8 +164,8 @@ static int index_path(git_buf *path, git_indexer *idx) ...@@ -165,8 +164,8 @@ static int index_path(git_buf *path, git_indexer *idx)
slash--; slash--;
if (git_buf_grow(path, slash + 1 + strlen(prefix) + if (git_buf_grow(path, slash + 1 + strlen(prefix) +
GIT_OID_HEXSZ + strlen(suffix) + 1) < GIT_SUCCESS) GIT_OID_HEXSZ + strlen(suffix) + 1) < 0)
return GIT_ENOMEM; return -1;
git_buf_truncate(path, slash); git_buf_truncate(path, slash);
git_buf_puts(path, prefix); git_buf_puts(path, prefix);
...@@ -174,10 +173,7 @@ static int index_path(git_buf *path, git_indexer *idx) ...@@ -174,10 +173,7 @@ static int index_path(git_buf *path, git_indexer *idx)
path->size += GIT_OID_HEXSZ; path->size += GIT_OID_HEXSZ;
git_buf_puts(path, suffix); git_buf_puts(path, suffix);
if (git_buf_oom(path)) return git_buf_oom(path) ? -1 : 0;
return GIT_ENOMEM;
return 0;
} }
int git_indexer_write(git_indexer *idx) int git_indexer_write(git_indexer *idx)
...@@ -197,26 +193,25 @@ int git_indexer_write(git_indexer *idx) ...@@ -197,26 +193,25 @@ int git_indexer_write(git_indexer *idx)
git_buf_sets(&filename, idx->pack->pack_name); git_buf_sets(&filename, idx->pack->pack_name);
git_buf_truncate(&filename, filename.size - strlen("pack")); git_buf_truncate(&filename, filename.size - strlen("pack"));
git_buf_puts(&filename, "idx"); git_buf_puts(&filename, "idx");
if (git_buf_oom(&filename)) if (git_buf_oom(&filename))
return GIT_ENOMEM; return -1;
error = git_filebuf_open(&idx->file, filename.ptr, GIT_FILEBUF_HASH_CONTENTS); error = git_filebuf_open(&idx->file, filename.ptr, GIT_FILEBUF_HASH_CONTENTS);
if (error < GIT_SUCCESS) if (error < 0)
goto cleanup; goto cleanup;
/* Write out the header */ /* Write out the header */
hdr.idx_signature = htonl(PACK_IDX_SIGNATURE); hdr.idx_signature = htonl(PACK_IDX_SIGNATURE);
hdr.idx_version = htonl(2); hdr.idx_version = htonl(2);
error = git_filebuf_write(&idx->file, &hdr, sizeof(hdr)); error = git_filebuf_write(&idx->file, &hdr, sizeof(hdr));
if (error < GIT_SUCCESS) if (error < 0)
goto cleanup; goto cleanup;
/* Write out the fanout table */ /* Write out the fanout table */
for (i = 0; i < 256; ++i) { for (i = 0; i < 256; ++i) {
uint32_t n = htonl(idx->fanout[i]); uint32_t n = htonl(idx->fanout[i]);
error = git_filebuf_write(&idx->file, &n, sizeof(n)); error = git_filebuf_write(&idx->file, &n, sizeof(n));
if (error < GIT_SUCCESS) if (error < 0)
goto cleanup; goto cleanup;
} }
...@@ -225,7 +220,7 @@ int git_indexer_write(git_indexer *idx) ...@@ -225,7 +220,7 @@ int git_indexer_write(git_indexer *idx)
git_vector_foreach(&idx->objects, i, entry) { git_vector_foreach(&idx->objects, i, entry) {
error = git_filebuf_write(&idx->file, &entry->oid, sizeof(git_oid)); error = git_filebuf_write(&idx->file, &entry->oid, sizeof(git_oid));
SHA1_Update(&ctx, &entry->oid, GIT_OID_RAWSZ); SHA1_Update(&ctx, &entry->oid, GIT_OID_RAWSZ);
if (error < GIT_SUCCESS) if (error < 0)
goto cleanup; goto cleanup;
} }
SHA1_Final(idx->hash.id, &ctx); SHA1_Final(idx->hash.id, &ctx);
...@@ -233,7 +228,7 @@ int git_indexer_write(git_indexer *idx) ...@@ -233,7 +228,7 @@ int git_indexer_write(git_indexer *idx)
/* Write out the CRC32 values */ /* Write out the CRC32 values */
git_vector_foreach(&idx->objects, i, entry) { git_vector_foreach(&idx->objects, i, entry) {
error = git_filebuf_write(&idx->file, &entry->crc, sizeof(uint32_t)); error = git_filebuf_write(&idx->file, &entry->crc, sizeof(uint32_t));
if (error < GIT_SUCCESS) if (error < 0)
goto cleanup; goto cleanup;
} }
...@@ -247,7 +242,7 @@ int git_indexer_write(git_indexer *idx) ...@@ -247,7 +242,7 @@ int git_indexer_write(git_indexer *idx)
n = htonl(entry->offset); n = htonl(entry->offset);
error = git_filebuf_write(&idx->file, &n, sizeof(uint32_t)); error = git_filebuf_write(&idx->file, &n, sizeof(uint32_t));
if (error < GIT_SUCCESS) if (error < 0)
goto cleanup; goto cleanup;
} }
...@@ -262,7 +257,7 @@ int git_indexer_write(git_indexer *idx) ...@@ -262,7 +257,7 @@ int git_indexer_write(git_indexer *idx)
split[1] = htonl(entry->offset_long & 0xffffffff); split[1] = htonl(entry->offset_long & 0xffffffff);
error = git_filebuf_write(&idx->file, &split, sizeof(uint32_t) * 2); error = git_filebuf_write(&idx->file, &split, sizeof(uint32_t) * 2);
if (error < GIT_SUCCESS) if (error < 0)
goto cleanup; goto cleanup;
} }
...@@ -271,7 +266,7 @@ int git_indexer_write(git_indexer *idx) ...@@ -271,7 +266,7 @@ int git_indexer_write(git_indexer *idx)
packfile_hash = git_mwindow_open(&idx->pack->mwf, &w, idx->st.st_size - GIT_OID_RAWSZ, GIT_OID_RAWSZ, &left); packfile_hash = git_mwindow_open(&idx->pack->mwf, &w, idx->st.st_size - GIT_OID_RAWSZ, GIT_OID_RAWSZ, &left);
git_mwindow_close(&w); git_mwindow_close(&w);
if (packfile_hash == NULL) { if (packfile_hash == NULL) {
error = git__rethrow(GIT_ENOMEM, "Failed to open window to packfile hash"); error = -1;
goto cleanup; goto cleanup;
} }
...@@ -280,19 +275,21 @@ int git_indexer_write(git_indexer *idx) ...@@ -280,19 +275,21 @@ int git_indexer_write(git_indexer *idx)
git_mwindow_close(&w); git_mwindow_close(&w);
error = git_filebuf_write(&idx->file, &file_hash, sizeof(git_oid)); error = git_filebuf_write(&idx->file, &file_hash, sizeof(git_oid));
if (error < 0)
goto cleanup;
/* Write out the index sha */ /* Write out the index sha */
error = git_filebuf_hash(&file_hash, &idx->file); error = git_filebuf_hash(&file_hash, &idx->file);
if (error < GIT_SUCCESS) if (error < 0)
goto cleanup; goto cleanup;
error = git_filebuf_write(&idx->file, &file_hash, sizeof(git_oid)); error = git_filebuf_write(&idx->file, &file_hash, sizeof(git_oid));
if (error < GIT_SUCCESS) if (error < 0)
goto cleanup; goto cleanup;
/* Figure out what the final name should be */ /* Figure out what the final name should be */
error = index_path(&filename, idx); error = index_path(&filename, idx);
if (error < GIT_SUCCESS) if (error < 0)
goto cleanup; goto cleanup;
/* Commit file */ /* Commit file */
...@@ -300,7 +297,7 @@ int git_indexer_write(git_indexer *idx) ...@@ -300,7 +297,7 @@ int git_indexer_write(git_indexer *idx)
cleanup: cleanup:
git_mwindow_free_all(&idx->pack->mwf); git_mwindow_free_all(&idx->pack->mwf);
if (error < GIT_SUCCESS) if (error < 0)
git_filebuf_cleanup(&idx->file); git_filebuf_cleanup(&idx->file);
git_buf_free(&filename); git_buf_free(&filename);
...@@ -319,8 +316,8 @@ int git_indexer_run(git_indexer *idx, git_indexer_stats *stats) ...@@ -319,8 +316,8 @@ int git_indexer_run(git_indexer *idx, git_indexer_stats *stats)
mwf = &idx->pack->mwf; mwf = &idx->pack->mwf;
error = git_mwindow_file_register(mwf); error = git_mwindow_file_register(mwf);
if (error < GIT_SUCCESS) if (error < 0)
return git__rethrow(error, "Failed to register mwindow file"); return error;
stats->total = (unsigned int)idx->nr_objects; stats->total = (unsigned int)idx->nr_objects;
stats->processed = processed = 0; stats->processed = processed = 0;
...@@ -346,27 +343,26 @@ int git_indexer_run(git_indexer *idx, git_indexer_stats *stats) ...@@ -346,27 +343,26 @@ int git_indexer_run(git_indexer *idx, git_indexer_stats *stats)
} }
error = git_packfile_unpack(&obj, idx->pack, &off); error = git_packfile_unpack(&obj, idx->pack, &off);
if (error < GIT_SUCCESS) { if (error < 0)
error = git__rethrow(error, "Failed to unpack object");
goto cleanup; goto cleanup;
}
/* FIXME: Parse the object instead of hashing it */ /* FIXME: Parse the object instead of hashing it */
error = git_odb__hashobj(&oid, &obj); error = git_odb__hashobj(&oid, &obj);
if (error < GIT_SUCCESS) { if (error < 0) {
error = git__rethrow(error, "Failed to hash object"); giterr_set(GITERR_INVALID, "Failed to hash object");
goto cleanup; goto cleanup;
} }
pentry = git__malloc(sizeof(struct git_pack_entry)); pentry = git__malloc(sizeof(struct git_pack_entry));
if (pentry == NULL) { if (pentry == NULL) {
error = GIT_ENOMEM; error = -1;
goto cleanup; goto cleanup;
} }
git_oid_cpy(&pentry->sha1, &oid); git_oid_cpy(&pentry->sha1, &oid);
pentry->offset = entry_start; pentry->offset = entry_start;
error = git_vector_insert(&idx->pack->cache, pentry); error = git_vector_insert(&idx->pack->cache, pentry);
if (error < GIT_SUCCESS) if (error < 0)
goto cleanup; goto cleanup;
git_oid_cpy(&entry->oid, &oid); git_oid_cpy(&entry->oid, &oid);
...@@ -375,7 +371,7 @@ int git_indexer_run(git_indexer *idx, git_indexer_stats *stats) ...@@ -375,7 +371,7 @@ int git_indexer_run(git_indexer *idx, git_indexer_stats *stats)
entry_size = (size_t)(off - entry_start); entry_size = (size_t)(off - entry_start);
packed = git_mwindow_open(mwf, &w, entry_start, entry_size, &left); packed = git_mwindow_open(mwf, &w, entry_start, entry_size, &left);
if (packed == NULL) { if (packed == NULL) {
error = git__rethrow(error, "Failed to open window to read packed data"); error = -1;
goto cleanup; goto cleanup;
} }
entry->crc = htonl(crc32(entry->crc, packed, (uInt)entry_size)); entry->crc = htonl(crc32(entry->crc, packed, (uInt)entry_size));
...@@ -383,10 +379,8 @@ int git_indexer_run(git_indexer *idx, git_indexer_stats *stats) ...@@ -383,10 +379,8 @@ int git_indexer_run(git_indexer *idx, git_indexer_stats *stats)
/* Add the object to the list */ /* Add the object to the list */
error = git_vector_insert(&idx->objects, entry); error = git_vector_insert(&idx->objects, entry);
if (error < GIT_SUCCESS) { if (error < 0)
error = git__rethrow(error, "Failed to add entry to list");
goto cleanup; goto cleanup;
}
for (i = oid.id[0]; i < 256; ++i) { for (i = oid.id[0]; i < 256; ++i) {
idx->fanout[i]++; idx->fanout[i]++;
......
...@@ -21,11 +21,8 @@ static int find_subtree(git_tree **subtree, const git_oid *root, ...@@ -21,11 +21,8 @@ static int find_subtree(git_tree **subtree, const git_oid *root,
*subtree = NULL; *subtree = NULL;
error = git_tree_lookup(&tree, repo, root); error = git_tree_lookup(&tree, repo, root);
if (error < GIT_SUCCESS) { if (error < 0)
if (error == GIT_ENOTFOUND) return error;
return error; /* notes tree doesn't exist yet */
return git__rethrow(error, "Failed to open notes tree");
}
for (i=0; i<git_tree_entrycount(tree); i++) { for (i=0; i<git_tree_entrycount(tree); i++) {
entry = git_tree_entry_byindex(tree, i); entry = git_tree_entry_byindex(tree, i);
...@@ -56,7 +53,7 @@ static int find_subtree(git_tree **subtree, const git_oid *root, ...@@ -56,7 +53,7 @@ static int find_subtree(git_tree **subtree, const git_oid *root,
} }
*subtree = tree; *subtree = tree;
return GIT_SUCCESS; return 0;
} }
static int find_blob(git_oid *blob, git_tree *tree, const char *target) static int find_blob(git_oid *blob, git_tree *tree, const char *target)
...@@ -71,7 +68,7 @@ static int find_blob(git_oid *blob, git_tree *tree, const char *target) ...@@ -71,7 +68,7 @@ static int find_blob(git_oid *blob, git_tree *tree, const char *target)
/* found matching note object - return */ /* found matching note object - return */
git_oid_cpy(blob, git_tree_entry_id(entry)); git_oid_cpy(blob, git_tree_entry_id(entry));
return GIT_SUCCESS; return 0;
} }
} }
return GIT_ENOTFOUND; return GIT_ENOTFOUND;
...@@ -93,18 +90,17 @@ static int note_write(git_oid *out, git_repository *repo, ...@@ -93,18 +90,17 @@ static int note_write(git_oid *out, git_repository *repo,
if (tree_sha) { if (tree_sha) {
error = find_subtree(&tree, tree_sha, repo, target, &fanout); error = find_subtree(&tree, tree_sha, repo, target, &fanout);
if (error < GIT_SUCCESS) if (error < 0)
return git__rethrow(error, "Failed to lookup subtree"); return error;
error = find_blob(&oid, tree, target + fanout); error = find_blob(&oid, tree, target + fanout);
if (error < GIT_SUCCESS && error != GIT_ENOTFOUND) { if (error != GIT_ENOTFOUND) {
git_tree_free(tree);
return git__throw(GIT_ENOTFOUND, "Failed to read subtree %s", target);
}
if (error == GIT_SUCCESS) {
git_tree_free(tree); git_tree_free(tree);
return git__throw(GIT_EEXISTS, "Note for `%s` exists already", target); if (!error) {
giterr_set(GITERR_REPOSITORY, "Note for '%s' exists already", target);
error = GIT_EEXISTS;
}
return error;
} }
} }
...@@ -113,8 +109,8 @@ static int note_write(git_oid *out, git_repository *repo, ...@@ -113,8 +109,8 @@ static int note_write(git_oid *out, git_repository *repo,
error = git_treebuilder_create(&tb, tree); error = git_treebuilder_create(&tb, tree);
git_tree_free(tree); git_tree_free(tree);
if (error < GIT_SUCCESS) if (error < 0)
return git__rethrow(error, "Failed to create treebuilder"); return error;
if (!tree_sha) if (!tree_sha)
/* no notes tree yet - create fanout */ /* no notes tree yet - create fanout */
...@@ -122,18 +118,18 @@ static int note_write(git_oid *out, git_repository *repo, ...@@ -122,18 +118,18 @@ static int note_write(git_oid *out, git_repository *repo,
/* create note object */ /* create note object */
error = git_blob_create_frombuffer(&oid, repo, note, strlen(note)); error = git_blob_create_frombuffer(&oid, repo, note, strlen(note));
if (error < GIT_SUCCESS) { if (error < 0) {
git_treebuilder_free(tb); git_treebuilder_free(tb);
return git__rethrow(error, "Failed to create note object"); return error;
} }
error = git_treebuilder_insert(&entry, tb, target + fanout, &oid, 0100644); error = git_treebuilder_insert(&entry, tb, target + fanout, &oid, 0100644);
if (error < GIT_SUCCESS) { if (error < 0) {
/* libgit2 doesn't support object removal (gc) yet */ /* libgit2 doesn't support object removal (gc) yet */
/* we leave an orphaned blob object behind - TODO */ /* we leave an orphaned blob object behind - TODO */
git_treebuilder_free(tb); git_treebuilder_free(tb);
return git__rethrow(error, "Failed to insert note object"); return error;
} }
if (out) if (out)
...@@ -142,8 +138,8 @@ static int note_write(git_oid *out, git_repository *repo, ...@@ -142,8 +138,8 @@ static int note_write(git_oid *out, git_repository *repo,
error = git_treebuilder_write(&oid, repo, tb); error = git_treebuilder_write(&oid, repo, tb);
git_treebuilder_free(tb); git_treebuilder_free(tb);
if (error < GIT_SUCCESS) if (error < 0)
return git__rethrow(error, "Failed to write notes tree"); return 0;
if (!tree_sha) { if (!tree_sha) {
/* create fanout subtree */ /* create fanout subtree */
...@@ -153,27 +149,28 @@ static int note_write(git_oid *out, git_repository *repo, ...@@ -153,27 +149,28 @@ static int note_write(git_oid *out, git_repository *repo,
subtree[2] = '\0'; subtree[2] = '\0';
error = git_treebuilder_create(&tb, NULL); error = git_treebuilder_create(&tb, NULL);
if (error < GIT_SUCCESS) if (error < 0)
return git__rethrow(error, "Failed to create treebuilder"); return error;
error = git_treebuilder_insert(NULL, tb, subtree, &oid, 0040000); error = git_treebuilder_insert(NULL, tb, subtree, &oid, 0040000);
if (error < GIT_SUCCESS) { if (error < 0) {
git_treebuilder_free(tb); git_treebuilder_free(tb);
return git__rethrow(error, "Failed to insert note object"); return error;
} }
error = git_treebuilder_write(&oid, repo, tb); error = git_treebuilder_write(&oid, repo, tb);
git_treebuilder_free(tb); git_treebuilder_free(tb);
if (error < GIT_SUCCESS) if (error < 0)
return git__rethrow(error, "Failed to write notes tree"); return error;
} }
/* create new notes commit */ /* create new notes commit */
error = git_tree_lookup(&tree, repo, &oid); error = git_tree_lookup(&tree, repo, &oid);
if (error < GIT_SUCCESS) if (error < 0)
return git__rethrow(error, "Failed to open new notes tree"); return error;
error = git_commit_create(&oid, repo, notes_ref, author, committer, error = git_commit_create(&oid, repo, notes_ref, author, committer,
NULL, GIT_NOTES_DEFAULT_MSG_ADD, NULL, GIT_NOTES_DEFAULT_MSG_ADD,
...@@ -181,10 +178,7 @@ static int note_write(git_oid *out, git_repository *repo, ...@@ -181,10 +178,7 @@ static int note_write(git_oid *out, git_repository *repo,
git_tree_free(tree); git_tree_free(tree);
if (error < GIT_SUCCESS) return error;
return git__rethrow(error, "Failed to create new notes commit");
return GIT_SUCCESS;
} }
static int note_lookup(git_note **out, git_repository *repo, static int note_lookup(git_note **out, git_repository *repo,
...@@ -197,31 +191,25 @@ static int note_lookup(git_note **out, git_repository *repo, ...@@ -197,31 +191,25 @@ static int note_lookup(git_note **out, git_repository *repo,
git_note *note; git_note *note;
error = find_subtree(&tree, tree_sha, repo, target, &fanout); error = find_subtree(&tree, tree_sha, repo, target, &fanout);
if (error < GIT_SUCCESS) if (error < 0)
return git__rethrow(error, "Failed to lookup subtree"); return error;
error = find_blob(&oid, tree, target + fanout); error = find_blob(&oid, tree, target + fanout);
if (error < GIT_SUCCESS) {
git_tree_free(tree);
return git__throw(GIT_ENOTFOUND, "No note found for object %s",
target);
}
git_tree_free(tree); git_tree_free(tree);
if (error < 0)
return error;
error = git_blob_lookup(&blob, repo, &oid); error = git_blob_lookup(&blob, repo, &oid);
if (error < GIT_SUCCESS) if (error < 0)
return git__throw(GIT_ERROR, "Failed to lookup note object"); return error;
note = git__malloc(sizeof(git_note)); note = git__malloc(sizeof(git_note));
if (note == NULL) { GITERR_CHECK_ALLOC(note);
git_blob_free(blob);
return GIT_ENOMEM;
}
git_oid_cpy(&note->oid, &oid); git_oid_cpy(&note->oid, &oid);
note->message = git__strdup(git_blob_rawcontent(blob)); note->message = git__strdup(git_blob_rawcontent(blob));
if (note->message == NULL) GITERR_CHECK_ALLOC(note->message);
error = GIT_ENOMEM;
*out = note; *out = note;
...@@ -240,39 +228,30 @@ static int note_remove(git_repository *repo, ...@@ -240,39 +228,30 @@ static int note_remove(git_repository *repo,
git_treebuilder *tb; git_treebuilder *tb;
error = find_subtree(&tree, tree_sha, repo, target, &fanout); error = find_subtree(&tree, tree_sha, repo, target, &fanout);
if (error < GIT_SUCCESS) if (error < 0)
return git__rethrow(error, "Failed to lookup subtree"); return error;
error = find_blob(&oid, tree, target + fanout); error = find_blob(&oid, tree, target + fanout);
if (error < GIT_SUCCESS) { if (!error)
git_tree_free(tree); error = git_treebuilder_create(&tb, tree);
return git__throw(GIT_ENOTFOUND, "No note found for object %s",
target);
}
error = git_treebuilder_create(&tb, tree);
git_tree_free(tree); git_tree_free(tree);
if (error < 0)
if (error < GIT_SUCCESS) return error;
return git__rethrow(error, "Failed to create treebuilder");
error = git_treebuilder_remove(tb, target + fanout); error = git_treebuilder_remove(tb, target + fanout);
if (error < GIT_SUCCESS) { if (!error)
git_treebuilder_free(tb); error = git_treebuilder_write(&oid, repo, tb);
return git__rethrow(error, "Failed to remove entry from notes tree");
}
error = git_treebuilder_write(&oid, repo, tb);
git_treebuilder_free(tb); git_treebuilder_free(tb);
if (error < 0)
if (error < GIT_SUCCESS) return error;
return git__rethrow(error, "Failed to write notes tree");
/* create new notes commit */ /* create new notes commit */
error = git_tree_lookup(&tree, repo, &oid); error = git_tree_lookup(&tree, repo, &oid);
if (error < GIT_SUCCESS) if (error < 0)
return git__rethrow(error, "Failed to open new notes tree"); return error;
error = git_commit_create(&oid, repo, notes_ref, author, committer, error = git_commit_create(&oid, repo, notes_ref, author, committer,
NULL, GIT_NOTES_DEFAULT_MSG_RM, NULL, GIT_NOTES_DEFAULT_MSG_RM,
...@@ -280,9 +259,6 @@ static int note_remove(git_repository *repo, ...@@ -280,9 +259,6 @@ static int note_remove(git_repository *repo,
git_tree_free(tree); git_tree_free(tree);
if (error < GIT_SUCCESS)
return git__rethrow(error, "Failed to create new notes commit");
return error; return error;
} }
...@@ -301,8 +277,8 @@ int git_note_read(git_note **out, git_repository *repo, ...@@ -301,8 +277,8 @@ int git_note_read(git_note **out, git_repository *repo,
notes_ref = GIT_NOTES_DEFAULT_REF; notes_ref = GIT_NOTES_DEFAULT_REF;
error = git_reference_lookup(&ref, repo, notes_ref); error = git_reference_lookup(&ref, repo, notes_ref);
if (error < GIT_SUCCESS) if (error < 0)
return git__rethrow(error, "Failed to lookup reference `%s`", notes_ref); return error;
assert(git_reference_type(ref) == GIT_REF_OID); assert(git_reference_type(ref) == GIT_REF_OID);
...@@ -311,27 +287,26 @@ int git_note_read(git_note **out, git_repository *repo, ...@@ -311,27 +287,26 @@ int git_note_read(git_note **out, git_repository *repo,
git_reference_free(ref); git_reference_free(ref);
if (error < GIT_SUCCESS) if (error < 0)
return git__rethrow(error, "Failed to find notes commit object"); return error;
sha = git_commit_tree_oid(commit); sha = git_commit_tree_oid(commit);
git_commit_free(commit); git_commit_free(commit);
target = git_oid_allocfmt(oid); target = git_oid_allocfmt(oid);
if (target == NULL) GITERR_CHECK_ALLOC(target);
return GIT_ENOMEM;
error = note_lookup(out, repo, sha, target); error = note_lookup(out, repo, sha, target);
git__free(target); git__free(target);
return error == GIT_SUCCESS ? GIT_SUCCESS : return error;
git__rethrow(error, "Failed to read note");
} }
int git_note_create(git_oid *out, git_repository *repo, int git_note_create(
git_signature *author, git_signature *committer, git_oid *out, git_repository *repo,
const char *notes_ref, const git_oid *oid, git_signature *author, git_signature *committer,
const char *note) const char *notes_ref, const git_oid *oid,
const char *note)
{ {
int error, nparents = 0; int error, nparents = 0;
char *target; char *target;
...@@ -343,10 +318,10 @@ int git_note_create(git_oid *out, git_repository *repo, ...@@ -343,10 +318,10 @@ int git_note_create(git_oid *out, git_repository *repo,
notes_ref = GIT_NOTES_DEFAULT_REF; notes_ref = GIT_NOTES_DEFAULT_REF;
error = git_reference_lookup(&ref, repo, notes_ref); error = git_reference_lookup(&ref, repo, notes_ref);
if (error < GIT_SUCCESS && error != GIT_ENOTFOUND) if (error < 0 && error != GIT_ENOTFOUND)
return git__rethrow(error, "Failed to lookup reference `%s`", notes_ref); return error;
if (error == GIT_SUCCESS) { if (!error) {
assert(git_reference_type(ref) == GIT_REF_OID); assert(git_reference_type(ref) == GIT_REF_OID);
/* lookup existing notes tree oid */ /* lookup existing notes tree oid */
...@@ -355,16 +330,15 @@ int git_note_create(git_oid *out, git_repository *repo, ...@@ -355,16 +330,15 @@ int git_note_create(git_oid *out, git_repository *repo,
git_reference_free(ref); git_reference_free(ref);
error = git_commit_lookup(&commit, repo, &sha); error = git_commit_lookup(&commit, repo, &sha);
if (error < GIT_SUCCESS) if (error < 0)
return git__rethrow(error, "Failed to find notes commit object"); return error;
git_oid_cpy(&sha, git_commit_tree_oid(commit)); git_oid_cpy(&sha, git_commit_tree_oid(commit));
nparents++; nparents++;
} }
target = git_oid_allocfmt(oid); target = git_oid_allocfmt(oid);
if (target == NULL) GITERR_CHECK_ALLOC(target);
return GIT_ENOMEM;
error = note_write(out, repo, author, committer, notes_ref, error = note_write(out, repo, author, committer, notes_ref,
note, nparents ? &sha : NULL, target, note, nparents ? &sha : NULL, target,
...@@ -372,8 +346,7 @@ int git_note_create(git_oid *out, git_repository *repo, ...@@ -372,8 +346,7 @@ int git_note_create(git_oid *out, git_repository *repo,
git__free(target); git__free(target);
git_commit_free(commit); git_commit_free(commit);
return error == GIT_SUCCESS ? GIT_SUCCESS : return error;
git__rethrow(error, "Failed to write note");
} }
int git_note_remove(git_repository *repo, const char *notes_ref, int git_note_remove(git_repository *repo, const char *notes_ref,
...@@ -390,8 +363,8 @@ int git_note_remove(git_repository *repo, const char *notes_ref, ...@@ -390,8 +363,8 @@ int git_note_remove(git_repository *repo, const char *notes_ref,
notes_ref = GIT_NOTES_DEFAULT_REF; notes_ref = GIT_NOTES_DEFAULT_REF;
error = git_reference_lookup(&ref, repo, notes_ref); error = git_reference_lookup(&ref, repo, notes_ref);
if (error < GIT_SUCCESS) if (error < 0)
return git__rethrow(error, "Failed to lookup reference `%s`", notes_ref); return error;
assert(git_reference_type(ref) == GIT_REF_OID); assert(git_reference_type(ref) == GIT_REF_OID);
...@@ -399,22 +372,20 @@ int git_note_remove(git_repository *repo, const char *notes_ref, ...@@ -399,22 +372,20 @@ int git_note_remove(git_repository *repo, const char *notes_ref,
git_reference_free(ref); git_reference_free(ref);
error = git_commit_lookup(&commit, repo, &sha); error = git_commit_lookup(&commit, repo, &sha);
if (error < GIT_SUCCESS) if (error < 0)
return git__rethrow(error, "Failed to find notes commit object"); return error;
git_oid_cpy(&sha, git_commit_tree_oid(commit)); git_oid_cpy(&sha, git_commit_tree_oid(commit));
target = git_oid_allocfmt(oid); target = git_oid_allocfmt(oid);
if (target == NULL) GITERR_CHECK_ALLOC(target);
return GIT_ENOMEM;
error = note_remove(repo, author, committer, notes_ref, error = note_remove(repo, author, committer, notes_ref,
&sha, target, 1, &commit); &sha, target, 1, &commit);
git__free(target); git__free(target);
git_commit_free(commit); git_commit_free(commit);
return error == GIT_SUCCESS ? GIT_SUCCESS : return error;
git__rethrow(error, "Failed to read note");
} }
const char * git_note_message(git_note *note) const char * git_note_message(git_note *note)
......
...@@ -541,6 +541,10 @@ int git_odb_read(git_odb_object **out, git_odb *db, const git_oid *id) ...@@ -541,6 +541,10 @@ int git_odb_read(git_odb_object **out, git_odb *db, const git_oid *id)
error = b->read(&raw.data, &raw.len, &raw.type, b, id); error = b->read(&raw.data, &raw.len, &raw.type, b, id);
} }
/* TODO: If no backends are configured, this returns GIT_ENOTFOUND but
* will never have called giterr_set().
*/
if (error && error != GIT_EPASSTHROUGH) if (error && error != GIT_EPASSTHROUGH)
return error; return error;
......
...@@ -158,7 +158,8 @@ int sha1_entry_pos(const void *table, ...@@ -158,7 +158,8 @@ int sha1_entry_pos(const void *table,
#endif #endif
if (!(lo <= mi && mi < hi)) { if (!(lo <= mi && mi < hi)) {
return git__throw(GIT_ERROR, "Assertion failure. Binary search invariant is false"); giterr_set(GITERR_INVALID, "Assertion failure. Binary search invariant is false");
return -1;
} }
mi_key = base + elem_size * mi + key_offset; mi_key = base + elem_size * mi + key_offset;
......
...@@ -38,31 +38,38 @@ static const char *skip_trailing_spaces(const char *buffer_start, const char *bu ...@@ -38,31 +38,38 @@ static const char *skip_trailing_spaces(const char *buffer_start, const char *bu
return buffer_end; return buffer_end;
} }
static int signature_error(const char *msg)
{
giterr_set(GITERR_INVALID, "Failed to parse signature - %s", msg);
return -1;
}
static int process_trimming(const char *input, char **storage, const char *input_end, int fail_when_empty) static int process_trimming(const char *input, char **storage, const char *input_end, int fail_when_empty)
{ {
const char *left, *right; const char *left, *right;
int trimmed_input_length; int trimmed_input_length;
assert(storage);
left = skip_leading_spaces(input, input_end); left = skip_leading_spaces(input, input_end);
right = skip_trailing_spaces(input, input_end - 1); right = skip_trailing_spaces(input, input_end - 1);
if (right < left) { if (right < left) {
if (fail_when_empty) if (fail_when_empty)
return git__throw(GIT_EINVALIDARGS, "Failed to trim. Input is either empty or only contains spaces"); return signature_error("input is either empty of contains only spaces");
else
right = left - 1; right = left - 1;
} }
trimmed_input_length = right - left + 1; trimmed_input_length = right - left + 1;
*storage = git__malloc(trimmed_input_length + 1); *storage = git__malloc(trimmed_input_length + 1);
if (*storage == NULL) GITERR_CHECK_ALLOC(*storage);
return GIT_ENOMEM;
memcpy(*storage, left, trimmed_input_length); memcpy(*storage, left, trimmed_input_length);
(*storage)[trimmed_input_length] = 0; (*storage)[trimmed_input_length] = 0;
return GIT_SUCCESS; return 0;
} }
int git_signature_new(git_signature **sig_out, const char *name, const char *email, git_time_t time, int offset) int git_signature_new(git_signature **sig_out, const char *name, const char *email, git_time_t time, int offset)
...@@ -74,23 +81,14 @@ int git_signature_new(git_signature **sig_out, const char *name, const char *ema ...@@ -74,23 +81,14 @@ int git_signature_new(git_signature **sig_out, const char *name, const char *ema
*sig_out = NULL; *sig_out = NULL;
if ((p = git__malloc(sizeof(git_signature))) == NULL) { p = git__calloc(1, sizeof(git_signature));
error = GIT_ENOMEM; GITERR_CHECK_ALLOC(p);
goto cleanup;
}
memset(p, 0x0, sizeof(git_signature));
error = process_trimming(name, &p->name, name + strlen(name), 1);
if (error < GIT_SUCCESS) {
git__rethrow(GIT_EINVALIDARGS, "Failed to create signature. 'name' argument is invalid");
goto cleanup;
}
error = process_trimming(email, &p->email, email + strlen(email), 1); if ((error = process_trimming(name, &p->name, name + strlen(name), 1)) < 0 ||
if (error < GIT_SUCCESS) { (error = process_trimming(email, &p->email, email + strlen(email), 1)) < 0)
git__rethrow(GIT_EINVALIDARGS, "Failed to create signature. 'email' argument is invalid"); {
goto cleanup; git_signature_free(p);
return error;
} }
p->when.time = time; p->when.time = time;
...@@ -98,24 +96,19 @@ int git_signature_new(git_signature **sig_out, const char *name, const char *ema ...@@ -98,24 +96,19 @@ int git_signature_new(git_signature **sig_out, const char *name, const char *ema
*sig_out = p; *sig_out = p;
return error; return 0;
cleanup:
git_signature_free(p);
return error;
} }
git_signature *git_signature_dup(const git_signature *sig) git_signature *git_signature_dup(const git_signature *sig)
{ {
git_signature *new; git_signature *new;
if (git_signature_new(&new, sig->name, sig->email, sig->when.time, sig->when.offset) < GIT_SUCCESS) if (git_signature_new(&new, sig->name, sig->email, sig->when.time, sig->when.offset) < 0)
return NULL; return NULL;
return new; return new;
} }
int git_signature_now(git_signature **sig_out, const char *name, const char *email) int git_signature_now(git_signature **sig_out, const char *name, const char *email)
{ {
int error;
time_t now; time_t now;
time_t offset; time_t offset;
struct tm *utc_tm, *local_tm; struct tm *utc_tm, *local_tm;
...@@ -148,12 +141,18 @@ int git_signature_now(git_signature **sig_out, const char *name, const char *ema ...@@ -148,12 +141,18 @@ int git_signature_now(git_signature **sig_out, const char *name, const char *ema
if (local_tm->tm_isdst) if (local_tm->tm_isdst)
offset += 60; offset += 60;
if ((error = git_signature_new(&sig, name, email, now, (int)offset)) < GIT_SUCCESS) if (git_signature_new(&sig, name, email, now, (int)offset) < 0)
return error; return -1;
*sig_out = sig; *sig_out = sig;
return error; return 0;
}
static int timezone_error(const char *msg)
{
giterr_set(GITERR_INVALID, "Failed to parse TZ offset - %s", msg);
return -1;
} }
static int parse_timezone_offset(const char *buffer, int *offset_out) static int parse_timezone_offset(const char *buffer, int *offset_out)
...@@ -172,28 +171,28 @@ static int parse_timezone_offset(const char *buffer, int *offset_out) ...@@ -172,28 +171,28 @@ static int parse_timezone_offset(const char *buffer, int *offset_out)
} }
if (offset_start[0] != '-' && offset_start[0] != '+') if (offset_start[0] != '-' && offset_start[0] != '+')
return git__throw(GIT_EOBJCORRUPTED, "Failed to parse TZ offset. It doesn't start with '+' or '-'"); return timezone_error("does not start with '+' or '-'");
if (offset_start[1] < '0' || offset_start[1] > '9') if (offset_start[1] < '0' || offset_start[1] > '9')
return git__throw(GIT_EOBJCORRUPTED, "Failed to parse TZ offset."); return timezone_error("expected initial digit");
if (git__strtol32(&dec_offset, offset_start + 1, &offset_end, 10) < GIT_SUCCESS) if (git__strtol32(&dec_offset, offset_start + 1, &offset_end, 10) < GIT_SUCCESS)
return git__throw(GIT_EOBJCORRUPTED, "Failed to parse TZ offset. It isn't a number"); return timezone_error("not a valid number");
if (offset_end - offset_start != 5) if (offset_end - offset_start != 5)
return git__throw(GIT_EOBJCORRUPTED, "Failed to parse TZ offset. Invalid length"); return timezone_error("invalid length");
if (dec_offset > 1400) if (dec_offset > 1400)
return git__throw(GIT_EOBJCORRUPTED, "Failed to parse TZ offset. Value too large"); return timezone_error("value too large");
hours = dec_offset / 100; hours = dec_offset / 100;
mins = dec_offset % 100; mins = dec_offset % 100;
if (hours > 14) // see http://www.worldtimezone.com/faq.html if (hours > 14) // see http://www.worldtimezone.com/faq.html
return git__throw(GIT_EOBJCORRUPTED, "Failed to parse TZ offset. Hour value too large"); return timezone_error("hour value too large");
if (mins > 59) if (mins > 59)
return git__throw(GIT_EOBJCORRUPTED, "Failed to parse TZ offset. Minute value too large"); return timezone_error("minutes value too large");
offset = (hours * 60) + mins; offset = (hours * 60) + mins;
...@@ -202,22 +201,22 @@ static int parse_timezone_offset(const char *buffer, int *offset_out) ...@@ -202,22 +201,22 @@ static int parse_timezone_offset(const char *buffer, int *offset_out)
*offset_out = offset; *offset_out = offset;
return GIT_SUCCESS; return 0;
} }
static int process_next_token(const char **buffer_out, char **storage, static int process_next_token(const char **buffer_out, char **storage,
const char *token_end, const char *right_boundary) const char *token_end, const char *right_boundary)
{ {
int error = process_trimming(*buffer_out, storage, token_end, 0); int error = process_trimming(*buffer_out, storage, token_end, 0);
if (error < GIT_SUCCESS) if (error < 0)
return error; return error;
*buffer_out = token_end + 1; *buffer_out = token_end + 1;
if (*buffer_out > right_boundary) if (*buffer_out > right_boundary)
return git__throw(GIT_EOBJCORRUPTED, "Failed to parse signature. Signature too short"); return signature_error("signature is too short");
return GIT_SUCCESS; return 0;
} }
static const char *scan_for_previous_token(const char *buffer, const char *left_boundary) static const char *scan_for_previous_token(const char *buffer, const char *left_boundary)
...@@ -241,17 +240,17 @@ static int parse_time(git_time_t *time_out, const char *buffer) ...@@ -241,17 +240,17 @@ static int parse_time(git_time_t *time_out, const char *buffer)
int time; int time;
int error; int error;
if (*buffer == '+' || *buffer == '-') if (*buffer == '+' || *buffer == '-') {
return git__throw(GIT_ERROR, "Failed while parsing time. '%s' rather look like a timezone offset.", buffer); giterr_set(GITERR_INVALID, "Failed while parsing time. '%s' actually looks like a timezone offset.", buffer);
return -1;
}
error = git__strtol32(&time, buffer, &buffer, 10); error = git__strtol32(&time, buffer, &buffer, 10);
if (error < GIT_SUCCESS) if (!error)
return error; *time_out = (git_time_t)time;
*time_out = (git_time_t)time; return error;
return GIT_SUCCESS;
} }
int git_signature__parse(git_signature *sig, const char **buffer_out, int git_signature__parse(git_signature *sig, const char **buffer_out,
...@@ -264,35 +263,35 @@ int git_signature__parse(git_signature *sig, const char **buffer_out, ...@@ -264,35 +263,35 @@ int git_signature__parse(git_signature *sig, const char **buffer_out,
memset(sig, 0x0, sizeof(git_signature)); memset(sig, 0x0, sizeof(git_signature));
if ((line_end = memchr(buffer, ender, buffer_end - buffer)) == NULL) if ((line_end = memchr(buffer, ender, buffer_end - buffer)) == NULL)
return git__throw(GIT_EOBJCORRUPTED, "Failed to parse signature. No newline given"); return signature_error("no newline given");
if (header) { if (header) {
const size_t header_len = strlen(header); const size_t header_len = strlen(header);
if (memcmp(buffer, header, header_len) != 0) if (memcmp(buffer, header, header_len) != 0)
return git__throw(GIT_EOBJCORRUPTED, "Failed to parse signature. Expected prefix '%s' doesn't match actual", header); return signature_error("expected prefix doesn't match actual");
buffer += header_len; buffer += header_len;
} }
if (buffer > line_end) if (buffer > line_end)
return git__throw(GIT_EOBJCORRUPTED, "Failed to parse signature. Signature too short"); return signature_error("signature too short");
if ((name_end = strchr(buffer, '<')) == NULL) if ((name_end = strchr(buffer, '<')) == NULL)
return git__throw(GIT_EOBJCORRUPTED, "Failed to parse signature. Cannot find '<' in signature"); return signature_error("character '<' not allowed in signature");
if ((email_end = strchr(name_end, '>')) == NULL) if ((email_end = strchr(name_end, '>')) == NULL)
return git__throw(GIT_EOBJCORRUPTED, "Failed to parse signature. Cannot find '>' in signature"); return signature_error("character '>' not allowed in signature");
if (email_end < name_end) if (email_end < name_end)
return git__throw(GIT_EOBJCORRUPTED, "Failed to parse signature. Malformed e-mail"); return signature_error("malformed e-mail");
error = process_next_token(&buffer, &sig->name, name_end, line_end); error = process_next_token(&buffer, &sig->name, name_end, line_end);
if (error < GIT_SUCCESS) if (error < 0)
return error; return error;
error = process_next_token(&buffer, &sig->email, email_end, line_end); error = process_next_token(&buffer, &sig->email, email_end, line_end);
if (error < GIT_SUCCESS) if (error < 0)
return error; return error;
tz_start = scan_for_previous_token(line_end - 1, buffer); tz_start = scan_for_previous_token(line_end - 1, buffer);
...@@ -301,19 +300,19 @@ int git_signature__parse(git_signature *sig, const char **buffer_out, ...@@ -301,19 +300,19 @@ int git_signature__parse(git_signature *sig, const char **buffer_out,
goto clean_exit; /* No timezone nor date */ goto clean_exit; /* No timezone nor date */
time_start = scan_for_previous_token(tz_start - 1, buffer); time_start = scan_for_previous_token(tz_start - 1, buffer);
if (time_start == NULL || parse_time(&sig->when.time, time_start) < GIT_SUCCESS) { if (time_start == NULL || parse_time(&sig->when.time, time_start) < 0) {
/* The tz_start might point at the time */ /* The tz_start might point at the time */
parse_time(&sig->when.time, tz_start); parse_time(&sig->when.time, tz_start);
goto clean_exit; goto clean_exit;
} }
if (parse_timezone_offset(tz_start, &sig->when.offset) < GIT_SUCCESS) { if (parse_timezone_offset(tz_start, &sig->when.offset) < 0) {
sig->when.time = 0; /* Bogus timezone, we reset the time */ sig->when.time = 0; /* Bogus timezone, we reset the time */
} }
clean_exit: clean_exit:
*buffer_out = line_end + 1; *buffer_out = line_end + 1;
return GIT_SUCCESS; return 0;
} }
void git_signature__writebuf(git_buf *buf, const char *header, const git_signature *sig) void git_signature__writebuf(git_buf *buf, const char *header, const git_signature *sig)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment