diff mbox series

[v5,5/5] rebase: add --reset-author-date

Message ID 20200626095528.117524-6-phillip.wood123@gmail.com (mailing list archive)
State New, archived
Headers show
Series cleanup ra/rebase-i-more-options | expand

Commit Message

Phillip Wood June 26, 2020, 9:55 a.m. UTC
From: Rohit Ashiwal <rohit.ashiwal265@gmail.com>

The previous commit introduced --ignore-date flag to rebase -i, but the
name is rather vague as it does not say whether the author date or the
committer date is ignored. Add an alias to convey the precise purpose.

Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Rohit Ashiwal <rohit.ashiwal265@gmail.com>
---
 Documentation/git-rebase.txt   |  1 +
 builtin/rebase.c               |  6 ++++--
 t/t3436-rebase-more-options.sh | 34 +++++++++++++++++++++-------------
 3 files changed, 26 insertions(+), 15 deletions(-)

Comments

Junio C Hamano June 26, 2020, 4:35 p.m. UTC | #1
Phillip Wood <phillip.wood123@gmail.com> writes:

> From: Rohit Ashiwal <rohit.ashiwal265@gmail.com>
>
> The previous commit introduced --ignore-date flag to rebase -i, but the
> name is rather vague as it does not say whether the author date or the
> committer date is ignored. Add an alias to convey the precise purpose.
>
> Helped-by: Junio C Hamano <gitster@pobox.com>

Hmph, did I?

> +		OPT_BOOL(0, "reset-author-date", &options.ignore_date,
> +			 N_("ignore author date and use current date")),
> +		OPT_HIDDEN_BOOL(0, "ignore-date", &options.ignore_date,
> +				N_("synonym of --reset-author-date")),

It is merely hidden but still supported.

> diff --git a/t/t3436-rebase-more-options.sh b/t/t3436-rebase-more-options.sh
> index 0ede2b8900..5b8963272a 100755
> --- a/t/t3436-rebase-more-options.sh
> +++ b/t/t3436-rebase-more-options.sh
> @@ -117,53 +117,61 @@ test_ctime_is_ignored () {
>  	! grep -v +0000 authortime
>  }
>  
> -test_expect_success '--ignore-date works with apply backend' '
> +test_expect_success '--reset-author-date works with apply backend' '
>  	git commit --amend --date="$GIT_AUTHOR_DATE" &&
> -	git rebase --apply --ignore-date HEAD^ &&
> +	git rebase --apply --reset-author-date HEAD^ &&
>  	test_ctime_is_ignored -1
>  '

Are there still some tests that check "--ignore-date"?  We probably
should have them, if we are not removing the support.

Thanks.  The entire series looked reasonable to me.
Phillip Wood June 26, 2020, 6:07 p.m. UTC | #2
Hi Junio

On 26/06/2020 17:35, Junio C Hamano wrote:
> Phillip Wood <phillip.wood123@gmail.com> writes:
> 
>> From: Rohit Ashiwal <rohit.ashiwal265@gmail.com>
>>
>> The previous commit introduced --ignore-date flag to rebase -i, but the
>> name is rather vague as it does not say whether the author date or the
>> committer date is ignored. Add an alias to convey the precise purpose.
>>
>> Helped-by: Junio C Hamano <gitster@pobox.com>
> 
> Hmph, did I?

