summaryrefslogtreecommitdiff
path: root/builtin/notes.c
diff options
context:
space:
mode:
authorJacob Keller <jacob.keller@gmail.com>2015-08-17 21:33:33 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-08-17 22:38:54 (GMT)
commitd2d68d9975da4a15dfca0e6e59001948e5bf57f9 (patch)
treef72d519b0d953932d25a8095a504e814d2ffc871 /builtin/notes.c
parent11dd2b2e9a3303bd1e32fd2ee95ec5dff38d9d47 (diff)
downloadgit-d2d68d9975da4a15dfca0e6e59001948e5bf57f9.zip
git-d2d68d9975da4a15dfca0e6e59001948e5bf57f9.tar.gz
git-d2d68d9975da4a15dfca0e6e59001948e5bf57f9.tar.bz2
notes: add notes.mergeStrategy option to select default strategy
Teach git-notes about "notes.mergeStrategy" to select a general strategy for all notes merges. This enables a user to always get expected merge strategy such as "cat_sort_uniq" without having to pass the "-s" option manually. Signed-off-by: Jacob Keller <jacob.keller@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/notes.c')
-rw-r--r--builtin/notes.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/builtin/notes.c b/builtin/notes.c
index 29816f9..9026d56 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -737,6 +737,19 @@ static int merge_commit(struct notes_merge_options *o)
return ret;
}
+static int git_config_get_notes_strategy(const char *key,
+ enum notes_merge_strategy *strategy)
+{
+ const char *value;
+
+ if (git_config_get_string_const(key, &value))
+ return 1;
+ if (parse_notes_merge_strategy(value, strategy))
+ git_die_config(key, "unknown notes merge strategy %s", value);
+
+ return 0;
+}
+
static int merge(int argc, const char **argv, const char *prefix)
{
struct strbuf remote_ref = STRBUF_INIT, msg = STRBUF_INIT;
@@ -795,15 +808,17 @@ static int merge(int argc, const char **argv, const char *prefix)
expand_notes_ref(&remote_ref);
o.remote_ref = remote_ref.buf;
+ t = init_notes_check("merge");
+
if (strategy) {
if (parse_notes_merge_strategy(strategy, &o.strategy)) {
error("Unknown -s/--strategy: %s", strategy);
usage_with_options(git_notes_merge_usage, options);
}
+ } else {
+ git_config_get_notes_strategy("notes.mergeStrategy", &o.strategy);
}
- t = init_notes_check("merge");
-
strbuf_addf(&msg, "notes: Merged notes from %s into %s",
remote_ref.buf, default_notes_ref());
strbuf_add(&(o.commit_msg), msg.buf + 7, msg.len - 7); /* skip "notes: " */