Add an 'int *err' argument to make_cache_entry to receive any error
that occurred when matching stat information for a file on disk.
Thread it through to the same argument of refresh_cache_ent.
This will allow callers of make_cache_entry to determine whether
failure was due to a missing file on disk.

Signed-off-by: Brad King <brad.k...@kitware.com>
---
 builtin/apply.c    |  2 +-
 builtin/checkout.c |  2 +-
 builtin/reset.c    |  2 +-
 cache.h            |  2 +-
 merge-recursive.c  |  3 ++-
 read-cache.c       | 12 +++++++-----
 resolve-undo.c     |  2 +-
 7 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/builtin/apply.c b/builtin/apply.c
index b0d0986..15e14ce 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -3675,7 +3675,7 @@ static void build_fake_ancestor(struct patch *list, const 
char *filename)
                        die("sha1 information is lacking or useless "
                            "(%s).", name);
 
-               ce = make_cache_entry(patch->old_mode, sha1, name, 0, 0);
+               ce = make_cache_entry(patch->old_mode, sha1, name, 0, 0, NULL);
                if (!ce)
                        die(_("make_cache_entry failed for path '%s'"), name);
                if (add_index_entry(&result, ce, ADD_CACHE_OK_TO_ADD))
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 5df3837..c7338bb 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -208,7 +208,7 @@ static int checkout_merged(int pos, struct checkout *state)
        if (write_sha1_file(result_buf.ptr, result_buf.size,
                            blob_type, sha1))
                die(_("Unable to add merge result for '%s'"), path);
-       ce = make_cache_entry(mode, sha1, path, 2, 0);
+       ce = make_cache_entry(mode, sha1, path, 2, 0, NULL);
        if (!ce)
                die(_("make_cache_entry failed for path '%s'"), path);
        status = checkout_entry(ce, state, NULL);
diff --git a/builtin/reset.c b/builtin/reset.c
index 6004803..8e0375d 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -122,7 +122,7 @@ static void update_index_from_diff(struct diff_queue_struct 
*q,
                if (one->mode && !is_null_sha1(one->sha1)) {
                        struct cache_entry *ce;
                        ce = make_cache_entry(one->mode, one->sha1, one->path,
-                               0, 0);
+                                             0, 0, NULL);
                        if (!ce)
                                die(_("make_cache_entry failed for path '%s'"),
                                    one->path);
diff --git a/cache.h b/cache.h
index c9efe88..8e4f17d 100644
--- a/cache.h
+++ b/cache.h
@@ -487,7 +487,7 @@ extern int remove_file_from_index(struct index_state *, 
const char *path);
 #define ADD_CACHE_IMPLICIT_DOT 32      /* internal to "git add -u/-A" */
 extern int add_to_index(struct index_state *, const char *path, struct stat *, 
int flags);
 extern int add_file_to_index(struct index_state *, const char *path, int 
flags);
-extern struct cache_entry *make_cache_entry(unsigned int mode, const unsigned 
char *sha1, const char *path, int stage, int refresh);
+extern struct cache_entry *make_cache_entry(unsigned int mode, const unsigned 
char *sha1, const char *path, int stage, int refresh, int *err);
 extern int ce_same_name(const struct cache_entry *a, const struct cache_entry 
*b);
 extern int index_name_is_other(const struct index_state *, const char *, int);
 extern void *read_blob_data_from_index(struct index_state *, const char *, 
unsigned long *);
diff --git a/merge-recursive.c b/merge-recursive.c
index a18bd15..4394c44 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -201,7 +201,8 @@ static int add_cacheinfo(unsigned int mode, const unsigned 
char *sha1,
                const char *path, int stage, int refresh, int options)
 {
        struct cache_entry *ce;
-       ce = make_cache_entry(mode, sha1 ? sha1 : null_sha1, path, stage, 
refresh);
+       ce = make_cache_entry(mode, sha1 ? sha1 : null_sha1, path,
+                             stage, refresh, NULL);
        if (!ce)
                return error(_("addinfo_cache failed for path '%s'"), path);
        return add_cache_entry(ce, options);
diff --git a/read-cache.c b/read-cache.c
index 33dd676..8f16cee 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -15,7 +15,8 @@
 #include "strbuf.h"
 #include "varint.h"
 
-static struct cache_entry *refresh_cache_entry(struct cache_entry *ce, int 
really);
+static struct cache_entry *refresh_cache_entry(struct cache_entry *ce,
+                                              int really, int* err);
 
 /* Mask for the name length in ce_flags in the on-disk index */
 
@@ -696,7 +697,7 @@ int add_file_to_index(struct index_state *istate, const 
char *path, int flags)
 
 struct cache_entry *make_cache_entry(unsigned int mode,
                const unsigned char *sha1, const char *path, int stage,
-               int refresh)
+               int refresh, int* err)
 {
        int size, len;
        struct cache_entry *ce;
@@ -717,7 +718,7 @@ struct cache_entry *make_cache_entry(unsigned int mode,
        ce->ce_mode = create_ce_mode(mode);
 
        if (refresh)
-               return refresh_cache_entry(ce, 0);
+               return refresh_cache_entry(ce, 0, err);
 
        return ce;
 }
@@ -1207,9 +1208,10 @@ int refresh_index(struct index_state *istate, unsigned 
int flags,
        return has_errors;
 }
 
-static struct cache_entry *refresh_cache_entry(struct cache_entry *ce, int 
really)
+static struct cache_entry *refresh_cache_entry(struct cache_entry *ce,
+                                              int really, int* err)
 {
-       return refresh_cache_ent(&the_index, ce, really, NULL, NULL);
+       return refresh_cache_ent(&the_index, ce, really, err, NULL);
 }
 
 
diff --git a/resolve-undo.c b/resolve-undo.c
index c09b006..2b7a937 100644
--- a/resolve-undo.c
+++ b/resolve-undo.c
@@ -144,7 +144,7 @@ int unmerge_index_entry_at(struct index_state *istate, int 
pos)
                if (!ru->mode[i])
                        continue;
                nce = make_cache_entry(ru->mode[i], ru->sha1[i],
-                                      ce->name, i + 1, 0);
+                                      ce->name, i + 1, 0, NULL);
                if (matched)
                        nce->ce_flags |= CE_MATCHED;
                if (add_index_entry(istate, nce, ADD_CACHE_OK_TO_ADD)) {
-- 
1.8.5.2

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to