Skip to content

Commit ff36682

Browse files
Lukas Fleischergitster
authored andcommitted
read_blob_data_from_index(): optionally return the size of blob data
This allows for optionally getting the size of the returned data and will be used in a follow-up patch. Signed-off-by: Lukas Fleischer <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 29fb37b commit ff36682

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

attr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ static struct attr_stack *read_attr_from_index(const char *path, int macro_ok)
387387
char *buf, *sp;
388388
int lineno = 0;
389389

390-
buf = read_blob_data_from_index(use_index ? use_index : &the_index, path);
390+
buf = read_blob_data_from_index(use_index ? use_index : &the_index, path, NULL);
391391
if (!buf)
392392
return NULL;
393393

cache.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ extern void free_name_hash(struct index_state *istate);
307307
#define resolve_undo_clear() resolve_undo_clear_index(&the_index)
308308
#define unmerge_cache_entry_at(at) unmerge_index_entry_at(&the_index, at)
309309
#define unmerge_cache(pathspec) unmerge_index(&the_index, pathspec)
310-
#define read_blob_data_from_cache(path) read_blob_data_from_index(&the_index, (path))
310+
#define read_blob_data_from_cache(path, sz) read_blob_data_from_index(&the_index, (path), (sz))
311311
#endif
312312

313313
enum object_type {
@@ -453,7 +453,7 @@ extern int add_file_to_index(struct index_state *, const char *path, int flags);
453453
extern struct cache_entry *make_cache_entry(unsigned int mode, const unsigned char *sha1, const char *path, int stage, int refresh);
454454
extern int ce_same_name(struct cache_entry *a, struct cache_entry *b);
455455
extern int index_name_is_other(const struct index_state *, const char *, int);
456-
extern void *read_blob_data_from_index(struct index_state *, const char *);
456+
extern void *read_blob_data_from_index(struct index_state *, const char *, unsigned long *);
457457

458458
/* do stat comparison even if CE_VALID is true */
459459
#define CE_MATCH_IGNORE_VALID 01

read-cache.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1896,7 +1896,7 @@ int index_name_is_other(const struct index_state *istate, const char *name,
18961896
return 1;
18971897
}
18981898

1899-
void *read_blob_data_from_index(struct index_state *istate, const char *path)
1899+
void *read_blob_data_from_index(struct index_state *istate, const char *path, unsigned long *size)
19001900
{
19011901
int pos, len;
19021902
unsigned long sz;
@@ -1925,5 +1925,7 @@ void *read_blob_data_from_index(struct index_state *istate, const char *path)
19251925
free(data);
19261926
return NULL;
19271927
}
1928+
if (size)
1929+
*size = sz;
19281930
return data;
19291931
}

0 commit comments

Comments
 (0)