builtin-am: rerere support
git-am.sh will call git-rerere at the following events: * "git rerere" when a three-way merge fails to record the conflicted automerge results. Since8389b52
(git-rerere: reuse recorded resolve., 2006-01-28) * Sincecb6020b
(Teach --[no-]rerere-autoupdate option to merge, revert and friends, 2009-12-04), git-am.sh supports the --[no-]rerere-autoupdate option as well, and would pass it to git-rerere. * "git rerere" when --resolved, to record the hand resolution. Sincef131dd4
(rerere: record (or avoid misrecording) resolved, skipped or aborted rebase/am, 2006-12-08) * "git rerere clear" when --skip-ing. Sincef131dd4
(rerere: record (or avoid misrecording) resolved, skipped or aborted rebase/am, 2006-12-08) * "git rerere clear" when --abort-ing. Since3e5057a
(git am --abort, 2008-07-16) Re-implement the above in builtin/am.c. Signed-off-by: Paul Tan <pyokagan@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
7088f8078a
commit
f1cb96d687
25
builtin/am.c
25
builtin/am.c
@ -24,6 +24,7 @@
|
|||||||
#include "revision.h"
|
#include "revision.h"
|
||||||
#include "log-tree.h"
|
#include "log-tree.h"
|
||||||
#include "notes-utils.h"
|
#include "notes-utils.h"
|
||||||
|
#include "rerere.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns 1 if the file is empty or does not exist, 0 otherwise.
|
* Returns 1 if the file is empty or does not exist, 0 otherwise.
|
||||||
@ -114,6 +115,7 @@ struct am_state {
|
|||||||
const char *resolvemsg;
|
const char *resolvemsg;
|
||||||
int committer_date_is_author_date;
|
int committer_date_is_author_date;
|
||||||
int ignore_date;
|
int ignore_date;
|
||||||
|
int allow_rerere_autoupdate;
|
||||||
const char *sign_commit;
|
const char *sign_commit;
|
||||||
int rebasing;
|
int rebasing;
|
||||||
};
|
};
|
||||||
@ -1312,6 +1314,7 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa
|
|||||||
o.verbosity = 0;
|
o.verbosity = 0;
|
||||||
|
|
||||||
if (merge_recursive_generic(&o, our_tree, his_tree, 1, bases, &result)) {
|
if (merge_recursive_generic(&o, our_tree, his_tree, 1, bases, &result)) {
|
||||||
|
rerere(state->allow_rerere_autoupdate);
|
||||||
free(his_tree_name);
|
free(his_tree_name);
|
||||||
return error(_("Failed to merge in the changes."));
|
return error(_("Failed to merge in the changes."));
|
||||||
}
|
}
|
||||||
@ -1531,6 +1534,8 @@ static void am_resolve(struct am_state *state)
|
|||||||
die_user_resolve(state);
|
die_user_resolve(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rerere(0);
|
||||||
|
|
||||||
do_commit(state);
|
do_commit(state);
|
||||||
|
|
||||||
am_next(state);
|
am_next(state);
|
||||||
@ -1630,6 +1635,21 @@ static int clean_index(const unsigned char *head, const unsigned char *remote)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets rerere's merge resolution metadata.
|
||||||
|
*/
|
||||||
|
static void am_rerere_clear(void)
|
||||||
|
{
|
||||||
|
struct string_list merge_rr = STRING_LIST_INIT_DUP;
|
||||||
|
int fd = setup_rerere(&merge_rr, 0);
|
||||||
|
|
||||||
|
if (fd < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
rerere_clear(&merge_rr);
|
||||||
|
string_list_clear(&merge_rr, 1);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resume the current am session by skipping the current patch.
|
* Resume the current am session by skipping the current patch.
|
||||||
*/
|
*/
|
||||||
@ -1637,6 +1657,8 @@ static void am_skip(struct am_state *state)
|
|||||||
{
|
{
|
||||||
unsigned char head[GIT_SHA1_RAWSZ];
|
unsigned char head[GIT_SHA1_RAWSZ];
|
||||||
|
|
||||||
|
am_rerere_clear();
|
||||||
|
|
||||||
if (get_sha1("HEAD", head))
|
if (get_sha1("HEAD", head))
|
||||||
hashcpy(head, EMPTY_TREE_SHA1_BIN);
|
hashcpy(head, EMPTY_TREE_SHA1_BIN);
|
||||||
|
|
||||||
@ -1694,6 +1716,8 @@ static void am_abort(struct am_state *state)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
am_rerere_clear();
|
||||||
|
|
||||||
curr_branch = resolve_refdup("HEAD", 0, curr_head, NULL);
|
curr_branch = resolve_refdup("HEAD", 0, curr_head, NULL);
|
||||||
has_curr_head = !is_null_sha1(curr_head);
|
has_curr_head = !is_null_sha1(curr_head);
|
||||||
if (!has_curr_head)
|
if (!has_curr_head)
|
||||||
@ -1823,6 +1847,7 @@ int cmd_am(int argc, const char **argv, const char *prefix)
|
|||||||
N_("lie about committer date")),
|
N_("lie about committer date")),
|
||||||
OPT_BOOL(0, "ignore-date", &state.ignore_date,
|
OPT_BOOL(0, "ignore-date", &state.ignore_date,
|
||||||
N_("use current timestamp for author date")),
|
N_("use current timestamp for author date")),
|
||||||
|
OPT_RERERE_AUTOUPDATE(&state.allow_rerere_autoupdate),
|
||||||
{ OPTION_STRING, 'S', "gpg-sign", &state.sign_commit, N_("key-id"),
|
{ OPTION_STRING, 'S', "gpg-sign", &state.sign_commit, N_("key-id"),
|
||||||
N_("GPG-sign commits"),
|
N_("GPG-sign commits"),
|
||||||
PARSE_OPT_OPTARG, NULL, (intptr_t) "" },
|
PARSE_OPT_OPTARG, NULL, (intptr_t) "" },
|
||||||
|
Loading…
Reference in New Issue
Block a user