git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v5 1/5] rebase -i: add --ignore-whitespace flag

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Jul 13, 2020, 10:02 UTC
Message-ID
<e4a440e5-fc10-f22c-bca2-b5cb077f49a6@gmail.com>
In-Reply-To
<20200629141453.GB20303@danh.dev>
Hi Danh
On 29/06/2020 15:14, Đoàn Trần Công Danh wrote:
Show 36 quoted lines
> Hi Phillip,
> 
> On 2020-06-26 15:43:00+0100, Phillip Wood <phillip.wood123@gmail.com> wrote:
>>>> +	if (options.type == REBASE_APPLY) {
>>>> +		if (ignore_whitespace)
>>>> +			argv_array_push (&options.git_am_opts,
>>>> +					 "--ignore-whitespace");
>>>> +	} else if (ignore_whitespace) {
>>>> +			string_list_append (&strategy_options,
>>>> +					    "ignore-space-change");
>>>> +	}
>>>> +
>>>
>>> Hm, I've just noticed this by now.
>>> Would it's better if we rewrite it as:
>>>
>>> 	if (ignore_whitespace) {
>>> 		if (options.type == REBASE_APPLY)
>>> 			argv_array_push(&options.git_am_opts,
>>> 					"--ignore-whitespace");
>>> 		else
>>> 			string_list_append(&strategy_options,
>>> 					   "ignore-space-change");
>>> 	}
>>>
>>> Ah, the incoming patches will add more conditions into the:
>>>
>>> 	if (options.type == REBASE_APPLY)
>>>
>>> I'm still not convinced, though.
>>
>> I wanted to keep the subsequent patches as simple as possible. Having to
>> rewrite the if statement in the next patch just clutters it up and makes the
>> real changes introduced by that patch less obvious
> 
> I think the code suggested by Junio may be cleaner ;)
Yes, I'll reroll with Junio's suggestion
Show 13 quoted lines
> I may write as:
> 
> 	if (ignore_whitespace) {
> 		if (options.type == REBASE_APPLY)
> 			argv_array_push(...)
> 		else
> 			string_list_append(...)
> 	}
> 
> 	if (other_condition)
> 		do_something_else(...)
> 
> I don't know if it's cleaner or not.

It leads to a lot of repetition of ' && options.type == REBASE_APPLY' as all the other conditions apart from --ignore-whitespace only need handling for the apply backend here.

Show 22 quoted lines
> I haven't tried applied it into real code.
> 
>>> Anyway, IIRC, --ignore-whitespace and --ignore-space-change has the
>>> same meaning, I think it's better to use the same option for both
>>> legs, no?
>>>
>>> I can understand the decision to use --ignore-whitespace as keeping
>>> the pass-through behavior of old code, but I think future maintenance
>>> is more important than that.
>>
>> I'm not sure how it affects future maintenance. The two different options
>> are for two different commands so I'm not sure it is worth the effort
> 
> I vaguely remember I was thinking about same option text in both leg
> would make the code easier for reasoning. And we can unify the
> recommendation for both backend. We will never strip
> --ignore-whitespace from git-apply, but it would be easier to always
> answer: "--ignore-space-change should be used to ignore space" when
> someone asks about it.
> 
> Typing this now makes me wonder if we should teach --ignore-space-change to
> git-rebase?

Possibly but not as part of this series which is about improving the merge backend rather than adding new options to rebase itself

