summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1a56be1)
raw | patch | inline | side by side (parent: 1a56be1)
author | Junio C Hamano <gitster@pobox.com> | |
Fri, 4 Dec 2009 08:20:48 +0000 (00:20 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 4 Dec 2009 08:20:48 +0000 (00:20 -0800) |
Introduce a command line option to override rerere.autoupdate configuration
variable to make it more useful.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
variable to make it more useful.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 files changed:
Documentation/git-merge.txt | patch | blob | history | |
builtin-commit.c | patch | blob | history | |
builtin-merge.c | patch | blob | history | |
builtin-rerere.c | patch | blob | history | |
builtin-revert.c | patch | blob | history | |
git-am.sh | patch | blob | history | |
git-rebase.sh | patch | blob | history | |
parse-options.c | patch | blob | history | |
parse-options.h | patch | blob | history | |
rerere.c | patch | blob | history | |
rerere.h | patch | blob | history | |
t/t4200-rerere.sh | patch | blob | history |
index e886c2ef543501deea84909b2e88fb163a1c9d2b..67470311e24a4ae6837adeaaec84ed24a6a4ae1f 100644 (file)
--------
[verse]
'git merge' [-n] [--stat] [--no-commit] [--squash] [-s <strategy>]...
- [-m <msg>] <remote>...
+ [--[no-]rerere-autoupdate] [-m <msg>] <remote>...
'git merge' <msg> HEAD <remote>...
DESCRIPTION
used to give a good default for automated 'git merge'
invocations.
+--rerere-autoupdate::
+--no-rerere-autoupdate::
+ Allow the rerere mechanism to update the index with the
+ result of auto-conflict resolution if possible.
+
<remote>...::
Other branch heads to merge into our branch. You need at
least one <remote>. Specifying more than one <remote>
diff --git a/builtin-commit.c b/builtin-commit.c
index e93a647c59f1f52a4b0eb92b6c84fd9cec0aad6a..72e0f0b563ee08993f0b73fa868ad525edc5f8ab 100644 (file)
--- a/builtin-commit.c
+++ b/builtin-commit.c
"new_index file. Check that disk is not full or quota is\n"
"not exceeded, and then \"git reset HEAD\" to recover.");
- rerere();
+ rerere(0);
run_hook(get_index_file(), "post-commit", NULL);
if (!quiet)
print_summary(prefix, commit_sha1);
diff --git a/builtin-merge.c b/builtin-merge.c
index 56a1bb651f89c05178153906192857d34c8061e3..c3faa6b9c3978267b979e74ddbb3a3d893c81dba 100644 (file)
--- a/builtin-merge.c
+++ b/builtin-merge.c
static size_t use_strategies_nr, use_strategies_alloc;
static const char *branch;
static int verbosity;
+static int allow_rerere_auto;
static struct strategy all_strategy[] = {
{ "recursive", DEFAULT_TWOHEAD | NO_TRIVIAL },
"allow fast-forward (default)"),
OPT_BOOLEAN(0, "ff-only", &fast_forward_only,
"abort if fast-forward is not possible"),
+ OPT_RERERE_AUTOUPDATE(&allow_rerere_auto),
OPT_CALLBACK('s', "strategy", &use_strategies, "strategy",
"merge strategy to use", option_parse_strategy),
OPT_CALLBACK('m', "message", &merge_msg, "message",
}
}
fclose(fp);
- rerere();
+ rerere(allow_rerere_auto);
printf("Automatic merge failed; "
"fix conflicts and then commit the result.\n");
return 1;
diff --git a/builtin-rerere.c b/builtin-rerere.c
index 343d6cde48266d63c0aa6826b973e55b48820745..7ec602cf55fd39ee5ae5b84831ccd5b583795631 100644 (file)
--- a/builtin-rerere.c
+++ b/builtin-rerere.c
int cmd_rerere(int argc, const char **argv, const char *prefix)
{
struct string_list merge_rr = { NULL, 0, 0, 1 };
- int i, fd;
-
+ int i, fd, flags = 0;
+
+ if (2 < argc) {
+ if (!strcmp(argv[1], "-h"))
+ usage(git_rerere_usage);
+ if (!strcmp(argv[1], "--rerere-autoupdate"))
+ flags = RERERE_AUTOUPDATE;
+ else if (!strcmp(argv[1], "--no-rerere-autoupdate"))
+ flags = RERERE_NOAUTOUPDATE;
+ if (flags) {
+ argc--;
+ argv++;
+ }
+ }
if (argc < 2)
- return rerere();
-
- if (!strcmp(argv[1], "-h"))
- usage(git_rerere_usage);
+ return rerere(flags);
- fd = setup_rerere(&merge_rr);
+ fd = setup_rerere(&merge_rr, flags);
if (fd < 0)
return 0;
diff --git a/builtin-revert.c b/builtin-revert.c
index 151aa6a981832954120359f7c953015525b530d8..857ca2eefa9719029faf48a143ee4afa846c77a6 100644 (file)
--- a/builtin-revert.c
+++ b/builtin-revert.c
static int edit, no_replay, no_commit, mainline, signoff;
static enum { REVERT, CHERRY_PICK } action;
static struct commit *commit;
+static int allow_rerere_auto;
static const char *me;
OPT_BOOLEAN('r', NULL, &noop, "no-op (backward compatibility)"),
OPT_BOOLEAN('s', "signoff", &signoff, "add Signed-off-by:"),
OPT_INTEGER('m', "mainline", &mainline, "parent number"),
+ OPT_RERERE_AUTOUPDATE(&allow_rerere_auto),
OPT_END(),
};
die ("Error wrapping up %s", defmsg);
fprintf(stderr, "Automatic %s failed.%s\n",
me, help_msg(commit->object.sha1));
- rerere();
+ rerere(allow_rerere_auto);
exit(1);
}
if (commit_lock_file(&msg_file) < 0)
diff --git a/git-am.sh b/git-am.sh
index 4838cdb9ede8765b37ab663aa59fb1b011a30b4c..2f46fda47bc1aa0a345c5cb7293724497965d75e 100755 (executable)
--- a/git-am.sh
+++ b/git-am.sh
abort restore the original branch and abort the patching operation.
committer-date-is-author-date lie about committer date
ignore-date use current timestamp for author date
+rerere-autoupdate update the index with reused conflict resolution if possible
rebasing* (internal use for git-rebase)"
. git-sh-setup
export GIT_MERGE_VERBOSITY=0
fi
git-merge-recursive $orig_tree -- HEAD $his_tree || {
- git rerere
+ git rerere $allow_rerere_autoupdate
echo Failed to merge in the changes.
exit 1
}
git_apply_opt=
committer_date_is_author_date=
ignore_date=
+allow_rerere_autoupdate=
while test $# != 0
do
committer_date_is_author_date=t ;;
--ignore-date)
ignore_date=t ;;
+ --rerere-autoupdate|--no-rerere-autoupdate)
+ allow_rerere_autoupdate="$1" ;;
-q|--quiet)
GIT_QUIET=t ;;
--)
diff --git a/git-rebase.sh b/git-rebase.sh
index b121f4537ccb173d9f289734f1fe2e89b28d7562..398ea737160dbc60617e25d52bd253b6f6bf709f 100755 (executable)
--- a/git-rebase.sh
+++ b/git-rebase.sh
git_am_opt=
rebase_root=
force_rebase=
+allow_rerere_autoupdate=
continue_merge () {
test -n "$prev_head" || die "prev_head must be defined"
return
;;
1)
- git rerere
+ git rerere $allow_rerere_autoupdate
die "$RESOLVEMSG"
;;
2)
-f|--f|--fo|--for|--forc|force|--force-r|--force-re|--force-reb|--force-reba|--force-rebas|--force-rebase)
force_rebase=t
;;
+ --rerere-autoupdate|--no-rerere-autoupdate)
+ allow_rerere_autoupdate="$1"
+ ;;
-*)
usage
;;
diff --git a/parse-options.c b/parse-options.c
index f5594114ede8a50090c8b97987b52a660235fa56..10ec21fb89788e19e6d8d99b29da9801bb406dd3 100644 (file)
--- a/parse-options.c
+++ b/parse-options.c
@@ -633,3 +633,10 @@ int parse_opt_with_commit(const struct option *opt, const char *arg, int unset)
commit_list_insert(commit, opt->value);
return 0;
}
+
+int parse_opt_tertiary(const struct option *opt, const char *arg, int unset)
+{
+ int *target = opt->value;
+ *target = unset ? 2 : 1;
+ return 0;
+}
diff --git a/parse-options.h b/parse-options.h
index f295a2cf858f4dbebc62e956878544ffdb7fbe58..91c1500661be825fea7b751230e2ac3f8b95fab4 100644 (file)
--- a/parse-options.h
+++ b/parse-options.h
(h), PARSE_OPT_NOARG, NULL, (p) }
#define OPT_INTEGER(s, l, v, h) { OPTION_INTEGER, (s), (l), (v), "n", (h) }
#define OPT_STRING(s, l, v, a, h) { OPTION_STRING, (s), (l), (v), (a), (h) }
+#define OPT_UYN(s, l, v, h) { OPTION_CALLBACK, (s), (l), (v), NULL, \
+ (h), PARSE_OPT_NOARG, &parse_opt_tertiary }
#define OPT_DATE(s, l, v, h) \
{ OPTION_CALLBACK, (s), (l), (v), "time",(h), 0, \
parse_opt_approxidate_cb }
extern int parse_opt_approxidate_cb(const struct option *, const char *, int);
extern int parse_opt_verbosity_cb(const struct option *, const char *, int);
extern int parse_opt_with_commit(const struct option *, const char *, int);
+extern int parse_opt_tertiary(const struct option *, const char *, int);
#define OPT__VERBOSE(var) OPT_BOOLEAN('v', "verbose", (var), "be verbose")
#define OPT__QUIET(var) OPT_BOOLEAN('q', "quiet", (var), "be quiet")
diff --git a/rerere.c b/rerere.c
index 29f95f657d04300e375d007e9d01832b89311602..e0ac5bcaed7da9cfdff10afc9d1ebb8c27f7ba9f 100644 (file)
--- a/rerere.c
+++ b/rerere.c
return 1;
}
-int setup_rerere(struct string_list *merge_rr)
+int setup_rerere(struct string_list *merge_rr, int flags)
{
int fd;
if (!is_rerere_enabled())
return -1;
+ if (flags & (RERERE_AUTOUPDATE|RERERE_NOAUTOUPDATE))
+ rerere_autoupdate = !!(flags & RERERE_AUTOUPDATE);
merge_rr_path = git_pathdup("MERGE_RR");
fd = hold_lock_file_for_update(&write_lock, merge_rr_path,
LOCK_DIE_ON_ERROR);
return fd;
}
-int rerere(void)
+int rerere(int flags)
{
struct string_list merge_rr = { NULL, 0, 0, 1 };
int fd;
- fd = setup_rerere(&merge_rr);
+ fd = setup_rerere(&merge_rr, flags);
if (fd < 0)
return 0;
return do_plain_rerere(&merge_rr, fd);
diff --git a/rerere.h b/rerere.h
index 13313f3f2b2cc6a8d895305b7ac92c12c1753682..10a94a4ea10aa4c7a1ba4ea8397b82f1278afc9d 100644 (file)
--- a/rerere.h
+++ b/rerere.h
#include "string-list.h"
-extern int setup_rerere(struct string_list *);
-extern int rerere(void);
+#define RERERE_AUTOUPDATE 01
+#define RERERE_NOAUTOUPDATE 02
+
+extern int setup_rerere(struct string_list *, int);
+extern int rerere(int);
extern const char *rerere_path(const char *hex, const char *file);
extern int has_rerere_resolution(const char *hex);
+#define OPT_RERERE_AUTOUPDATE(v) OPT_UYN(0, "rerere-autoupdate", (v), \
+ "update the index with reused conflict resolution if possible")
+
#endif
diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh
index a6bc028a57115729d38e4b228cd259880d0bf6f8..bb402c3780356d1feab4e8b7c9b9624495d3e176 100755 (executable)
--- a/t/t4200-rerere.sh
+++ b/t/t4200-rerere.sh
git checkout version2 &&
test_must_fail git merge fifth &&
test 0 = $(git ls-files -u | wc -l)
+'
+test_expect_success 'merge --rerere-autoupdate' '
+ git config --unset rerere.autoupdate
+ git reset --hard &&
+ git checkout version2 &&
+ test_must_fail git merge --rerere-autoupdate fifth &&
+ test 0 = $(git ls-files -u | wc -l)
+'
+
+test_expect_success 'merge --no-rerere-autoupdate' '
+ git config rerere.autoupdate true
+ git reset --hard &&
+ git checkout version2 &&
+ test_must_fail git merge --no-rerere-autoupdate fifth &&
+ test 2 = $(git ls-files -u | wc -l)
'
test_done