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

Function guess_p_value

apply.c:747–775  ·  view source on GitHub ↗

* Given the string after "--- " or "+++ ", guess the appropriate * p_value for the given patch. */

Source from the content-addressed store, hash-verified

745 * p_value for the given patch.
746 */
747static int guess_p_value(struct apply_state *state, const char *nameline)
748{
749 char *name, *cp;
750 int val = -1;
751
752 if (is_dev_null(nameline))
753 return -1;
754 name = find_name_traditional(&state->root, nameline, NULL, 0);
755 if (!name)
756 return -1;
757 cp = strchr(name, '/');
758 if (!cp)
759 val = 0;
760 else if (state->prefix) {
761 /*
762 * Does it begin with "a/$our-prefix" and such? Then this is
763 * very likely to apply to our directory.
764 */
765 if (starts_with(name, state->prefix))
766 val = count_slashes(state->prefix);
767 else {
768 cp++;
769 if (starts_with(cp, state->prefix))
770 val = count_slashes(state->prefix) + 1;
771 }
772 }
773 free(name);
774 return val;
775}
776
777/*
778 * Does the ---/+++ line have the POSIX timestamp after the last HT?

Callers 1

parse_traditional_patchFunction · 0.85

Calls 4

is_dev_nullFunction · 0.85
find_name_traditionalFunction · 0.85
starts_withFunction · 0.85
count_slashesFunction · 0.85

Tested by

no test coverage detected