| 135 | |
| 136 | |
| 137 | struct notes_rewrite_cfg *init_copy_notes_for_rewrite(const char *cmd) |
| 138 | { |
| 139 | struct notes_rewrite_cfg *c = xmalloc(sizeof(struct notes_rewrite_cfg)); |
| 140 | const char *rewrite_mode_env = getenv(GIT_NOTES_REWRITE_MODE_ENVIRONMENT); |
| 141 | const char *rewrite_refs_env = getenv(GIT_NOTES_REWRITE_REF_ENVIRONMENT); |
| 142 | c->cmd = cmd; |
| 143 | c->enabled = 1; |
| 144 | c->combine = combine_notes_concatenate; |
| 145 | CALLOC_ARRAY(c->refs, 1); |
| 146 | c->refs->strdup_strings = 1; |
| 147 | c->refs_from_env = 0; |
| 148 | c->mode_from_env = 0; |
| 149 | if (rewrite_mode_env) { |
| 150 | c->mode_from_env = 1; |
| 151 | c->combine = parse_combine_notes_fn(rewrite_mode_env); |
| 152 | if (!c->combine) |
| 153 | /* |
| 154 | * TRANSLATORS: The first %s is the name of |
| 155 | * the environment variable, the second %s is |
| 156 | * its value. |
| 157 | */ |
| 158 | error(_("Bad %s value: '%s'"), GIT_NOTES_REWRITE_MODE_ENVIRONMENT, |
| 159 | rewrite_mode_env); |
| 160 | } |
| 161 | if (rewrite_refs_env) { |
| 162 | c->refs_from_env = 1; |
| 163 | string_list_add_refs_from_colon_sep(c->refs, rewrite_refs_env); |
| 164 | } |
| 165 | repo_config(the_repository, notes_rewrite_config, c); |
| 166 | if (!c->enabled || !c->refs->nr) { |
| 167 | string_list_clear(c->refs, 0); |
| 168 | free(c->refs); |
| 169 | free(c); |
| 170 | return NULL; |
| 171 | } |
| 172 | c->trees = load_notes_trees(c->refs, NOTES_INIT_WRITABLE); |
| 173 | string_list_clear(c->refs, 0); |
| 174 | free(c->refs); |
| 175 | return c; |
| 176 | } |
| 177 | |
| 178 | int copy_note_for_rewrite(struct notes_rewrite_cfg *c, |
| 179 | const struct object_id *from_obj, const struct object_id *to_obj) |
no test coverage detected