Skip to content

Commit aacb82d

Browse files
newrengitster
authored andcommitted
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>
1 parent 70cc3d3 commit aacb82d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

merge-recursive.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ static int dir_in_way(const char *path, int check_working_copy)
621621
return check_working_copy && !lstat(path, &st) && S_ISDIR(st.st_mode);
622622
}
623623

624-
static int would_lose_untracked(const char *path)
624+
static int was_tracked(const char *path)
625625
{
626626
int pos = cache_name_pos(path, strlen(path));
627627

@@ -638,11 +638,16 @@ static int would_lose_untracked(const char *path)
638638
switch (ce_stage(active_cache[pos])) {
639639
case 0:
640640
case 2:
641-
return 0;
641+
return 1;
642642
}
643643
pos++;
644644
}
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);
646651
}
647652

648653
static int make_room_for_path(const char *path)

0 commit comments

Comments
 (0)