@@ -869,34 +869,6 @@ static char *get_author(const char *message)
869
869
return NULL ;
870
870
}
871
871
872
- /* Read author-script and return an ident line (author <email> timestamp) */
873
- static const char * read_author_ident (struct strbuf * buf )
874
- {
875
- struct strbuf out = STRBUF_INIT ;
876
- char * name , * email , * date ;
877
-
878
- if (read_author_script (rebase_path_author_script (),
879
- & name , & email , & date , 0 ))
880
- return NULL ;
881
-
882
- /* validate date since fmt_ident() will die() on bad value */
883
- if (parse_date (date , & out )){
884
- warning (_ ("invalid date format '%s' in '%s'" ),
885
- date , rebase_path_author_script ());
886
- strbuf_release (& out );
887
- return NULL ;
888
- }
889
-
890
- strbuf_reset (& out );
891
- strbuf_addstr (& out , fmt_ident (name , email , WANT_AUTHOR_IDENT , date , 0 ));
892
- strbuf_swap (buf , & out );
893
- strbuf_release (& out );
894
- free (name );
895
- free (email );
896
- free (date );
897
- return buf -> buf ;
898
- }
899
-
900
872
static const char staged_changes_advice [] =
901
873
N_ ("you have staged changes in your working tree\n"
902
874
"If these changes are meant to be squashed into the previous commit, run:\n"
@@ -954,45 +926,6 @@ static int run_git_commit(struct repository *r,
954
926
{
955
927
struct child_process cmd = CHILD_PROCESS_INIT ;
956
928
957
- if ((flags & CREATE_ROOT_COMMIT ) && !(flags & AMEND_MSG )) {
958
- struct strbuf msg = STRBUF_INIT , script = STRBUF_INIT ;
959
- const char * author = NULL ;
960
- struct object_id root_commit , * cache_tree_oid ;
961
- int res = 0 ;
962
-
963
- if (is_rebase_i (opts )) {
964
- author = read_author_ident (& script );
965
- if (!author ) {
966
- strbuf_release (& script );
967
- return -1 ;
968
- }
969
- }
970
-
971
- if (!defmsg )
972
- BUG ("root commit without message" );
973
-
974
- if (!(cache_tree_oid = get_cache_tree_oid (r -> index )))
975
- res = -1 ;
976
-
977
- if (!res )
978
- res = strbuf_read_file (& msg , defmsg , 0 );
979
-
980
- if (res <= 0 )
981
- res = error_errno (_ ("could not read '%s'" ), defmsg );
982
- else
983
- res = commit_tree (msg .buf , msg .len , cache_tree_oid ,
984
- NULL , & root_commit , author ,
985
- opts -> gpg_sign );
986
-
987
- strbuf_release (& msg );
988
- strbuf_release (& script );
989
- if (!res )
990
- res = update_ref (NULL , "HEAD" , & root_commit , NULL , 0 ,
991
- UPDATE_REFS_MSG_ON_ERR );
992
-
993
- return res < 0 ? error (_ ("writing root commit" )) : 0 ;
994
- }
995
-
996
929
cmd .git_cmd = 1 ;
997
930
998
931
if (is_rebase_i (opts ) && read_env_script (& cmd .env_array )) {
@@ -1376,7 +1309,7 @@ static int try_to_commit(struct repository *r,
1376
1309
struct object_id * oid )
1377
1310
{
1378
1311
struct object_id tree ;
1379
- struct commit * current_head ;
1312
+ struct commit * current_head = NULL ;
1380
1313
struct commit_list * parents = NULL ;
1381
1314
struct commit_extra_header * extra = NULL ;
1382
1315
struct strbuf err = STRBUF_INIT ;
@@ -1411,7 +1344,8 @@ static int try_to_commit(struct repository *r,
1411
1344
}
1412
1345
parents = copy_commit_list (current_head -> parents );
1413
1346
extra = read_commit_extra_headers (current_head , exclude_gpgsig );
1414
- } else if (current_head ) {
1347
+ } else if (current_head &&
1348
+ (!(flags & CREATE_ROOT_COMMIT ) || (flags & AMEND_MSG ))) {
1415
1349
commit_list_insert (current_head , & parents );
1416
1350
}
1417
1351
@@ -1488,8 +1422,7 @@ static int do_commit(struct repository *r,
1488
1422
{
1489
1423
int res = 1 ;
1490
1424
1491
- if (!(flags & EDIT_MSG ) && !(flags & VERIFY_MSG ) &&
1492
- !(flags & CREATE_ROOT_COMMIT )) {
1425
+ if (!(flags & EDIT_MSG ) && !(flags & VERIFY_MSG )) {
1493
1426
struct object_id oid ;
1494
1427
struct strbuf sb = STRBUF_INIT ;
1495
1428
0 commit comments