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

Function super_prefixed

unpack-trees.c:85–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83 : (unpack_plumbing_errors[(type)]) )
84
85static const char *super_prefixed(const char *path, const char *super_prefix)
86{
87 /*
88 * It is necessary and sufficient to have two static buffers
89 * here, as the return value of this function is fed to
90 * error() using the unpack_*_errors[] templates we see above.
91 */
92 static struct strbuf buf[2] = {STRBUF_INIT, STRBUF_INIT};
93 static int super_prefix_len = -1;
94 static unsigned idx = ARRAY_SIZE(buf) - 1;
95
96 if (super_prefix_len < 0) {
97 if (!super_prefix) {
98 super_prefix_len = 0;
99 } else {
100 int i;
101 for (i = 0; i < ARRAY_SIZE(buf); i++)
102 strbuf_addstr(&buf[i], super_prefix);
103 super_prefix_len = buf[0].len;
104 }
105 }
106
107 if (!super_prefix_len)
108 return path;
109
110 if (++idx >= ARRAY_SIZE(buf))
111 idx = 0;
112
113 strbuf_setlen(&buf[idx], super_prefix_len);
114 strbuf_addstr(&buf[idx], path);
115
116 return buf[idx].buf;
117}
118
119void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,
120 const char *cmd)

Callers 5

add_rejected_pathFunction · 0.85
display_error_msgsFunction · 0.85
display_warning_msgsFunction · 0.85
bind_mergeFunction · 0.85

Calls 2

strbuf_addstrFunction · 0.85
strbuf_setlenFunction · 0.85

Tested by

no test coverage detected