@matheusbsbs / matheus-bagliano / commits / 6640f88165
Fork 0

Move make_cache_entry() from merge-recursive.c into read-cache.c

The function make_cache_entry() is too useful to be hidden away in merge-recursive. So move it to libgit.a (exposing it via cache.h). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Carlos Rica committed Sep 11, 2007 at 05:17 UTC 6640f88165f77edcc266a2c0c56fb017dc613198
3 files changed +26 -24
cache.h
+1
@@ -264,6 +264,7 @@ extern struct cache_entry *refresh_cache_entry(struct cache_entry *ce, int reall
264 extern int remove_index_entry_at(struct index_state *, int pos);
265 extern int remove_file_from_index(struct index_state *, const char *path);
266 extern int add_file_to_index(struct index_state *, const char *path, int verbose);
267 +extern struct cache_entry *make_cache_entry(unsigned int mode, const unsigned char *sha1, const char *path, int stage, int refresh);
268 extern int ce_same_name(struct cache_entry *a, struct cache_entry *b);
269 extern int ie_match_stat(struct index_state *, struct cache_entry *, struct stat *, int);
270 extern int ie_modified(struct index_state *, struct cache_entry *, struct stat *, int);
merge-recursive.c
-24
@@ -171,30 +171,6 @@ static void output_commit_title(struct commit *commit)
171 }
172 }
173
174 -static struct cache_entry *make_cache_entry(unsigned int mode,
175 - const unsigned char *sha1, const char *path, int stage, int refresh)
176 -{
177 - int size, len;
178 - struct cache_entry *ce;
179 -
180 - if (!verify_path(path))
181 - return NULL;
182 -
183 - len = strlen(path);
184 - size = cache_entry_size(len);
185 - ce = xcalloc(1, size);
186 -
187 - hashcpy(ce->sha1, sha1);
188 - memcpy(ce->name, path, len);
189 - ce->ce_flags = create_ce_flags(len, stage);
190 - ce->ce_mode = create_ce_mode(mode);
191 -
192 - if (refresh)
193 - return refresh_cache_entry(ce, 0);
194 -
195 - return ce;
196 -}
197 -
174 static int add_cacheinfo(unsigned int mode, const unsigned char *sha1,
175 const char *path, int stage, int refresh, int options)
176 {
read-cache.c
+25
@@ -434,6 +434,31 @@ int add_file_to_index(struct index_state *istate, const char *path, int verbose)
434 return 0;
435 }
436
437 +struct cache_entry *make_cache_entry(unsigned int mode,
438 + const unsigned char *sha1, const char *path, int stage,
439 + int refresh)
440 +{
441 + int size, len;
442 + struct cache_entry *ce;
443 +
444 + if (!verify_path(path))
445 + return NULL;
446 +
447 + len = strlen(path);
448 + size = cache_entry_size(len);
449 + ce = xcalloc(1, size);
450 +
451 + hashcpy(ce->sha1, sha1);
452 + memcpy(ce->name, path, len);
453 + ce->ce_flags = create_ce_flags(len, stage);
454 + ce->ce_mode = create_ce_mode(mode);
455 +
456 + if (refresh)
457 + return refresh_cache_entry(ce, 0);
458 +
459 + return ce;
460 +}
461 +
462 int ce_same_name(struct cache_entry *a, struct cache_entry *b)
463 {
464 int len = ce_namelen(a);