@matheusbsbs / matheus-bagliano / commits / 35a5aa79d0
Fork 0

unpack-trees.c: generalize verify_* functions

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Aug 20, 2009 at 20:47 UTC 35a5aa79d040e2121b6f6bbb17b173f4644699e3
1 file changed +18 -5
unpack-trees.c
+18 -5
@@ -452,8 +452,9 @@ static int same(struct cache_entry *a, struct cache_entry *b)
452 * When a CE gets turned into an unmerged entry, we
453 * want it to be up-to-date
454 */
455 -static int verify_uptodate(struct cache_entry *ce,
456 - struct unpack_trees_options *o)
455 +static int verify_uptodate_1(struct cache_entry *ce,
456 + struct unpack_trees_options *o,
457 + const char *error_msg)
458 {
459 struct stat st;
460
@@ -478,7 +479,13 @@ static int verify_uptodate(struct cache_entry *ce,
479 if (errno == ENOENT)
480 return 0;
481 return o->gently ? -1 :
481 - error(ERRORMSG(o, not_uptodate_file), ce->name);
482 + error(error_msg, ce->name);
483 +}
484 +
485 +static int verify_uptodate(struct cache_entry *ce,
486 + struct unpack_trees_options *o)
487 +{
488 + return verify_uptodate_1(ce, o, ERRORMSG(o, not_uptodate_file));
489 }
490
491 static void invalidate_ce_path(struct cache_entry *ce, struct unpack_trees_options *o)
@@ -586,8 +593,9 @@ static int icase_exists(struct unpack_trees_options *o, struct cache_entry *dst,
593 * We do not want to remove or overwrite a working tree file that
594 * is not tracked, unless it is ignored.
595 */
589 -static int verify_absent(struct cache_entry *ce, const char *action,
590 - struct unpack_trees_options *o)
596 +static int verify_absent_1(struct cache_entry *ce, const char *action,
597 + struct unpack_trees_options *o,
598 + const char *error_msg)
599 {
600 struct stat st;
601
@@ -667,6 +675,11 @@ static int verify_absent(struct cache_entry *ce, const char *action,
675 }
676 return 0;
677 }
678 +static int verify_absent(struct cache_entry *ce, const char *action,
679 + struct unpack_trees_options *o)
680 +{
681 + return verify_absent_1(ce, action, o, ERRORMSG(o, would_lose_untracked));
682 +}
683
684 static int merged_entry(struct cache_entry *merge, struct cache_entry *old,
685 struct unpack_trees_options *o)