Re: [PATCH] commit: simplify building parents list
From: Junio C Hamano <hidden>
Date: 2016-10-30 23:03:31
René Scharfe [off-list ref] writes:
quoted hunk
Push pptr down into the FROM_MERGE branch of the if/else statement, where it's actually used, and call commit_list_append() for appending elements instead of playing tricks with commit_list_insert(). Call copy_commit_list() in the amend branch instead of open-coding it. Don't bother setting pptr in the final branch as it's not used thereafter. Signed-off-by: Rene Scharfe <redacted> --- ...@@ -1729,7 +1727,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix) reflog_msg = (whence == FROM_CHERRY_PICK) ? "commit (cherry-pick)" : "commit"; - pptr = &commit_list_insert(current_head, pptr)->next; + commit_list_insert(current_head, &parents); }
I needed to read the full preimage to determine why this hunk is equivalent to the original. Which is a good demonstration that what motivated this patch is a valid issue to tackle---initializing the pptr variable to point at &parents too early and have the long if/elseif/... cascade work with it made the code unnecessarily harder to understand and this update untangles that. Thanks.