summaryrefslogtreecommitdiff
path: root/update-cache.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-09 19:09:27 (GMT)
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-09 19:09:27 (GMT)
commit197ee8c97076ee784db9f4b5a9294e86f42d068c (patch)
treeccba05512dc3b5f46c5fd5caadb40ce79ffb944b /update-cache.c
parent8d3af1d53255ac36494492720ebb83e932b0c0bc (diff)
downloadgit-197ee8c97076ee784db9f4b5a9294e86f42d068c.zip
git-197ee8c97076ee784db9f4b5a9294e86f42d068c.tar.gz
git-197ee8c97076ee784db9f4b5a9294e86f42d068c.tar.bz2
Make "write_cache()" and friends available as generic routines.
This is needed for the change to make "read-tree" just read into the cache (and then you do a "checkout-cache" to update your current dir contents).
Diffstat (limited to 'update-cache.c')
-rw-r--r--update-cache.c69
1 files changed, 0 insertions, 69 deletions
diff --git a/update-cache.c b/update-cache.c
index 7a076be..03b111b 100644
--- a/update-cache.c
+++ b/update-cache.c
@@ -5,44 +5,6 @@
*/
#include "cache.h"
-static int remove_file_from_cache(char *path)
-{
- int pos = cache_name_pos(path, strlen(path));
- if (pos < 0) {
- pos = -pos-1;
- active_nr--;
- if (pos < active_nr)
- memmove(active_cache + pos, active_cache + pos + 1, (active_nr - pos - 1) * sizeof(struct cache_entry *));
- }
- return 0;
-}
-
-static int add_cache_entry(struct cache_entry *ce)
-{
- int pos;
-
- pos = cache_name_pos(ce->name, ce->namelen);
-
- /* existing match? Just replace it */
- if (pos < 0) {
- active_cache[-pos-1] = ce;
- return 0;
- }
-
- /* Make sure the array is big enough .. */
- if (active_nr == active_alloc) {
- active_alloc = alloc_nr(active_alloc);
- active_cache = realloc(active_cache, active_alloc * sizeof(struct cache_entry *));
- }
-
- /* Add it in.. */
- active_nr++;
- if (active_nr > pos)
- memmove(active_cache + pos + 1, active_cache + pos, (active_nr - pos - 1) * sizeof(ce));
- active_cache[pos] = ce;
- return 0;
-}
-
static int index_fd(const char *path, int namelen, struct cache_entry *ce, int fd, struct stat *st)
{
z_stream stream;
@@ -126,37 +88,6 @@ static int add_file_to_cache(char *path)
return add_cache_entry(ce);
}
-static int write_cache(int newfd, struct cache_entry **cache, int entries)
-{
- SHA_CTX c;
- struct cache_header hdr;
- int i;
-
- hdr.signature = CACHE_SIGNATURE;
- hdr.version = 1;
- hdr.entries = entries;
-
- SHA1_Init(&c);
- SHA1_Update(&c, &hdr, offsetof(struct cache_header, sha1));
- for (i = 0; i < entries; i++) {
- struct cache_entry *ce = cache[i];
- int size = ce_size(ce);
- SHA1_Update(&c, ce, size);
- }
- SHA1_Final(hdr.sha1, &c);
-
- if (write(newfd, &hdr, sizeof(hdr)) != sizeof(hdr))
- return -1;
-
- for (i = 0; i < entries; i++) {
- struct cache_entry *ce = cache[i];
- int size = ce_size(ce);
- if (write(newfd, ce, size) != size)
- return -1;
- }
- return 0;
-}
-
/*
* We fundamentally don't like some paths: we don't want
* dot or dot-dot anywhere, and in fact, we don't even want