@matheusbsbs / matheus-bagliano / commits / d61633ae18
Fork 0

unpack-trees: simplify verify_absent_sparse()

verify_absent_sparse() was introduced in commit 08402b0409 ("merge-recursive: distinguish "removed" and "overwritten" messages", 2010-08-11), and has always had exactly one caller which always passes error_type == ERROR_WOULD_LOSE_UNTRACKED_OVERWRITTEN. This function then checks whether error_type is this value, and if so, sets it instead to ERROR_WOULD_LOSE_ORPHANED_OVERWRITTEN. It has been nearly a decade and no other caller has been created, and no other value has ever been passed, so just pass the expected value to begin with. Reviewed-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed Mar 27, 2020 at 00:48 UTC d61633ae186d26ab2c216108c917ec0ae7dd2782
1 file changed +2 -6
unpack-trees.c
+2 -6
@@ -506,7 +506,7 @@ static int apply_sparse_checkout(struct index_state *istate,
506 ce->ce_flags &= ~CE_UPDATE;
507 }
508 if (was_skip_worktree && !ce_skip_worktree(ce)) {
509 - if (verify_absent_sparse(ce, ERROR_WOULD_LOSE_UNTRACKED_OVERWRITTEN, o))
509 + if (verify_absent_sparse(ce, ERROR_WOULD_LOSE_ORPHANED_OVERWRITTEN, o))
510 return -1;
511 ce->ce_flags |= CE_UPDATE;
512 }
@@ -2026,11 +2026,7 @@ static int verify_absent_sparse(const struct cache_entry *ce,
2026 enum unpack_trees_error_types error_type,
2027 struct unpack_trees_options *o)
2028 {
2029 - enum unpack_trees_error_types orphaned_error = error_type;
2030 - if (orphaned_error == ERROR_WOULD_LOSE_UNTRACKED_OVERWRITTEN)
2031 - orphaned_error = ERROR_WOULD_LOSE_ORPHANED_OVERWRITTEN;
2032 -
2033 - return verify_absent_1(ce, orphaned_error, o);
2029 + return verify_absent_1(ce, error_type, o);
2030 }
2031
2032 static int merged_entry(const struct cache_entry *ce,