@@ -148,6 +148,7 @@ static GIT_PATH_FUNC(rebase_path_refs_to_delete, "rebase-merge/refs-to-delete")
148
148
*/
149
149
static GIT_PATH_FUNC (rebase_path_gpg_sign_opt , "rebase-merge/gpg_sign_opt" )
150
150
static GIT_PATH_FUNC (rebase_path_cdate_is_adate , "rebase-merge/cdate_is_adate" )
151
+ static GIT_PATH_FUNC (rebase_path_ignore_date , "rebase-merge/ignore_date" )
151
152
static GIT_PATH_FUNC (rebase_path_orig_head , "rebase-merge/orig-head" )
152
153
static GIT_PATH_FUNC (rebase_path_verbose , "rebase-merge/verbose" )
153
154
static GIT_PATH_FUNC (rebase_path_quiet , "rebase-merge/quiet" )
@@ -891,6 +892,36 @@ static char *read_author_date_or_null(void)
891
892
return date ;
892
893
}
893
894
895
+ /* Construct a free()able author string with current time as the author date */
896
+ static char * ignore_author_date (const char * author )
897
+ {
898
+ int len = strlen (author );
899
+ struct ident_split ident ;
900
+ struct strbuf new_author = STRBUF_INIT ;
901
+
902
+ if (split_ident_line (& ident , author , len ) < 0 ) {
903
+ error (_ ("malformed ident line" ));
904
+ return NULL ;
905
+ }
906
+ len = ident .mail_end - ident .name_begin + 1 ;
907
+
908
+ strbuf_addf (& new_author , "%.*s " , len , ident .name_begin );
909
+ datestamp (& new_author );
910
+ return strbuf_detach (& new_author , NULL );
911
+ }
912
+
913
+ static void push_dates (struct child_process * child , int change_committer_date )
914
+ {
915
+ time_t now = time (NULL );
916
+ struct strbuf date = STRBUF_INIT ;
917
+
918
+ strbuf_addf (& date , "@%" PRIuMAX , (uintmax_t )now );
919
+ argv_array_pushf (& child -> env_array , "GIT_AUTHOR_DATE=%s" , date .buf );
920
+ if (change_committer_date )
921
+ argv_array_pushf (& child -> env_array , "GIT_COMMITTER_DATE=%s" , date .buf );
922
+ strbuf_release (& date );
923
+ }
924
+
894
925
static const char staged_changes_advice [] =
895
926
N_ ("you have staged changes in your working tree\n"
896
927
"If these changes are meant to be squashed into the previous commit, run:\n"
@@ -959,7 +990,8 @@ static int run_git_commit(struct repository *r,
959
990
return -1 ;
960
991
961
992
strbuf_addf (& datebuf , "@%s" , date );
962
- res = setenv ("GIT_COMMITTER_DATE" , datebuf .buf , 1 );
993
+ res = setenv ("GIT_COMMITTER_DATE" ,
994
+ opts -> ignore_date ? "" : datebuf .buf , 1 );
963
995
964
996
strbuf_release (& datebuf );
965
997
free (date );
@@ -983,6 +1015,8 @@ static int run_git_commit(struct repository *r,
983
1015
argv_array_push (& cmd .args , "--amend" );
984
1016
if (opts -> gpg_sign )
985
1017
argv_array_pushf (& cmd .args , "-S%s" , opts -> gpg_sign );
1018
+ if (opts -> ignore_date )
1019
+ push_dates (& cmd , opts -> committer_date_is_author_date );
986
1020
if (defmsg )
987
1021
argv_array_pushl (& cmd .args , "-F" , defmsg , NULL );
988
1022
else if (!(flags & EDIT_MSG ))
@@ -1405,7 +1439,8 @@ static int try_to_commit(struct repository *r,
1405
1439
strbuf_addf (& date , "@%.*s %.*s" ,
1406
1440
(int )(ident .date_end - ident .date_begin ), ident .date_begin ,
1407
1441
(int )(ident .tz_end - ident .tz_begin ), ident .tz_begin );
1408
- res = setenv ("GIT_COMMITTER_DATE" , date .buf , 1 );
1442
+ res = setenv ("GIT_COMMITTER_DATE" ,
1443
+ opts -> ignore_date ? "" : date .buf , 1 );
1409
1444
strbuf_release (& date );
1410
1445
1411
1446
if (res )
@@ -1455,6 +1490,15 @@ static int try_to_commit(struct repository *r,
1455
1490
1456
1491
reset_ident_date ();
1457
1492
1493
+ if (opts -> ignore_date ) {
1494
+ author = ignore_author_date (author );
1495
+ if (!author ) {
1496
+ res = -1 ;
1497
+ goto out ;
1498
+ }
1499
+ free (author_to_free );
1500
+ author_to_free = (char * )author ;
1501
+ }
1458
1502
if (commit_tree_extended (msg -> buf , msg -> len , & tree , parents ,
1459
1503
oid , author , opts -> gpg_sign , extra )) {
1460
1504
res = error (_ ("failed to write commit object" ));
@@ -2538,6 +2582,11 @@ static int read_populate_opts(struct replay_opts *opts)
2538
2582
opts -> committer_date_is_author_date = 1 ;
2539
2583
}
2540
2584
2585
+ if (file_exists (rebase_path_ignore_date ())) {
2586
+ opts -> allow_ff = 0 ;
2587
+ opts -> ignore_date = 1 ;
2588
+ }
2589
+
2541
2590
if (file_exists (rebase_path_reschedule_failed_exec ()))
2542
2591
opts -> reschedule_failed_exec = 1 ;
2543
2592
@@ -2622,6 +2671,8 @@ int write_basic_state(struct replay_opts *opts, const char *head_name,
2622
2671
write_file (rebase_path_signoff (), "--signoff\n" );
2623
2672
if (opts -> committer_date_is_author_date )
2624
2673
write_file (rebase_path_cdate_is_adate (), "%s" , "" );
2674
+ if (opts -> ignore_date )
2675
+ write_file (rebase_path_ignore_date (), "%s" , "" );
2625
2676
if (opts -> reschedule_failed_exec )
2626
2677
write_file (rebase_path_reschedule_failed_exec (), "%s" , "" );
2627
2678
@@ -3439,6 +3490,8 @@ static int do_merge(struct repository *r,
3439
3490
argv_array_push (& cmd .args , git_path_merge_msg (r ));
3440
3491
if (opts -> gpg_sign )
3441
3492
argv_array_push (& cmd .args , opts -> gpg_sign );
3493
+ if (opts -> ignore_date )
3494
+ push_dates (& cmd , opts -> committer_date_is_author_date );
3442
3495
3443
3496
/* Add the tips to be merged */
3444
3497
for (j = to_merge ; j ; j = j -> next )
@@ -3711,7 +3764,8 @@ static int pick_commits(struct repository *r,
3711
3764
if (opts -> allow_ff )
3712
3765
assert (!(opts -> signoff || opts -> no_commit ||
3713
3766
opts -> record_origin || opts -> edit ||
3714
- opts -> committer_date_is_author_date ));
3767
+ opts -> committer_date_is_author_date ||
3768
+ opts -> ignore_date ));
3715
3769
if (read_and_refresh_cache (r , opts ))
3716
3770
return -1 ;
3717
3771
0 commit comments