@@ -1642,7 +1642,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
1642
1642
const char * index_file , * reflog_msg ;
1643
1643
char * nl ;
1644
1644
unsigned char sha1 [20 ];
1645
- struct commit_list * parents = NULL , * * pptr = & parents ;
1645
+ struct commit_list * parents = NULL ;
1646
1646
struct stat statbuf ;
1647
1647
struct commit * current_head = NULL ;
1648
1648
struct commit_extra_header * extra = NULL ;
@@ -1688,20 +1688,18 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
1688
1688
if (!reflog_msg )
1689
1689
reflog_msg = "commit (initial)" ;
1690
1690
} else if (amend ) {
1691
- struct commit_list * c ;
1692
-
1693
1691
if (!reflog_msg )
1694
1692
reflog_msg = "commit (amend)" ;
1695
- for (c = current_head -> parents ; c ; c = c -> next )
1696
- pptr = & commit_list_insert (c -> item , pptr )-> next ;
1693
+ parents = copy_commit_list (current_head -> parents );
1697
1694
} else if (whence == FROM_MERGE ) {
1698
1695
struct strbuf m = STRBUF_INIT ;
1699
1696
FILE * fp ;
1700
1697
int allow_fast_forward = 1 ;
1698
+ struct commit_list * * pptr = & parents ;
1701
1699
1702
1700
if (!reflog_msg )
1703
1701
reflog_msg = "commit (merge)" ;
1704
- pptr = & commit_list_insert (current_head , pptr )-> next ;
1702
+ pptr = commit_list_append (current_head , pptr );
1705
1703
fp = fopen (git_path_merge_head (), "r" );
1706
1704
if (fp == NULL )
1707
1705
die_errno (_ ("could not open '%s' for reading" ),
@@ -1712,7 +1710,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
1712
1710
parent = get_merge_parent (m .buf );
1713
1711
if (!parent )
1714
1712
die (_ ("Corrupt MERGE_HEAD file (%s)" ), m .buf );
1715
- pptr = & commit_list_insert (parent , pptr )-> next ;
1713
+ pptr = commit_list_append (parent , pptr );
1716
1714
}
1717
1715
fclose (fp );
1718
1716
strbuf_release (& m );
@@ -1729,7 +1727,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
1729
1727
reflog_msg = (whence == FROM_CHERRY_PICK )
1730
1728
? "commit (cherry-pick)"
1731
1729
: "commit" ;
1732
- pptr = & commit_list_insert (current_head , pptr ) -> next ;
1730
+ commit_list_insert (current_head , & parents ) ;
1733
1731
}
1734
1732
1735
1733
/* Finally, get the commit message */
0 commit comments