Propagate cache error internal to refresh_cache() via parameter.
The function refresh_cache() is the only user of cache_errno that switches its behaviour based on what internal function refresh_cache_entry() finds; pass the error status back in a parameter passed down to it, to get rid of the global variable cache_errno. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Apr 1, 2007 at 21:34 UTC
ec0cc704692a83c1d01b53f366b9919accdd4268
1 file changed
+13
-6
read-cache.c
+13
-6
@@ -24,8 +24,6 @@ unsigned int active_nr, active_alloc, active_cache_changed;
24
25
struct cache_tree *active_cache_tree;
26
27
-static int cache_errno;
28
-
27
static void *cache_mmap;
28
static size_t cache_mmap_size;
29
@@ -643,14 +641,15 @@ int add_cache_entry(struct cache_entry *ce, int option)
641
* For example, you'd want to do this after doing a "git-read-tree",
642
* to link up the stat cache details with the proper files.
643
*/
646
-struct cache_entry *refresh_cache_entry(struct cache_entry *ce, int really)
644
+static struct cache_entry *refresh_cache_ent(struct cache_entry *ce, int really, int *err)
645
{
646
struct stat st;
647
struct cache_entry *updated;
648
int changed, size;
649
650
if (lstat(ce->name, &st) < 0) {
653
- cache_errno = errno;
651
+ if (err)
652
+ *err = errno;
653
return NULL;
654
}
655
@@ -664,7 +663,8 @@ struct cache_entry *refresh_cache_entry(struct cache_entry *ce, int really)
663
}
664
665
if (ce_modified(ce, &st, really)) {
667
- cache_errno = EINVAL;
666
+ if (err)
667
+ *err = EINVAL;
668
return NULL;
669
}
670
@@ -696,6 +696,8 @@ int refresh_cache(unsigned int flags)
696
697
for (i = 0; i < active_nr; i++) {
698
struct cache_entry *ce, *new;
699
+ int cache_errno = 0;
700
+
701
ce = active_cache[i];
702
if (ce_stage(ce)) {
703
while ((i < active_nr) &&
@@ -709,7 +711,7 @@ int refresh_cache(unsigned int flags)
711
continue;
712
}
713
712
- new = refresh_cache_entry(ce, really);
714
+ new = refresh_cache_ent(ce, really, &cache_errno);
715
if (new == ce)
716
continue;
717
if (!new) {
@@ -737,6 +739,11 @@ int refresh_cache(unsigned int flags)
739
return has_errors;
740
}
741
742
+struct cache_entry *refresh_cache_entry(struct cache_entry *ce, int really)
743
+{
744
+ return refresh_cache_ent(ce, really, NULL);
745
+}
746
+
747
static int verify_hdr(struct cache_header *hdr, unsigned long size)
748
{
749
SHA_CTX c;