Skip to content

Commit

Permalink
merge-recursive: Split was_tracked() out of would_lose_untracked()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Elijah Newren authored and Junio C Hamano committed Aug 14, 2011
1 parent 70cc3d3 commit aacb82d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions merge-recursive.c
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ static int dir_in_way(const char *path, int check_working_copy)
return check_working_copy && !lstat(path, &st) && S_ISDIR(st.st_mode);
}

static int would_lose_untracked(const char *path)
static int was_tracked(const char *path)
{
int pos = cache_name_pos(path, strlen(path));

Expand All @@ -638,11 +638,16 @@ static int would_lose_untracked(const char *path)
switch (ce_stage(active_cache[pos])) {
case 0:
case 2:
return 0;
return 1;
}
pos++;
}
return file_exists(path);
return 0;
}

static int would_lose_untracked(const char *path)
{
return !was_tracked(path) && file_exists(path);
}

static int make_room_for_path(const char *path)
Expand Down

0 comments on commit aacb82d

Please sign in to comment.