When recreating merge conflicts with "git checkout -m <path>" the original conflict labels are lost. For commands like "git merge" and "git cherry-pick" we could use the presence of the related root ref (MERGE_HEAD and CHERRY_PICK_HEAD respectively) to recreate the labels. However, if the conflicts are from "git stash pop" or "git checkout -m <branch>", then there is no ref to deduce the labels from. To ensure the labels are always available, the merge machinery is updated to write ".git/MERGE_LABELS" when it updates the worktree and there are conflicts. The labels are then read from that file by "git checkout -m <path>" when recreating the conflicts. As "git checkout -m <branch>" calls remove_branch_state() which ordinarily removes the labels file, we need to pass a flag down to optionally prevent that so that the labels are available for any subsequent "git checkout -m <path>". Note that merge_switch_to_result() we assign "result->priv" to "opt->priv" and later clear "opt->priv" in order to get a pointer to the private struct as result->priv is void*. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
21 lines
609 B
C
21 lines
609 B
C
#ifndef MERGE_H
|
|
#define MERGE_H
|
|
|
|
struct commit_list;
|
|
struct object_id;
|
|
struct repository;
|
|
|
|
int try_merge_command(struct repository *r,
|
|
const char *strategy, size_t xopts_nr,
|
|
const char **xopts, struct commit_list *common,
|
|
const char *head_arg, struct commit_list *remotes);
|
|
int checkout_fast_forward(struct repository *r,
|
|
const struct object_id *from,
|
|
const struct object_id *to,
|
|
int overwrite_ignore);
|
|
int write_merge_labels(struct repository *r, const char *labels[3]);
|
|
int read_merge_labels(struct repository *r,
|
|
char **base, char **ours, char **theirs);
|
|
|
|
#endif /* MERGE_H */
|