tree-diff: don't access hash of NULL object_id pointer
[gitweb.git] / cache.h
diff --git a/cache.h b/cache.h
index d1f2c5c08886643f0231945ca27f4d79026a3491..50fd2b3ccfd56b5a298f9e47dafb903cb82e26ba 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -597,6 +597,7 @@ extern int read_index_unmerged(struct index_state *);
 #define CLOSE_LOCK             (1 << 1)
 extern int write_locked_index(struct index_state *, struct lock_file *lock, unsigned flags);
 extern int discard_index(struct index_state *);
+extern void move_index_extensions(struct index_state *dst, struct index_state *src);
 extern int unmerged_index(const struct index_state *);
 extern int verify_path(const char *path);
 extern int strcmp_offset(const char *s1, const char *s2, size_t *first_change);
@@ -1025,6 +1026,13 @@ static inline void oidcpy(struct object_id *dst, const struct object_id *src)
        hashcpy(dst->hash, src->hash);
 }
 
+static inline struct object_id *oiddup(const struct object_id *src)
+{
+       struct object_id *dst = xmalloc(sizeof(struct object_id));
+       oidcpy(dst, src);
+       return dst;
+}
+
 static inline void hashclr(unsigned char *hash)
 {
        memset(hash, 0, GIT_SHA1_RAWSZ);