MCPcopy Create free account
hub / github.com/git/git / run_add_p_common

Function run_add_p_common

add-patch.c:2008–2038  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2006}
2007
2008static int run_add_p_common(struct add_p_state *state,
2009 const struct pathspec *ps,
2010 unsigned flags)
2011{
2012 size_t binary_count = 0;
2013 size_t i;
2014
2015 if (parse_diff(state, ps) < 0)
2016 return -1;
2017
2018 for (i = 0; i < state->file_diff_nr;) {
2019 if (state->file_diff[i].binary && !state->file_diff[i].hunk_nr) {
2020 binary_count++;
2021 i++;
2022 continue;
2023 }
2024 if ((i = patch_update_file(state, i, flags)) == state->file_diff_nr)
2025 break;
2026 }
2027
2028 if (!state->cfg.auto_advance)
2029 for (i = 0; i < state->file_diff_nr; i++)
2030 apply_patch(state, state->file_diff + i);
2031
2032 if (state->file_diff_nr == 0)
2033 err(state, _("No changes."));
2034 else if (binary_count == state->file_diff_nr)
2035 err(state, _("Only binary files changed."));
2036
2037 return 0;
2038}
2039
2040int run_add_p(struct repository *r, enum add_p_mode mode,
2041 struct interactive_options *opts, const char *revision,

Callers 2

run_add_pFunction · 0.85
run_add_p_indexFunction · 0.85

Calls 4

parse_diffFunction · 0.85
patch_update_fileFunction · 0.85
errFunction · 0.85
apply_patchFunction · 0.70

Tested by

no test coverage detected