Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhillip Wood <phillip.wood@dunelm.org.uk>2023-04-10 12:08:28 +0300
committerJunio C Hamano <gitster@pobox.com>2023-04-10 19:53:19 +0300
commitfb60b9f37f87241a886e183f0ec6261debb9c1c5 (patch)
tree8d99df1e8a7adf0045021ef5283bf9a4c4cc696d /sequencer.h
parent461434a013c2289fb59070e1a118d39441828847 (diff)
sequencer: use struct strvec to store merge strategy options
The sequencer stores the merge strategy options in an array of strings which allocated with ALLOC_GROW(). Using "struct strvec" avoids manually managing the memory of that array and simplifies the code. Aside from memory allocation the changes to the sequencer are largely mechanical, changing xopts_nr to xopts.nr and xopts[i] to xopts.v[i]. A new option parsing macro OPT_STRVEC() is also added to collect the strategy options. Hopefully this can be used to simplify the code in builtin/merge.c in the future. Note that there is a change of behavior to "git cherry-pick" and "git revert" as passing “--no-strategy-option” will now clear any previous strategy options whereas before this change it did nothing. Reviewed-by: Elijah Newren <newren@gmail.com> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sequencer.h')
-rw-r--r--sequencer.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/sequencer.h b/sequencer.h
index 33dbaf5b66..8a79d6b200 100644
--- a/sequencer.h
+++ b/sequencer.h
@@ -2,6 +2,7 @@
#define SEQUENCER_H
#include "strbuf.h"
+#include "strvec.h"
#include "wt-status.h"
struct commit;
@@ -60,8 +61,7 @@ struct replay_opts {
/* Merge strategy */
char *default_strategy; /* from config options */
char *strategy;
- char **xopts;
- size_t xopts_nr, xopts_alloc;
+ struct strvec xopts;
/* Reflog */
char *reflog_action;
@@ -80,7 +80,12 @@ struct replay_opts {
/* Private use */
const char *reflog_message;
};
-#define REPLAY_OPTS_INIT { .edit = -1, .action = -1, .current_fixups = STRBUF_INIT }
+#define REPLAY_OPTS_INIT { \
+ .edit = -1, \
+ .action = -1, \
+ .current_fixups = STRBUF_INIT, \
+ .xopts = STRVEC_INIT, \
+}
/*
* Note that ordering matters in this enum. Not only must it match the mapping