Yes, you added a fixup d82dfa7f5b ("rebase -i: finishing touches to
--reset-author-date", 2019-11-21) which I squashed into this patch

> 
>> +		OPT_BOOL(0, "reset-author-date", &options.ignore_date,
>> +			 N_("ignore author date and use current date")),
>> +		OPT_HIDDEN_BOOL(0, "ignore-date", &options.ignore_date,
>> +				N_("synonym of --reset-author-date")),
> 
> It is merely hidden but still supported.
> 
>> diff --git a/t/t3436-rebase-more-options.sh b/t/t3436-rebase-more-options.sh
>> index 0ede2b8900..5b8963272a 100755
>> --- a/t/t3436-rebase-more-options.sh
>> +++ b/t/t3436-rebase-more-options.sh
>> @@ -117,53 +117,61 @@ test_ctime_is_ignored () {
>>  	! grep -v +0000 authortime
>>  }
>>  
>> -test_expect_success '--ignore-date works with apply backend' '
>> +test_expect_success '--reset-author-date works with apply backend' '
>>  	git commit --amend --date="$GIT_AUTHOR_DATE" &&
>> -	git rebase --apply --ignore-date HEAD^ &&
>> +	git rebase --apply --reset-author-date HEAD^ &&
>>  	test_ctime_is_ignored -1
>>  '
> 
> Are there still some tests that check "--ignore-date"?  We probably
> should have them, if we are not removing the support.

This patch converts the existing --ignore-date tests to use
--reset-author-date and adds a single new test at the end to check
--ignore-date

Best Wishes

Phillip

> 
> Thanks.  The entire series looked reasonable to me.
>
diff mbox series

Patch

diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index e2717e20e6..a5f82913fb 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -450,6 +450,7 @@  See also INCOMPATIBLE OPTIONS below.
 	date. This option implies --force-rebase.
 
 --ignore-date::
+--reset-author-date::
 	Instead of using the author date of the original commit, use
 	the current time as the	author date of the rebased commit.  This
 	option implies `--force-rebase`.
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 890dd4c588..3fe33beef4 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -1505,8 +1505,10 @@  int cmd_rebase(int argc, const char **argv, const char *prefix)
 		OPT_BOOL(0, "committer-date-is-author-date",
 			 &options.committer_date_is_author_date,
 			 N_("make committer date match author date")),
-		OPT_BOOL(0, "ignore-date", &options.ignore_date,
-			 "ignore author date and use current date"),
+		OPT_BOOL(0, "reset-author-date", &options.ignore_date,
+			 N_("ignore author date and use current date")),
+		OPT_HIDDEN_BOOL(0, "ignore-date", &options.ignore_date,
+				N_("synonym of --reset-author-date")),
 		OPT_PASSTHRU_ARGV('C', NULL, &options.git_am_opts, N_("n"),
 				  N_("passed to 'git apply'"), 0),
 		OPT_BOOL(0, "ignore-whitespace", &ignore_whitespace,
diff --git a/t/t3436-rebase-more-options.sh b/t/t3436-rebase-more-options.sh
index 0ede2b8900..5b8963272a 100755
--- a/t/t3436-rebase-more-options.sh
+++ b/t/t3436-rebase-more-options.sh
@@ -117,53 +117,61 @@  test_ctime_is_ignored () {
 	! grep -v +0000 authortime
 }
 
-test_expect_success '--ignore-date works with apply backend' '
+test_expect_success '--reset-author-date works with apply backend' '
 	git commit --amend --date="$GIT_AUTHOR_DATE" &&
-	git rebase --apply --ignore-date HEAD^ &&
+	git rebase --apply --reset-author-date HEAD^ &&
 	test_ctime_is_ignored -1
 '
 
-test_expect_success '--ignore-date works with merge backend' '
+test_expect_success '--reset-author-date works with merge backend' '
 	git commit --amend --date="$GIT_AUTHOR_DATE" &&
-	git rebase --ignore-date -m HEAD^ &&
+	git rebase --reset-author-date -m HEAD^ &&
 	test_ctime_is_ignored -1
 '
 
-test_expect_success '--ignore-date works after conflict resolution' '
-	test_must_fail git rebase --ignore-date -m \
+test_expect_success '--reset-author-date works after conflict resolution' '
+	test_must_fail git rebase --reset-author-date -m \
 		--onto commit2^^ commit2^ commit2 &&
 	echo resolved >foo &&
 	git add foo &&
 	git rebase --continue &&
 	test_ctime_is_ignored -1
 '
 
-test_expect_success '--ignore-date works with rebase -r' '
+test_expect_success '--reset-author-date works with rebase -r' '
 	git checkout side &&
 	git merge --no-ff commit3 &&
-	git rebase -r --root --ignore-date &&
+	git rebase -r --root --reset-author-date &&
 	test_ctime_is_ignored
 '
 
-test_expect_success '--ignore-date with --committer-date-is-author-date works' '
+test_expect_success '--reset-author-date with --committer-date-is-author-date works' '
 	test_must_fail git rebase -m --committer-date-is-author-date \
-		--ignore-date --onto commit2^^ commit2^ commit3 &&
+		--reset-author-date --onto commit2^^ commit2^ commit3 &&
 	git checkout --theirs foo &&
 	git add foo &&
 	git rebase --continue &&
 	test_ctime_is_atime -2 &&
 	test_ctime_is_ignored -2
 '
 
-test_expect_success '--ignore-date --committer-date-is-author-date works when forking merge' '
+test_expect_success '--reset-author-date --committer-date-is-author-date works when forking merge' '
 	GIT_SEQUENCE_EDITOR="echo \"merge -C $(git rev-parse HEAD) commit3\">" \
 		PATH="./test-bin:$PATH" git rebase -i --strategy=test \
-				--ignore-date --committer-date-is-author-date \
-				side side &&
+				--reset-author-date \
+				--committer-date-is-author-date side side &&
 	test_ctime_is_atime -1 &&
 	test_ctime_is_ignored -1
  '
 
+test_expect_success '--ignore-date is an alias for --reset-author-date' '
+	git commit --amend --date="$GIT_AUTHOR_DATE" &&
+	git rebase --apply --ignore-date HEAD^ &&
+	git commit --allow-empty -m empty --date="$GIT_AUTHOR_DATE" &&
+	git rebase -m --ignore-date HEAD^ &&
+	test_ctime_is_ignored -2
+'
+
 # This must be the last test in this file
 test_expect_success '$EDITOR and friends are unchanged' '
 	test_editor_unchanged