|
24 | 24 | #include "revision.h"
|
25 | 25 | #include "log-tree.h"
|
26 | 26 | #include "notes-utils.h"
|
| 27 | +#include "rerere.h" |
27 | 28 |
|
28 | 29 | /**
|
29 | 30 | * Returns 1 if the file is empty or does not exist, 0 otherwise.
|
@@ -114,6 +115,7 @@ struct am_state {
|
114 | 115 | const char *resolvemsg;
|
115 | 116 | int committer_date_is_author_date;
|
116 | 117 | int ignore_date;
|
| 118 | + int allow_rerere_autoupdate; |
117 | 119 | const char *sign_commit;
|
118 | 120 | int rebasing;
|
119 | 121 | };
|
@@ -1312,6 +1314,7 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa
|
1312 | 1314 | o.verbosity = 0;
|
1313 | 1315 |
|
1314 | 1316 | if (merge_recursive_generic(&o, our_tree, his_tree, 1, bases, &result)) {
|
| 1317 | + rerere(state->allow_rerere_autoupdate); |
1315 | 1318 | free(his_tree_name);
|
1316 | 1319 | return error(_("Failed to merge in the changes."));
|
1317 | 1320 | }
|
@@ -1531,6 +1534,8 @@ static void am_resolve(struct am_state *state)
|
1531 | 1534 | die_user_resolve(state);
|
1532 | 1535 | }
|
1533 | 1536 |
|
| 1537 | + rerere(0); |
| 1538 | + |
1534 | 1539 | do_commit(state);
|
1535 | 1540 |
|
1536 | 1541 | am_next(state);
|
@@ -1630,13 +1635,30 @@ static int clean_index(const unsigned char *head, const unsigned char *remote)
|
1630 | 1635 | return 0;
|
1631 | 1636 | }
|
1632 | 1637 |
|
| 1638 | +/** |
| 1639 | + * Resets rerere's merge resolution metadata. |
| 1640 | + */ |
| 1641 | +static void am_rerere_clear(void) |
| 1642 | +{ |
| 1643 | + struct string_list merge_rr = STRING_LIST_INIT_DUP; |
| 1644 | + int fd = setup_rerere(&merge_rr, 0); |
| 1645 | + |
| 1646 | + if (fd < 0) |
| 1647 | + return; |
| 1648 | + |
| 1649 | + rerere_clear(&merge_rr); |
| 1650 | + string_list_clear(&merge_rr, 1); |
| 1651 | +} |
| 1652 | + |
1633 | 1653 | /**
|
1634 | 1654 | * Resume the current am session by skipping the current patch.
|
1635 | 1655 | */
|
1636 | 1656 | static void am_skip(struct am_state *state)
|
1637 | 1657 | {
|
1638 | 1658 | unsigned char head[GIT_SHA1_RAWSZ];
|
1639 | 1659 |
|
| 1660 | + am_rerere_clear(); |
| 1661 | + |
1640 | 1662 | if (get_sha1("HEAD", head))
|
1641 | 1663 | hashcpy(head, EMPTY_TREE_SHA1_BIN);
|
1642 | 1664 |
|
@@ -1694,6 +1716,8 @@ static void am_abort(struct am_state *state)
|
1694 | 1716 | return;
|
1695 | 1717 | }
|
1696 | 1718 |
|
| 1719 | + am_rerere_clear(); |
| 1720 | + |
1697 | 1721 | curr_branch = resolve_refdup("HEAD", 0, curr_head, NULL);
|
1698 | 1722 | has_curr_head = !is_null_sha1(curr_head);
|
1699 | 1723 | if (!has_curr_head)
|
@@ -1823,6 +1847,7 @@ int cmd_am(int argc, const char **argv, const char *prefix)
|
1823 | 1847 | N_("lie about committer date")),
|
1824 | 1848 | OPT_BOOL(0, "ignore-date", &state.ignore_date,
|
1825 | 1849 | N_("use current timestamp for author date")),
|
| 1850 | + OPT_RERERE_AUTOUPDATE(&state.allow_rerere_autoupdate), |
1826 | 1851 | { OPTION_STRING, 'S', "gpg-sign", &state.sign_commit, N_("key-id"),
|
1827 | 1852 | N_("GPG-sign commits"),
|
1828 | 1853 | PARSE_OPT_OPTARG, NULL, (intptr_t) "" },
|
|
0 commit comments