use file_exists() to check if a file exists in the worktree
Call file_exists() instead of open-coding it. That's shorter, simpler and the intent becomes clearer. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
aaa7e0d7f8
commit
dbe44faadb
@ -611,7 +611,6 @@ static char *unique_path(struct merge_options *o, const char *path, const char *
|
||||
{
|
||||
struct strbuf newpath = STRBUF_INIT;
|
||||
int suffix = 0;
|
||||
struct stat st;
|
||||
size_t base_len;
|
||||
|
||||
strbuf_addf(&newpath, "%s~", path);
|
||||
@ -620,7 +619,7 @@ static char *unique_path(struct merge_options *o, const char *path, const char *
|
||||
base_len = newpath.len;
|
||||
while (string_list_has_string(&o->current_file_set, newpath.buf) ||
|
||||
string_list_has_string(&o->current_directory_set, newpath.buf) ||
|
||||
lstat(newpath.buf, &st) == 0) {
|
||||
file_exists(newpath.buf)) {
|
||||
strbuf_setlen(&newpath, base_len);
|
||||
strbuf_addf(&newpath, "_%d", suffix++);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user