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

Re: [PATCH v2 4/4] mergetool: fix running in subdir when rerere enabled

From
RHRichard Hansen <hansenr@google.com>
Date
Jan 7, 2017, 02:16 UTC
Message-ID
<7a561587-3afc-58f9-a490-6bcaa7287576@google.com>
In-Reply-To
<199807ae-844c-57cd-28cf-2c10b3aee7a9@kdbg.org>
On 2017-01-06 04:42, Johannes Sixt wrote:
Show 33 quoted lines
> Am 06.01.2017 um 02:09 schrieb Richard Hansen:
>> If rerere is enabled and no pathnames are given, run cd_to_toplevel
>> before running 'git diff --name-only' so that 'git diff --name-only'
>> sees the pathnames emitted by 'git rerere remaining'.
>>
>> Also run cd_to_toplevel before running 'git rerere remaining' in case
>> 'git rerere remaining' is ever changed to print pathnames relative to
>> the current directory rather than to $GIT_WORK_TREE.
>>
>> This fixes a regression introduced in
>> 57937f70a09c12ef484c290865dac4066d207c9c (v2.11.0).
>>
>> Signed-off-by: Richard Hansen <hansenr@google.com>
>> ---
>>  git-mergetool.sh     | 1 +
>>  t/t7610-mergetool.sh | 2 +-
>>  2 files changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/git-mergetool.sh b/git-mergetool.sh
>> index e52b4e4f2..67ea0d6db 100755
>> --- a/git-mergetool.sh
>> +++ b/git-mergetool.sh
>> @@ -456,6 +456,7 @@ main () {
>>
>>      if test $# -eq 0 && test -e "$GIT_DIR/MERGE_RR"
>>      then
>> +        cd_to_toplevel
>>          set -- $(git rerere remaining)
>>          if test $# -eq 0
>>          then
>
> This cannot be a complete solution. Why do we have another
> cd_to_toplevel later, after `git diff --name-only -- "$@"`?

The arguments passed to 'git diff' (including the -O argument) are all interpreted as relative to the current working directory, yet 'git diff --name-only' outputs pathnames that are relative to the top-level directory. Thus:

   * cd_to_toplevel MUST NOT be run before that 'git diff' command
     unless all pathnames relative to $PWD are converted to absolute (or
     relative to the top-level directory), and
   * cd_to_toplevel MUST be run after 'git diff' so that $files is
     interpreted correctly.

And now I realize that my change breaks -O<foo> if <foo> is relative to $PWD. Grr. Too bad we don't have tests for running mergetool -O<relative-path> from a subdirectory.

Show 5 quoted lines
>
> Maybe it is necessary to revert back to the flow control that we had
> before 57937f70a09c ("mergetool: honor diff.orderFile", 2016-10-07)? It
> did not have `test $# -eq 0` and `test -e "$GIT_DIR/MERGE_RR"` in a
> single condition.

Reverting to the previous control flow won't work unless the -O pathname is converted to absolute (or relative to the top-level directory). But I'll have to do that anyway. Blech.

Do we already have a helper shell function somewhere that converts a pathname to absolute? Thanks to symlinks it's trickier than one might expect.

Thanks, Richard

>
> -- Hannes
Previous: Johannes SixtNext: Richard Hansen
Message 14 of 76 in “fix mergetool+rerere+subdir regression”
  1. 0/4 fix mergetool+rerere+subdir regressionRichard Hansen, Jan 4, 2017
  2. 2/4 t7610: make tests more independent and debuggableRichard Hansen, Jan 4, 2017
  3. Stefan BellerJan 4, 2017
  4. Richard HansenJan 5, 2017
  5. Richard HansenJan 5, 2017
  6. Simon RuderichJan 5, 2017
  7. Richard HansenJan 5, 2017
  8. 3/4 t7610: add test case for rerere+mergetool+subdir bugRichard Hansen, Jan 4, 2017
  9. 1/4 t7610: update branch names to match test numberRichard Hansen, Jan 4, 2017
  10. 4/4 mergetool: fix running in subdir when rerere enabledRichard Hansen, Jan 4, 2017
  11. 0/4 fix mergetool+rerere+subdir regressionRichard Hansen, Jan 6, 2017
  12. 4/4 mergetool: fix running in subdir when rerere enabledRichard Hansen, Jan 6, 2017
  13. Johannes SixtJan 6, 2017
  14. Richard HansenJan 7, 2017
  15. 3/4 t7610: add test case for rerere+mergetool+subdir bugRichard Hansen, Jan 6, 2017
  16. 1/4 t7610: update branch names to match test numberRichard Hansen, Jan 6, 2017
  17. 2/4 t7610: make tests more independent and debuggableRichard Hansen, Jan 6, 2017
  18. Stefan BellerJan 6, 2017
  19. Richard HansenJan 7, 2017
  20. 00/13 fix mergetool+rerere+subdir regressionRichard Hansen, Jan 9, 2017
  21. 01/13 .mailmap: Use my personal email address as my canonicalRichard Hansen, Jan 9, 2017
  22. 05/13 t7610: don't rely on state from previous testRichard Hansen, Jan 9, 2017
  23. 06/13 t7610: run 'git reset --hard' after each test to clean upRichard Hansen, Jan 9, 2017
  24. 03/13 t7610: Move setup code to the 'setup' test case.Richard Hansen, Jan 9, 2017
  25. 04/13 t7610: use test_when_finished for cleanup tasksRichard Hansen, Jan 9, 2017
  26. 07/13 t7610: delete some now-unnecessary 'git reset --hard' linesRichard Hansen, Jan 9, 2017
  27. 08/13 t7610: always work on a test-specific branchRichard Hansen, Jan 9, 2017
  28. 13/13 mergetool: fix running in subdir when rerere enabledRichard Hansen, Jan 9, 2017
  29. Junio C HamanoJan 9, 2017
  30. Junio C HamanoJan 9, 2017
  31. Johannes SixtJan 9, 2017
  32. Richard HansenJan 9, 2017
  33. Junio C HamanoJan 9, 2017
  34. Junio C HamanoJan 9, 2017
  35. Richard HansenJan 9, 2017
  36. 09/13 t7610: don't assume the checked-out commitRichard Hansen, Jan 9, 2017
  37. 12/13 mergetool: take the "-O" out of $orderfileRichard Hansen, Jan 9, 2017
  38. 11/13 t7610: add test case for rerere+mergetool+subdir bugRichard Hansen, Jan 9, 2017
  39. 10/13 t7610: spell 'git reset --hard' consistentlyRichard Hansen, Jan 9, 2017
  40. 02/13 t7610: update branch names to match test numberRichard Hansen, Jan 9, 2017
  41. Stefan BellerJan 9, 2017
  42. 00/14 fix mergetool+rerere+subdir regressionRichard Hansen, Jan 9, 2017
  43. 01/14 .mailmap: Use my personal email address as my canonicalRichard Hansen, Jan 9, 2017
  44. 02/14 rev-parse doc: use "--" in the --prefix exampleRichard Hansen, Jan 9, 2017
  45. 04/14 t7610: Move setup code to the 'setup' test case.Richard Hansen, Jan 9, 2017
  46. 05/14 t7610: use test_when_finished for cleanup tasksRichard Hansen, Jan 9, 2017
  47. 08/14 t7610: delete some now-unnecessary 'git reset --hard' linesRichard Hansen, Jan 9, 2017
  48. 10/14 t7610: don't assume the checked-out commitRichard Hansen, Jan 9, 2017
  49. 13/14 mergetool: take the "-O" out of $orderfileRichard Hansen, Jan 9, 2017
  50. 11/14 t7610: spell 'git reset --hard' consistentlyRichard Hansen, Jan 9, 2017
  51. 14/14 mergetool: fix running in subdir when rerere enabledRichard Hansen, Jan 9, 2017
  52. Johannes SixtJan 10, 2017
  53. Richard HansenJan 10, 2017
  54. Junio C HamanoJan 10, 2017
  55. Johannes SixtJan 10, 2017
  56. 12/14 t7610: add test case for rerere+mergetool+subdir bugRichard Hansen, Jan 9, 2017
  57. 09/14 t7610: always work on a test-specific branchRichard Hansen, Jan 9, 2017
  58. 07/14 t7610: run 'git reset --hard' after each test to clean upRichard Hansen, Jan 9, 2017
  59. 06/14 t7610: don't rely on state from previous testRichard Hansen, Jan 9, 2017
  60. 03/14 t7610: update branch names to match test numberRichard Hansen, Jan 9, 2017
  61. 00/14 fix mergetool+rerere+subdir regressionRichard Hansen, Jan 10, 2017
  62. 01/14 .mailmap: Use my personal email address as my canonicalRichard Hansen, Jan 10, 2017
  63. 09/14 t7610: always work on a test-specific branchRichard Hansen, Jan 10, 2017
  64. 11/14 t7610: spell 'git reset --hard' consistentlyRichard Hansen, Jan 10, 2017
  65. 10/14 t7610: don't assume the checked-out commitRichard Hansen, Jan 10, 2017
  66. 12/14 t7610: add test case for rerere+mergetool+subdir bugRichard Hansen, Jan 10, 2017
  67. 13/14 mergetool: take the "-O" out of $orderfileRichard Hansen, Jan 10, 2017
  68. 14/14 mergetool: fix running in subdir when rerere enabledRichard Hansen, Jan 10, 2017
  69. 08/14 t7610: delete some now-unnecessary 'git reset --hard' linesRichard Hansen, Jan 10, 2017
  70. 07/14 t7610: run 'git reset --hard' after each test to clean upRichard Hansen, Jan 10, 2017
  71. 06/14 t7610: don't rely on state from previous testRichard Hansen, Jan 10, 2017
  72. 05/14 t7610: use test_when_finished for cleanup tasksRichard Hansen, Jan 10, 2017
  73. 04/14 t7610: Move setup code to the 'setup' test case.Richard Hansen, Jan 10, 2017
  74. 03/14 t7610: update branch names to match test numberRichard Hansen, Jan 10, 2017
  75. 02/14 rev-parse doc: pass "--" to rev-parse in the --prefix exampleRichard Hansen, Jan 10, 2017
  76. David AguilarJan 10, 2017

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.