]> git.ipfire.org Git - thirdparty/git.git/commitdiff
read-cache: delete unused hashing methods
authorDerrick Stolee <dstolee@microsoft.com>
Tue, 18 May 2021 18:32:48 +0000 (18:32 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 19 May 2021 07:41:21 +0000 (16:41 +0900)
These methods were marked as MAYBE_UNUSED in the previous change to
avoid a complicated diff. Delete them entirely, since we now use the
hashfile API instead of this custom hashing code.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
read-cache.c

index e3c9ab8033e9aac40fd37984883d4d81e452a296..77961a38854069850829a7fecd8be5dc1e2f7b62 100644 (file)
@@ -2522,46 +2522,6 @@ int repo_index_has_changes(struct repository *repo,
        }
 }
 
-#define WRITE_BUFFER_SIZE (128 * 1024)
-static unsigned char write_buffer[WRITE_BUFFER_SIZE];
-static unsigned long write_buffer_len;
-
-MAYBE_UNUSED
-static int ce_write_flush(git_hash_ctx *context, int fd)
-{
-       unsigned int buffered = write_buffer_len;
-       if (buffered) {
-               the_hash_algo->update_fn(context, write_buffer, buffered);
-               if (write_in_full(fd, write_buffer, buffered) < 0)
-                       return -1;
-               write_buffer_len = 0;
-       }
-       return 0;
-}
-
-MAYBE_UNUSED
-static int ce_write(git_hash_ctx *context, int fd, void *data, unsigned int len)
-{
-       while (len) {
-               unsigned int buffered = write_buffer_len;
-               unsigned int partial = WRITE_BUFFER_SIZE - buffered;
-               if (partial > len)
-                       partial = len;
-               memcpy(write_buffer + buffered, data, partial);
-               buffered += partial;
-               if (buffered == WRITE_BUFFER_SIZE) {
-                       write_buffer_len = buffered;
-                       if (ce_write_flush(context, fd))
-                               return -1;
-                       buffered = 0;
-               }
-               write_buffer_len = buffered;
-               len -= partial;
-               data = (char *) data + partial;
-       }
-       return 0;
-}
-
 static int write_index_ext_header(struct hashfile *f,
                                  git_hash_ctx *eoie_f,
                                  unsigned int ext,
@@ -2579,30 +2539,6 @@ static int write_index_ext_header(struct hashfile *f,
        return 0;
 }
 
-MAYBE_UNUSED
-static int ce_flush(git_hash_ctx *context, int fd, unsigned char *hash)
-{
-       unsigned int left = write_buffer_len;
-
-       if (left) {
-               write_buffer_len = 0;
-               the_hash_algo->update_fn(context, write_buffer, left);
-       }
-
-       /* Flush first if not enough space for hash signature */
-       if (left + the_hash_algo->rawsz > WRITE_BUFFER_SIZE) {
-               if (write_in_full(fd, write_buffer, left) < 0)
-                       return -1;
-               left = 0;
-       }
-
-       /* Append the hash signature at the end */
-       the_hash_algo->final_fn(write_buffer + left, context);
-       hashcpy(hash, write_buffer + left);
-       left += the_hash_algo->rawsz;
-       return (write_in_full(fd, write_buffer, left) < 0) ? -1 : 0;
-}
-
 static void ce_smudge_racily_clean_entry(struct index_state *istate,
                                         struct cache_entry *ce)
 {