merge-recursive: Split was_tracked() out of would_lose_untracked()
Checking whether a filename was part of stage 0 or stage 2 is code that we would like to be able to call from a few other places without also lstat()-ing the file to see if it exists in the working copy. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Elijah Newren committed
Aug 11, 2011 at 23:19 UTC
aacb82de3ff8ae7b0a9e4cfec16c1807b6c315ef
1 file changed
+8
-3
merge-recursive.c
+8
-3
@@ -621,7 +621,7 @@ static int dir_in_way(const char *path, int check_working_copy)
621
return check_working_copy && !lstat(path, &st) && S_ISDIR(st.st_mode);
622
}
623
624
-static int would_lose_untracked(const char *path)
624
+static int was_tracked(const char *path)
625
{
626
int pos = cache_name_pos(path, strlen(path));
627
@@ -638,11 +638,16 @@ static int would_lose_untracked(const char *path)
638
switch (ce_stage(active_cache[pos])) {
639
case 0:
640
case 2:
641
- return 0;
641
+ return 1;
642
}
643
pos++;
644
}
645
- return file_exists(path);
645
+ return 0;
646
+}
647
+
648
+static int would_lose_untracked(const char *path)
649
+{
650
+ return !was_tracked(path) && file_exists(path);
651
}
652
653
static int make_room_for_path(const char *path)