Commit Diff


commit - 6257c2378b7f0f559d5796ea45346551ddbe255b
commit + fbdb635427fd6ccd5e72f5ba3a3fa6eea409c8a4
blob - 5fe3a143b937f5d9546cfeb56eacda0494beb68a
blob + b2f6c91aecb8a7dea4ac642323e479b981ca9f0c
--- lib/pack_create.c
+++ lib/pack_create.c
@@ -48,6 +48,7 @@
 
 #include "got_lib_deltify.h"
 #include "got_lib_delta.h"
+#include "got_lib_hash.h"
 #include "got_lib_object.h"
 #include "got_lib_object_idset.h"
 #include "got_lib_object_cache.h"
@@ -1557,6 +1558,7 @@ deltahdr(off_t *packfile_size, SHA1_CTX *ctx, int pack
 	const struct got_error *err;
 	char buf[32];
 	int nh;
+	size_t idlen;
 
 	if (m->prev->off != 0) {
 		err = packhdr(&nh, buf, sizeof(buf),
@@ -1577,11 +1579,12 @@ deltahdr(off_t *packfile_size, SHA1_CTX *ctx, int pack
 		if (err)
 			return err;
 		*packfile_size += nh;
-		err = hwrite(packfd, m->prev->id.hash,
-		    sizeof(m->prev->id.hash), ctx);
+
+		idlen = got_hash_digest_length(m->prev->id.algo);
+		err = hwrite(packfd, m->prev->id.hash, idlen, ctx);
 		if (err)
 			return err;
-		*packfile_size += sizeof(m->prev->id.hash);
+		*packfile_size += idlen;
 	}
 
 	return NULL;