summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/indexer.c12
-rw-r--r--tests/pack/indexer.c4
-rw-r--r--tests/pack/packbuilder.c8
3 files changed, 10 insertions, 14 deletions
diff --git a/src/indexer.c b/src/indexer.c
index 606de2ef6..0ad7869ef 100644
--- a/src/indexer.c
+++ b/src/indexer.c
@@ -931,7 +931,6 @@ int git_indexer_commit(git_indexer *idx, git_transfer_progress *stats)
git_buf filename = GIT_BUF_INIT;
struct entry *entry;
git_oid trailer_hash, file_hash;
- git_hash_ctx ctx;
git_filebuf index_file = {0};
void *packfile_trailer;
@@ -940,9 +939,6 @@ int git_indexer_commit(git_indexer *idx, git_transfer_progress *stats)
return -1;
}
- if (git_hash_ctx_init(&ctx) < 0)
- return -1;
-
/* Test for this before resolve_deltas(), as it plays with idx->off */
if (idx->off + 20 < idx->pack->mwf.size) {
giterr_set(GITERR_INDEXER, "unexpected data at the end of the pack");
@@ -986,6 +982,10 @@ int git_indexer_commit(git_indexer *idx, git_transfer_progress *stats)
git_vector_sort(&idx->objects);
+ /* Use the trailer hash as the pack file name to ensure
+ * files with different contents have different names */
+ git_oid_cpy(&idx->hash, &trailer_hash);
+
git_buf_sets(&filename, idx->pack->pack_name);
git_buf_shorten(&filename, strlen("pack"));
git_buf_puts(&filename, "idx");
@@ -1010,9 +1010,7 @@ int git_indexer_commit(git_indexer *idx, git_transfer_progress *stats)
/* Write out the object names (SHA-1 hashes) */
git_vector_foreach(&idx->objects, i, entry) {
git_filebuf_write(&index_file, &entry->oid, sizeof(git_oid));
- git_hash_update(&ctx, &entry->oid, GIT_OID_RAWSZ);
}
- git_hash_final(&idx->hash, &ctx);
/* Write out the CRC32 values */
git_vector_foreach(&idx->objects, i, entry) {
@@ -1086,14 +1084,12 @@ int git_indexer_commit(git_indexer *idx, git_transfer_progress *stats)
idx->pack_committed = 1;
git_buf_free(&filename);
- git_hash_ctx_cleanup(&ctx);
return 0;
on_error:
git_mwindow_free_all(&idx->pack->mwf);
git_filebuf_cleanup(&index_file);
git_buf_free(&filename);
- git_hash_ctx_cleanup(&ctx);
return -1;
}
diff --git a/tests/pack/indexer.c b/tests/pack/indexer.c
index 1e514b2d6..c73d3974e 100644
--- a/tests/pack/indexer.c
+++ b/tests/pack/indexer.c
@@ -85,7 +85,7 @@ void test_pack_indexer__fix_thin(void)
cl_assert_equal_i(stats.indexed_objects, 2);
cl_assert_equal_i(stats.local_objects, 1);
- git_oid_fromstr(&should_id, "11f0f69b334728fdd8bc86b80499f22f29d85b15");
+ git_oid_fromstr(&should_id, "fefdb2d740a3a6b6c03a0c7d6ce431c6d5810e13");
cl_assert_equal_oid(&should_id, git_indexer_hash(idx));
git_indexer_free(idx);
@@ -102,7 +102,7 @@ void test_pack_indexer__fix_thin(void)
int fd;
ssize_t read;
struct stat st;
- const char *name = "pack-11f0f69b334728fdd8bc86b80499f22f29d85b15.pack";
+ const char *name = "pack-fefdb2d740a3a6b6c03a0c7d6ce431c6d5810e13.pack";
fd = p_open(name, O_RDONLY);
cl_assert(fd != -1);
diff --git a/tests/pack/packbuilder.c b/tests/pack/packbuilder.c
index 29f3e2d64..9ad52f354 100644
--- a/tests/pack/packbuilder.c
+++ b/tests/pack/packbuilder.c
@@ -113,7 +113,7 @@ void test_pack_packbuilder__create_pack(void)
* $ cd tests/resources/testrepo.git
* $ git rev-list --objects HEAD | \
* git pack-objects -q --no-reuse-delta --threads=1 pack
- * $ sha1sum git-80e61eb315239ef3c53033e37fee43b744d57122.pack
+ * $ sha1sum pack-7f5fa362c664d68ba7221259be1cbd187434b2f0.pack
* 5d410bdf97cf896f9007681b92868471d636954b
*
*/
@@ -142,7 +142,7 @@ void test_pack_packbuilder__get_hash(void)
git_packbuilder_write(_packbuilder, ".", 0, NULL, NULL);
git_oid_fmt(hex, git_packbuilder_hash(_packbuilder));
- cl_assert_equal_s(hex, "80e61eb315239ef3c53033e37fee43b744d57122");
+ cl_assert_equal_s(hex, "7f5fa362c664d68ba7221259be1cbd187434b2f0");
}
static void test_write_pack_permission(mode_t given, mode_t expected)
@@ -166,10 +166,10 @@ static void test_write_pack_permission(mode_t given, mode_t expected)
mask = p_umask(0);
p_umask(mask);
- cl_git_pass(p_stat("pack-80e61eb315239ef3c53033e37fee43b744d57122.idx", &statbuf));
+ cl_git_pass(p_stat("pack-7f5fa362c664d68ba7221259be1cbd187434b2f0.idx", &statbuf));
cl_assert_equal_i(statbuf.st_mode & os_mask, (expected & ~mask) & os_mask);
- cl_git_pass(p_stat("pack-80e61eb315239ef3c53033e37fee43b744d57122.pack", &statbuf));
+ cl_git_pass(p_stat("pack-7f5fa362c664d68ba7221259be1cbd187434b2f0.pack", &statbuf));
cl_assert_equal_i(statbuf.st_mode & os_mask, (expected & ~mask) & os_mask);
}