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

Function grab_1st_switch

wt-status.c:1681–1707  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1679};
1680
1681static int grab_1st_switch(const char *refname UNUSED,
1682 struct object_id *ooid UNUSED,
1683 struct object_id *noid,
1684 const char *email UNUSED,
1685 timestamp_t timestamp UNUSED, int tz UNUSED,
1686 const char *message, void *cb_data)
1687{
1688 struct grab_1st_switch_cbdata *cb = cb_data;
1689 const char *target = NULL, *end;
1690
1691 if (!skip_prefix(message, "checkout: moving from ", &message))
1692 return 0;
1693 target = strstr(message, " to ");
1694 if (!target)
1695 return 0;
1696 target += strlen(" to ");
1697 strbuf_reset(&cb->buf);
1698 oidcpy(&cb->noid, noid);
1699 end = strchrnul(target, '\n');
1700 strbuf_add(&cb->buf, target, end - target);
1701 if (!strcmp(cb->buf.buf, "HEAD")) {
1702 /* HEAD is relative. Resolve it to the right reflog entry. */
1703 strbuf_reset(&cb->buf);
1704 strbuf_add_unique_abbrev(&cb->buf, noid, DEFAULT_ABBREV);
1705 }
1706 return 1;
1707}
1708
1709static void wt_status_get_detached_from(struct repository *r,
1710 struct wt_status_state *state)

Callers

nothing calls this directly

Calls 3

oidcpyFunction · 0.85
strbuf_addFunction · 0.85
strbuf_add_unique_abbrevFunction · 0.85

Tested by

no test coverage detected