Best Wishes
Phillip
Show 99 quoted lines
> 
> Thanks,
> 
> -- Danh
> 
>>
>> Best Wishes
>>
>> Phillip
>>
>>> I've tried changing ignore-whitespace to ignore-space-change and run
>>> make test
>>>
>>> It looks good to me (aka nothing failed _in my machine_),
>>> 4/5 and 5/5 is not applied, though.
>>>
>>>>   	if (strategy_options.nr) {
>>>>   		int i;
>>>> diff --git a/t/t3422-rebase-incompatible-options.sh b/t/t3422-rebase-incompatible-options.sh
>>>> index 50e7960702..55ca46786d 100755
>>>> --- a/t/t3422-rebase-incompatible-options.sh
>>>> +++ b/t/t3422-rebase-incompatible-options.sh
>>>> @@ -61,7 +61,6 @@ test_rebase_am_only () {
>>>>   }
>>>>   test_rebase_am_only --whitespace=fix
>>>> -test_rebase_am_only --ignore-whitespace
>>>>   test_rebase_am_only --committer-date-is-author-date
>>>>   test_rebase_am_only -C4
>>>> diff --git a/t/t3436-rebase-more-options.sh b/t/t3436-rebase-more-options.sh
>>>> new file mode 100755
>>>> index 0000000000..4f8a6e51c9
>>>> --- /dev/null
>>>> +++ b/t/t3436-rebase-more-options.sh
>>>> @@ -0,0 +1,60 @@
>>>> +#!/bin/sh
>>>> +#
>>>> +# Copyright (c) 2019 Rohit Ashiwal
>>>> +#
>>>> +
>>>> +test_description='tests to ensure compatibility between am and interactive backends'
>>>> +
>>>> +. ./test-lib.sh
>>>> +
>>>> +. "$TEST_DIRECTORY"/lib-rebase.sh
>>>> +
>>>> +# This is a special case in which both am and interactive backends
>>>> +# provide the same output. It was done intentionally because
>>>> +# both the backends fall short of optimal behaviour.
>>>> +test_expect_success 'setup' '
>>>> +	git checkout -b topic &&
>>>> +	test_write_lines "line 1" "	line 2" "line 3" >file &&
>>>> +	git add file &&
>>>> +	git commit -m "add file" &&
>>>> +
>>>> +	test_write_lines "line 1" "new line 2" "line 3" >file &&
>>>> +	git commit -am "update file" &&
>>>> +	git tag side &&
>>>> +
>>>> +	git checkout --orphan master &&
>>>> +	test_write_lines "line 1" "        line 2" "line 3" >file &&
>>>> +	git commit -am "add file" &&
>>>> +	git tag main
>>>> +'
>>>> +
>>>> +test_expect_success '--ignore-whitespace works with apply backend' '
>>>> +	test_must_fail git rebase --apply main side &&
>>>> +	git rebase --abort &&
>>>> +	git rebase --apply --ignore-whitespace main side &&
>>>> +	git diff --exit-code side
>>>> +'
>>>> +
>>>> +test_expect_success '--ignore-whitespace works with merge backend' '
>>>> +	test_must_fail git rebase --merge main side &&
>>>> +	git rebase --abort &&
>>>> +	git rebase --merge --ignore-whitespace main side &&
>>>> +	git diff --exit-code side
>>>> +'
>>>> +
>>>> +test_expect_success '--ignore-whitespace is remembered when continuing' '
>>>> +	(
>>>> +		set_fake_editor &&
>>>> +		FAKE_LINES="break 1" git rebase -i --ignore-whitespace \
>>>> +			main side &&
>>>> +		git rebase --continue
>>>> +	) &&
>>>> +	git diff --exit-code side
>>>> +'
>>>> +
>>>> +# This must be the last test in this file
>>>> +test_expect_success '$EDITOR and friends are unchanged' '
>>>> +	test_editor_unchanged
>>>> +'
>>>> +
>>>> +test_done
>>>> -- 
>>>> 2.27.0
>>>>
>>>
> 
Previous: Đoàn Trần Công DanhNext: Junio C Hamano
Message 79 of 130 in “fixup ra/rebase-i-more-options”
  1. 0/6 fixup ra/rebase-i-more-optionsPhillip Wood, Apr 7, 2020
  2. 2/6 t3433: remove loops from testsPhillip Wood, Apr 7, 2020
  3. Elijah NewrenApr 7, 2020
  4. 1/6 Revert "Revert "Merge branch 'ra/rebase-i-more-options'""Phillip Wood, Apr 7, 2020
  5. Elijah NewrenApr 7, 2020
  6. Phillip WoodApr 7, 2020
  7. Junio C HamanoApr 7, 2020
  8. Junio C HamanoApr 7, 2020
  9. Johannes SchindelinApr 12, 2020
  10. Phillip WoodApr 13, 2020
  11. Junio C HamanoApr 13, 2020
  12. 3/6 t3433: only compare commit datesPhillip Wood, Apr 7, 2020
  13. 4/6 rebase -i: fix --committer-date-is-author-datePhillip Wood, Apr 7, 2020
  14. Elijah NewrenApr 7, 2020
  15. Phillip WoodApr 7, 2020
  16. 5/6 Revert "sequencer: allow callers of read_author_script() to ignore fields"Phillip Wood, Apr 7, 2020
  17. Elijah NewrenApr 7, 2020
  18. 6/6 t3433: improve coveragePhillip Wood, Apr 7, 2020
  19. Elijah NewrenApr 7, 2020
  20. Phillip WoodApr 7, 2020
  21. Elijah NewrenApr 7, 2020
  22. Phillip WoodApr 7, 2020
  23. Junio C HamanoApr 7, 2020
  24. 0/5 cleanup ra/rebase-i-more-optionsPhillip Wood, Apr 29, 2020
  25. 1/5 rebase -i: add --ignore-whitespace flagPhillip Wood, Apr 29, 2020
  26. Elijah NewrenMay 13, 2020
  27. Phillip WoodMay 14, 2020
  28. 3/5 sequencer: rename amend_author to author_to_freePhillip Wood, Apr 29, 2020
  29. 2/5 rebase -i: support --committer-date-is-author-datePhillip Wood, Apr 29, 2020
  30. Alban GruinMay 10, 2020
  31. Elijah NewrenMay 13, 2020
  32. 5/5 rebase: add --reset-author-datePhillip Wood, Apr 29, 2020
  33. 4/5 rebase -i: support --ignore-datePhillip Wood, Apr 29, 2020
  34. Alban GruinMay 10, 2020
  35. Phillip WoodMay 12, 2020
  36. Junio C HamanoMay 13, 2020
  37. Elijah NewrenMay 13, 2020
  38. Junio C HamanoApr 29, 2020
  39. Elijah NewrenMay 13, 2020
  40. 0/5 cleanup ra/rebase-i-more-optionsPhillip Wood, May 21, 2020
  41. 1/5 rebase -i: add --ignore-whitespace flagPhillip Wood, May 21, 2020
  42. 2/5 rebase -i: support --committer-date-is-author-datePhillip Wood, May 21, 2020
  43. 5/5 rebase: add --reset-author-datePhillip Wood, May 21, 2020
  44. 4/5 rebase -i: support --ignore-datePhillip Wood, May 21, 2020
  45. Đoàn Trần Công DanhMay 23, 2020
  46. Phillip WoodMay 23, 2020
  47. Đoàn Trần Công DanhMay 23, 2020
  48. Phillip WoodMay 23, 2020
  49. Đoàn Trần Công DanhMay 23, 2020
  50. Phillip WoodMay 27, 2020
  51. Junio C HamanoMay 24, 2020
  52. 3/5 sequencer: rename amend_author to author_to_freePhillip Wood, May 21, 2020
  53. Elijah NewrenMay 22, 2020
  54. Phillip WoodMay 23, 2020
  55. Johannes SchindelinMay 23, 2020
  56. 0/5 cleanup ra/rebase-i-more-optionsPhillip Wood, May 27, 2020
  57. 1/5 rebase -i: add --ignore-whitespace flagPhillip Wood, May 27, 2020
  58. Johannes SchindelinMay 29, 2020
  59. Kerry, RichardJun 1, 2020
  60. Phillip WoodJun 1, 2020
  61. Johannes SchindelinJun 1, 2020
  62. 2/5 rebase -i: support --committer-date-is-author-datePhillip Wood, May 27, 2020
  63. Johannes SchindelinMay 29, 2020
  64. Phillip WoodJun 1, 2020
  65. 3/5 sequencer: rename amend_author to author_to_freePhillip Wood, May 27, 2020
  66. 4/5 rebase -i: support --ignore-datePhillip Wood, May 27, 2020
  67. 5/5 rebase: add --reset-author-datePhillip Wood, May 27, 2020
  68. 6/5 fixup! rebase: add --reset-author-datePhillip Wood, May 27, 2020
  69. Đoàn Trần Công DanhMay 28, 2020
  70. Johannes SchindelinMay 29, 2020
  71. Phillip WoodJun 1, 2020
  72. Junio C HamanoMay 27, 2020
  73. 0/5 cleanup ra/rebase-i-more-optionsPhillip Wood, Jun 26, 2020
  74. 1/5 rebase -i: add --ignore-whitespace flagPhillip Wood, Jun 26, 2020
  75. Đoàn Trần Công DanhJun 26, 2020
  76. Phillip WoodJun 26, 2020
  77. Junio C HamanoJun 26, 2020
  78. Đoàn Trần Công DanhJun 29, 2020
  79. Phillip WoodJul 13, 2020
  80. Junio C HamanoJun 26, 2020
  81. 2/5 rebase -i: support --committer-date-is-author-datePhillip Wood, Jun 26, 2020
  82. 3/5 sequencer: rename amend_author to author_to_freePhillip Wood, Jun 26, 2020
  83. 4/5 rebase -i: support --ignore-datePhillip Wood, Jun 26, 2020
  84. Đoàn Trần Công DanhJun 26, 2020
  85. Phillip WoodJun 26, 2020
  86. Junio C HamanoJun 26, 2020
  87. 5/5 rebase: add --reset-author-datePhillip Wood, Jun 26, 2020
  88. Junio C HamanoJun 26, 2020
  89. Phillip WoodJun 26, 2020
  90. Junio C HamanoJun 26, 2020
  91. 0/5 fixup ra/rebase-i-more-optionsPhillip Wood, Jul 13, 2020
  92. 2/5 rebase -i: support --committer-date-is-author-datePhillip Wood, Jul 13, 2020
  93. Đoàn Trần Công DanhJul 15, 2020
  94. Phillip WoodJul 16, 2020
  95. Đoàn Trần Công DanhJul 16, 2020
  96. Phillip WoodJul 16, 2020
  97. Phillip WoodJul 16, 2020
  98. Đoàn Trần Công DanhJul 17, 2020
  99. 1/5 rebase -i: add --ignore-whitespace flagPhillip Wood, Jul 13, 2020
  100. 3/5 sequencer: rename amend_author to author_to_freePhillip Wood, Jul 13, 2020
  101. 4/5 rebase -i: support --ignore-datePhillip Wood, Jul 13, 2020
  102. 5/5 rebase: add --reset-author-datePhillip Wood, Jul 13, 2020
  103. Junio C HamanoJul 13, 2020
  104. Phillip WoodJul 15, 2020
  105. 0/5 cleanup ra/rebase-i-more-optionsPhillip Wood, Jul 16, 2020
  106. 1/5 rebase -i: add --ignore-whitespace flagPhillip Wood, Jul 16, 2020
  107. 2/5 rebase -i: support --committer-date-is-author-datePhillip Wood, Jul 16, 2020
  108. Johannes SchindelinAug 13, 2020
  109. 3/5 sequencer: rename amend_author to author_to_freePhillip Wood, Jul 16, 2020
  110. 5/5 rebase: add --reset-author-datePhillip Wood, Jul 16, 2020
  111. 4/5 rebase -i: support --ignore-datePhillip Wood, Jul 16, 2020
  112. Johannes SchindelinAug 13, 2020
  113. Junio C HamanoJul 16, 2020
  114. Johannes SchindelinAug 13, 2020
  115. Junio C HamanoAug 13, 2020
  116. Phillip WoodAug 13, 2020
  117. 0/5 cleanup ra/rebase-i-more-optionsPhillip Wood, Aug 17, 2020
  118. 2/5 am: stop exporting GIT_COMMITTER_DATEPhillip Wood, Aug 17, 2020
  119. Junio C HamanoAug 17, 2020
  120. Phillip WoodAug 19, 2020
  121. Junio C HamanoAug 19, 2020
  122. Phillip WoodAug 20, 2020
  123. 4/5 rebase -i: support --ignore-datePhillip Wood, Aug 17, 2020
  124. Phillip WoodAug 19, 2020
  125. Junio C HamanoAug 19, 2020
  126. Phillip WoodAug 20, 2020
  127. 5/5 rebase: add --reset-author-datePhillip Wood, Aug 17, 2020
  128. 3/5 rebase -i: support --committer-date-is-author-datePhillip Wood, Aug 17, 2020
  129. Junio C HamanoAug 26, 2020
  130. 1/5 rebase -i: add --ignore-whitespace flagPhillip Wood, Aug 17, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.