@@ -1647,7 +1647,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
1647
1647
const char * index_file , * reflog_msg ;
1648
1648
char * nl ;
1649
1649
unsigned char sha1 [20 ];
1650
- struct commit_list * parents = NULL , * * pptr = & parents ;
1650
+ struct commit_list * parents = NULL ;
1651
1651
struct stat statbuf ;
1652
1652
struct commit * current_head = NULL ;
1653
1653
struct commit_extra_header * extra = NULL ;
@@ -1693,20 +1693,18 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
1693
1693
if (!reflog_msg )
1694
1694
reflog_msg = "commit (initial)" ;
1695
1695
} else if (amend ) {
1696
- struct commit_list * c ;
1697
-
1698
1696
if (!reflog_msg )
1699
1697
reflog_msg = "commit (amend)" ;
1700
- for (c = current_head -> parents ; c ; c = c -> next )
1701
- pptr = & commit_list_insert (c -> item , pptr )-> next ;
1698
+ parents = copy_commit_list (current_head -> parents );
1702
1699
} else if (whence == FROM_MERGE ) {
1703
1700
struct strbuf m = STRBUF_INIT ;
1704
1701
FILE * fp ;
1705
1702
int allow_fast_forward = 1 ;
1703
+ struct commit_list * * pptr = & parents ;
1706
1704
1707
1705
if (!reflog_msg )
1708
1706
reflog_msg = "commit (merge)" ;
1709
- pptr = & commit_list_insert (current_head , pptr )-> next ;
1707
+ pptr = commit_list_append (current_head , pptr );
1710
1708
fp = fopen (git_path_merge_head (), "r" );
1711
1709
if (fp == NULL )
1712
1710
die_errno (_ ("could not open '%s' for reading" ),
@@ -1717,7 +1715,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
1717
1715
parent = get_merge_parent (m .buf );
1718
1716
if (!parent )
1719
1717
die (_ ("Corrupt MERGE_HEAD file (%s)" ), m .buf );
1720
- pptr = & commit_list_insert (parent , pptr )-> next ;
1718
+ pptr = commit_list_append (parent , pptr );
1721
1719
}
1722
1720
fclose (fp );
1723
1721
strbuf_release (& m );
@@ -1734,7 +1732,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
1734
1732
reflog_msg = (whence == FROM_CHERRY_PICK )
1735
1733
? "commit (cherry-pick)"
1736
1734
: "commit" ;
1737
- pptr = & commit_list_insert (current_head , pptr ) -> next ;
1735
+ commit_list_insert (current_head , & parents ) ;
1738
1736
}
1739
1737
1740
1738
/* Finally, get the commit message */
0 commit comments