Skip to content

Commit 0488481

Browse files
pcloudsgitster
authored andcommitted
sha1-name.c: remove the_repo from diagnose_invalid_index_path()
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c931ba4 commit 0488481

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

dir.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2315,6 +2315,14 @@ int file_exists(const char *f)
23152315
return lstat(f, &sb) == 0;
23162316
}
23172317

2318+
int repo_file_exists(struct repository *repo, const char *path)
2319+
{
2320+
if (repo != the_repository)
2321+
BUG("do not know how to check file existence in arbitrary repo");
2322+
2323+
return file_exists(path);
2324+
}
2325+
23182326
static int cmp_icase(char a, char b)
23192327
{
23202328
if (a == b)

dir.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,9 @@ extern void add_exclude(const char *string, const char *base,
269269
int baselen, struct exclude_list *el, int srcpos);
270270
extern void clear_exclude_list(struct exclude_list *el);
271271
extern void clear_directory(struct dir_struct *dir);
272-
extern int file_exists(const char *);
272+
273+
int repo_file_exists(struct repository *repo, const char *path);
274+
int file_exists(const char *);
273275

274276
extern int is_inside_dir(const char *dir);
275277
extern int dir_inside_of(const char *subdir, const char *dir);

sha1-name.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1664,11 +1664,12 @@ static void diagnose_invalid_oid_path(const char *prefix,
16641664
}
16651665

16661666
/* Must be called only when :stage:filename doesn't exist. */
1667-
static void diagnose_invalid_index_path(struct index_state *istate,
1667+
static void diagnose_invalid_index_path(struct repository *r,
16681668
int stage,
16691669
const char *prefix,
16701670
const char *filename)
16711671
{
1672+
struct index_state *istate = r->index;
16721673
const struct cache_entry *ce;
16731674
int pos;
16741675
unsigned namelen = strlen(filename);
@@ -1708,7 +1709,7 @@ static void diagnose_invalid_index_path(struct index_state *istate,
17081709
ce_stage(ce), filename);
17091710
}
17101711

1711-
if (file_exists(filename))
1712+
if (repo_file_exists(r, filename))
17121713
die("Path '%s' exists on disk, but not in the index.", filename);
17131714
if (is_missing_file_error(errno))
17141715
die("Path '%s' does not exist (neither on disk nor in the index).",
@@ -1814,7 +1815,7 @@ static enum get_oid_result get_oid_with_context_1(struct repository *repo,
18141815
pos++;
18151816
}
18161817
if (only_to_die && name[1] && name[1] != '/')
1817-
diagnose_invalid_index_path(repo->index, stage, prefix, cp);
1818+
diagnose_invalid_index_path(repo, stage, prefix, cp);
18181819
free(new_path);
18191820
return -1;
18201821
}

0 commit comments

Comments
 (0)