mirror of
https://github.com/git/git
synced 2024-08-28 12:09:19 +00:00
Merge branch 'rs/commit-pptr-simplify'
Code simplification. * rs/commit-pptr-simplify: commit: simplify building parents list
This commit is contained in:
commit
2f445c17e5
|
@ -1642,7 +1642,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
|
||||||
const char *index_file, *reflog_msg;
|
const char *index_file, *reflog_msg;
|
||||||
char *nl;
|
char *nl;
|
||||||
unsigned char sha1[20];
|
unsigned char sha1[20];
|
||||||
struct commit_list *parents = NULL, **pptr = &parents;
|
struct commit_list *parents = NULL;
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
struct commit *current_head = NULL;
|
struct commit *current_head = NULL;
|
||||||
struct commit_extra_header *extra = NULL;
|
struct commit_extra_header *extra = NULL;
|
||||||
|
@ -1688,20 +1688,18 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
|
||||||
if (!reflog_msg)
|
if (!reflog_msg)
|
||||||
reflog_msg = "commit (initial)";
|
reflog_msg = "commit (initial)";
|
||||||
} else if (amend) {
|
} else if (amend) {
|
||||||
struct commit_list *c;
|
|
||||||
|
|
||||||
if (!reflog_msg)
|
if (!reflog_msg)
|
||||||
reflog_msg = "commit (amend)";
|
reflog_msg = "commit (amend)";
|
||||||
for (c = current_head->parents; c; c = c->next)
|
parents = copy_commit_list(current_head->parents);
|
||||||
pptr = &commit_list_insert(c->item, pptr)->next;
|
|
||||||
} else if (whence == FROM_MERGE) {
|
} else if (whence == FROM_MERGE) {
|
||||||
struct strbuf m = STRBUF_INIT;
|
struct strbuf m = STRBUF_INIT;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
int allow_fast_forward = 1;
|
int allow_fast_forward = 1;
|
||||||
|
struct commit_list **pptr = &parents;
|
||||||
|
|
||||||
if (!reflog_msg)
|
if (!reflog_msg)
|
||||||
reflog_msg = "commit (merge)";
|
reflog_msg = "commit (merge)";
|
||||||
pptr = &commit_list_insert(current_head, pptr)->next;
|
pptr = commit_list_append(current_head, pptr);
|
||||||
fp = fopen(git_path_merge_head(), "r");
|
fp = fopen(git_path_merge_head(), "r");
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
die_errno(_("could not open '%s' for reading"),
|
die_errno(_("could not open '%s' for reading"),
|
||||||
|
@ -1712,7 +1710,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
|
||||||
parent = get_merge_parent(m.buf);
|
parent = get_merge_parent(m.buf);
|
||||||
if (!parent)
|
if (!parent)
|
||||||
die(_("Corrupt MERGE_HEAD file (%s)"), m.buf);
|
die(_("Corrupt MERGE_HEAD file (%s)"), m.buf);
|
||||||
pptr = &commit_list_insert(parent, pptr)->next;
|
pptr = commit_list_append(parent, pptr);
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
strbuf_release(&m);
|
strbuf_release(&m);
|
||||||
|
@ -1729,7 +1727,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
|
||||||
reflog_msg = (whence == FROM_CHERRY_PICK)
|
reflog_msg = (whence == FROM_CHERRY_PICK)
|
||||||
? "commit (cherry-pick)"
|
? "commit (cherry-pick)"
|
||||||
: "commit";
|
: "commit";
|
||||||
pptr = &commit_list_insert(current_head, pptr)->next;
|
commit_list_insert(current_head, &parents);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Finally, get the commit message */
|
/* Finally, get the commit message */
|
||||||
|
|
Loading…
Reference in a new issue