Skip to content

Commit 191e9d2

Browse files
pcloudsgitster
authored andcommitted
unpack-trees: keep gently check inside add_rejected_path
This basically follows the footsteps of 6a143aa (checkout -m: attempt merge when deletion of path was staged - 2014-08-12) where there gently check is moved inside reject_merge() so that callers do not accidentally forget it. add_rejected_path() has the same usage pattern. All call sites check gently first, then decide to call add_rejected_path() if needed. Move the check inside. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 041f5ea commit 191e9d2

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

unpack-trees.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ static int add_rejected_path(struct unpack_trees_options *o,
219219
enum unpack_trees_error_types e,
220220
const char *path)
221221
{
222+
if (o->gently)
223+
return -1;
224+
222225
if (!o->show_all_errors)
223226
return error(ERRORMSG(o, e), super_prefixed(path));
224227

@@ -268,8 +271,7 @@ static int check_submodule_move_head(const struct cache_entry *ce,
268271
flags |= SUBMODULE_MOVE_HEAD_FORCE;
269272

270273
if (submodule_move_head(ce->name, old_id, new_id, flags))
271-
return o->gently ? -1 :
272-
add_rejected_path(o, ERROR_WOULD_LOSE_SUBMODULE, ce->name);
274+
return add_rejected_path(o, ERROR_WOULD_LOSE_SUBMODULE, ce->name);
273275
return 0;
274276
}
275277

@@ -1645,8 +1647,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
16451647
static int reject_merge(const struct cache_entry *ce,
16461648
struct unpack_trees_options *o)
16471649
{
1648-
return o->gently ? -1 :
1649-
add_rejected_path(o, ERROR_WOULD_OVERWRITE, ce->name);
1650+
return add_rejected_path(o, ERROR_WOULD_OVERWRITE, ce->name);
16501651
}
16511652

16521653
static int same(const struct cache_entry *a, const struct cache_entry *b)
@@ -1693,8 +1694,7 @@ static int verify_uptodate_1(const struct cache_entry *ce,
16931694
int r = check_submodule_move_head(ce,
16941695
"HEAD", oid_to_hex(&ce->oid), o);
16951696
if (r)
1696-
return o->gently ? -1 :
1697-
add_rejected_path(o, error_type, ce->name);
1697+
return add_rejected_path(o, error_type, ce->name);
16981698
return 0;
16991699
}
17001700

@@ -1712,8 +1712,7 @@ static int verify_uptodate_1(const struct cache_entry *ce,
17121712
}
17131713
if (errno == ENOENT)
17141714
return 0;
1715-
return o->gently ? -1 :
1716-
add_rejected_path(o, error_type, ce->name);
1715+
return add_rejected_path(o, error_type, ce->name);
17171716
}
17181717

17191718
int verify_uptodate(const struct cache_entry *ce,
@@ -1835,8 +1834,7 @@ static int verify_clean_subdirectory(const struct cache_entry *ce,
18351834
d.exclude_per_dir = o->dir->exclude_per_dir;
18361835
i = read_directory(&d, o->src_index, pathbuf, namelen+1, NULL);
18371836
if (i)
1838-
return o->gently ? -1 :
1839-
add_rejected_path(o, ERROR_NOT_UPTODATE_DIR, ce->name);
1837+
return add_rejected_path(o, ERROR_NOT_UPTODATE_DIR, ce->name);
18401838
free(pathbuf);
18411839
return cnt;
18421840
}
@@ -1905,8 +1903,7 @@ static int check_ok_to_remove(const char *name, int len, int dtype,
19051903
return 0;
19061904
}
19071905

1908-
return o->gently ? -1 :
1909-
add_rejected_path(o, error_type, name);
1906+
return add_rejected_path(o, error_type, name);
19101907
}
19111908

19121909
/*

0 commit comments

Comments
 (0)