| 83 | : (unpack_plumbing_errors[(type)]) ) |
| 84 | |
| 85 | static 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 | |
| 119 | void setup_unpack_trees_porcelain(struct unpack_trees_options *opts, |
| 120 | const char *cmd) |
no test coverage detected