mirror of
https://github.com/git/git
synced 2024-08-25 02:35:46 +00:00
sequencer: use reverse_commit_list() helper
Instead of creating a new allocation, reverse the original list in-place by calling the reverse_commit_list() helper. The original code discards the list "bases" after storing its reverse copy in a newly created list "reversed". If the code that followed from here used both "bases" and "reversed", the modification would not have worked, but since the original list "bases" gets discarded, we can simply reverse "bases" in-place with the reverse_commit_list() helper and reuse the same variable in the code that follows. builtin/merge.c has been left unmodified, since in its case, the original list is needed separately from its reverse copy by the code. Signed-off-by: Jayati Shrivastava <gaurijove@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
4c53a8c20f
commit
5327d8982a
10
sequencer.c
10
sequencer.c
|
@ -3753,7 +3753,7 @@ static int do_merge(struct repository *r,
|
||||||
int run_commit_flags = 0;
|
int run_commit_flags = 0;
|
||||||
struct strbuf ref_name = STRBUF_INIT;
|
struct strbuf ref_name = STRBUF_INIT;
|
||||||
struct commit *head_commit, *merge_commit, *i;
|
struct commit *head_commit, *merge_commit, *i;
|
||||||
struct commit_list *bases, *j, *reversed = NULL;
|
struct commit_list *bases, *j;
|
||||||
struct commit_list *to_merge = NULL, **tail = &to_merge;
|
struct commit_list *to_merge = NULL, **tail = &to_merge;
|
||||||
const char *strategy = !opts->xopts_nr &&
|
const char *strategy = !opts->xopts_nr &&
|
||||||
(!opts->strategy ||
|
(!opts->strategy ||
|
||||||
|
@ -3988,9 +3988,7 @@ static int do_merge(struct repository *r,
|
||||||
git_path_merge_head(r), 0);
|
git_path_merge_head(r), 0);
|
||||||
write_message("no-ff", 5, git_path_merge_mode(r), 0);
|
write_message("no-ff", 5, git_path_merge_mode(r), 0);
|
||||||
|
|
||||||
for (j = bases; j; j = j->next)
|
bases = reverse_commit_list(bases);
|
||||||
commit_list_insert(j->item, &reversed);
|
|
||||||
free_commit_list(bases);
|
|
||||||
|
|
||||||
repo_read_index(r);
|
repo_read_index(r);
|
||||||
init_merge_options(&o, r);
|
init_merge_options(&o, r);
|
||||||
|
@ -4006,10 +4004,10 @@ static int do_merge(struct repository *r,
|
||||||
* update the index and working copy immediately.
|
* update the index and working copy immediately.
|
||||||
*/
|
*/
|
||||||
ret = merge_ort_recursive(&o,
|
ret = merge_ort_recursive(&o,
|
||||||
head_commit, merge_commit, reversed,
|
head_commit, merge_commit, bases,
|
||||||
&i);
|
&i);
|
||||||
} else {
|
} else {
|
||||||
ret = merge_recursive(&o, head_commit, merge_commit, reversed,
|
ret = merge_recursive(&o, head_commit, merge_commit, bases,
|
||||||
&i);
|
&i);
|
||||||
}
|
}
|
||||||
if (ret <= 0)
|
if (ret <= 0)
|
||||||
|
|
Loading…
Reference in a new issue