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

Function gitdiff_verify_name

apply.c:929–974  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

927#define DIFF_NEW_NAME 1
928
929static int gitdiff_verify_name(struct gitdiff_data *state,
930 const char *line,
931 int isnull,
932 char **name,
933 int side)
934{
935 if (!*name && !isnull) {
936 *name = find_name(state->root, line, NULL, state->p_value, TERM_TAB);
937 return 0;
938 }
939
940 if (*name) {
941 char *another;
942 if (isnull) {
943 if (state->patch_input_file)
944 return error(_("git apply: bad git-diff - expected /dev/null, got %s at %s:%d"),
945 *name, state->patch_input_file, state->linenr);
946 return error(_("git apply: bad git-diff - expected /dev/null, got %s on line %d"),
947 *name, state->linenr);
948 }
949 another = find_name(state->root, line, NULL, state->p_value, TERM_TAB);
950 if (!another || strcmp(another, *name)) {
951 free(another);
952 if (state->patch_input_file)
953 return error((side == DIFF_NEW_NAME) ?
954 _("git apply: bad git-diff - inconsistent new filename at %s:%d") :
955 _("git apply: bad git-diff - inconsistent old filename at %s:%d"),
956 state->patch_input_file, state->linenr);
957 return error((side == DIFF_NEW_NAME) ?
958 _("git apply: bad git-diff - inconsistent new filename on line %d") :
959 _("git apply: bad git-diff - inconsistent old filename on line %d"),
960 state->linenr);
961 }
962 free(another);
963 } else {
964 if (!is_dev_null(line)) {
965 if (state->patch_input_file)
966 return error(_("git apply: bad git-diff - expected /dev/null at %s:%d"),
967 state->patch_input_file, state->linenr);
968 return error(_("git apply: bad git-diff - expected /dev/null on line %d"),
969 state->linenr);
970 }
971 }
972
973 return 0;
974}
975
976static int gitdiff_oldname(struct gitdiff_data *state,
977 const char *line,

Callers 2

gitdiff_oldnameFunction · 0.85
gitdiff_newnameFunction · 0.85

Calls 3

find_nameFunction · 0.85
errorFunction · 0.85
is_dev_nullFunction · 0.85

Tested by

no test coverage detected