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

Function append_fetch_head

builtin/fetch.c:1145–1189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1143}
1144
1145static void append_fetch_head(struct fetch_head *fetch_head,
1146 const struct object_id *old_oid,
1147 enum fetch_head_status fetch_head_status,
1148 const char *note,
1149 const char *url, size_t url_len)
1150{
1151 char old_oid_hex[GIT_MAX_HEXSZ + 1];
1152 const char *merge_status_marker;
1153 size_t i;
1154
1155 if (!fetch_head->fp)
1156 return;
1157
1158 switch (fetch_head_status) {
1159 case FETCH_HEAD_NOT_FOR_MERGE:
1160 merge_status_marker = "not-for-merge";
1161 break;
1162 case FETCH_HEAD_MERGE:
1163 merge_status_marker = "";
1164 break;
1165 default:
1166 /* do not write anything to FETCH_HEAD */
1167 return;
1168 }
1169
1170 strbuf_addf(&fetch_head->buf, "%s\t%s\t%s",
1171 oid_to_hex_r(old_oid_hex, old_oid), merge_status_marker, note);
1172 for (i = 0; i < url_len; ++i)
1173 if ('\n' == url[i])
1174 strbuf_addstr(&fetch_head->buf, "\\n");
1175 else
1176 strbuf_addch(&fetch_head->buf, url[i]);
1177 strbuf_addch(&fetch_head->buf, '\n');
1178
1179 /*
1180 * When using an atomic fetch, we do not want to update FETCH_HEAD if
1181 * any of the reference updates fails. We thus have to write all
1182 * updates to a buffer first and only commit it as soon as all
1183 * references have been successfully updated.
1184 */
1185 if (!atomic_fetch) {
1186 strbuf_write(&fetch_head->buf, fetch_head->fp);
1187 strbuf_reset(&fetch_head->buf);
1188 }
1189}
1190
1191static void commit_fetch_head(struct fetch_head *fetch_head)
1192{

Callers 1

store_updated_refsFunction · 0.85

Calls 5

strbuf_addfFunction · 0.85
oid_to_hex_rFunction · 0.85
strbuf_addstrFunction · 0.85
strbuf_addchFunction · 0.85
strbuf_writeFunction · 0.85

Tested by

no test coverage detected