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

Re: [GSoC][PATCH v7 00/26] Convert "git stash" to C builtin

From
Thomas Gummerer <t.gummerer@gmail.com>
Date
Aug 15, 2018, 22:25 UTC
Message-ID
<20180815222503.GR2734@hank.intra.tgummerer.com>
In-Reply-To
<cover.1533753605.git.ungureanupaulsebastian@gmail.com>
On 08/08, Paul-Sebastian Ungureanu wrote:
Show 6 quoted lines
> Hello,
> 
> Here is the whole `git stash` C version. Some of the previous
> patches were already reviewed (up to and including "stash: convert
> store to builtin"), but there are some which were not
> (starting with "stash: convert create to builtin").

Thanks for this new iteration, and sorry I took a while to find some time to review this. I had another read through the patches up until patch 15, and left some comments, before running out of time again. I hope to find some time in the next few days to go through the rest of the series as well.

One more comment in terms of the structure of the series. The patches doing the actual conversion from shell to C seem to be interleaved with cleanup patches and patches that make the C version use more internal APIs. I'd suggest putting all the cleanup patches (e.g. "stash: change `git stash show` usage text and documentation") to the front of the series, as that's more likely to be uncontroversial, and could maybe even be merged by itself.

Then I'd put all the conversion from shell to C patches, and only once everything is converted I'd put the patches to use more of the internal APIs rather than using run_command everywhere. A possible alternative would be to squash the patches to replace the run_command calls with patches that use the internal API directly, to save the reviewers some time by reading through less churn. Though I'm kind of on the fence with that, as a faithful conversion using 'run_command' may be easier to review as a first step.

Hope this helps!
Show 25 quoted lines
> In order to see the difference between the shell version and
> the C version, I ran `time` on:
> 
> * git test suite (t3903-stash.sh, t3904-stash-patch.sh,
> t3905-stash-include-untracked.sh and t3906-stash-submodule.sh)
> 
>         t3903-stash.sh:
>         ** SHELL: 12,69s user 9,95s system 109% cpu 20,730 total
>         **     C:  2,67s user 2,84s system 105% cpu  5,206 total
> 
>         t3904-stash-patch.sh:
>         ** SHELL: 1,43s user 0,94s system 106% cpu 2,242 total
>         **     C: 1,01s user 0,58s system 104% cpu 1,530 total
> 
>         t3905-stash-include-untracked.sh
>         ** SHELL: 2,22s user 1,73s system 110% cpu 3,569 total
>         **     C: 0,59s user 0,57s system 106% cpu 1,085 total
> 
>         t3906-stash-submodule.sh
>         ** SHELL: 2,89s user 2,99s system 106% cpu 5,527 total
>         **     C: 2,21s user 2,61s system 105% cpu 4,568 total
> 
>         TOTAL:
>         ** SHELL: 19.23s user 15.61s system
>         **     C:  6.48s user  6.60s system
Awesome!
Show 69 quoted lines
> * a git repository with 4000 files: 1000 not changed,
> 1000 staged files, 1000 unstaged files, 1000 untracked.
> In this case I ran some of the most used commands:
> 
>         git stash push:
> 
>         ** SHELL: 0,12s user 0,21s system 101% cpu 0,329 total
>         **     C: 0,06s user 0,13s system 105% cpu 0,185 total
> 
>         git stash push -u:
> 
>         ** SHELL: 0,18s user 0,27s system  108% cpu 0,401 total
>         **     C: 0,09s user 0,19s system  103% cpu 0,267 total
> 
>         git stash pop:
> 
>         ** SHELL: 0,16s user 0,26s system 103% cpu 0,399 total
>         **     C: 0,13s user 0,19s system 102% cpu 0,308 total
> 
> Best regards,
> Paul Ungureanu
> 
> 
> Joel Teichroeb (5):
>   stash: improve option parsing test coverage
>   stash: convert apply to builtin
>   stash: convert drop and clear to builtin
>   stash: convert branch to builtin
>   stash: convert pop to builtin
> 
> Paul-Sebastian Ungureanu (21):
>   sha1-name.c: added 'get_oidf', which acts like 'get_oid'
>   stash: update test cases conform to coding guidelines
>   stash: renamed test cases to be more descriptive
>   stash: implement the "list" command in the builtin
>   stash: convert show to builtin
>   stash: change `git stash show` usage text and documentation
>   stash: refactor `show_stash()` to use the diff API
>   stash: update `git stash show` documentation
>   stash: convert store to builtin
>   stash: convert create to builtin
>   stash: replace spawning a "read-tree" process
>   stash: avoid spawning a "diff-index" process
>   stash: convert push to builtin
>   stash: make push to be quiet
>   stash: add tests for `git stash push -q`
>   stash: replace spawning `git ls-files` child process
>   stash: convert save to builtin
>   stash: convert `stash--helper.c` into `stash.c`
>   stash: optimize `get_untracked_files()` and `check_changes()`
>   stash: replace all `write-tree` child processes with API calls
>   stash: replace all "git apply" child processes with API calls
> 
>  Documentation/git-stash.txt |    7 +-
>  Makefile                    |    2 +-
>  builtin.h                   |    1 +
>  builtin/stash.c             | 1562 +++++++++++++++++++++++++++++++++++
>  cache.h                     |    1 +
>  git-stash.sh                |  752 -----------------
>  git.c                       |    1 +
>  sha1-name.c                 |   19 +
>  t/t3903-stash.sh            |  190 +++--
>  9 files changed, 1714 insertions(+), 821 deletions(-)
>  create mode 100644 builtin/stash.c
>  delete mode 100755 git-stash.sh
> 
> -- 
> 2.18.0.573.g56500d98f
> 
Previous: Thomas GummererNext: Paul Sebastian Ungureanu
Message 107 of 181 in “Convert some stash functionality to a builtin”
  1. 0/5 Convert some stash functionality to a builtinJoel Teichroeb, Apr 5, 2018
  2. 1/5 stash: improve option parsing test coverageJoel Teichroeb, Apr 5, 2018
  3. Johannes SchindelinApr 6, 2018
  4. Paul-Sebastian UngureanuApr 6, 2018
  5. Johannes SchindelinApr 9, 2018
  6. 3/5 stash: convert drop and clear to builtinJoel Teichroeb, Apr 5, 2018
  7. Johannes SchindelinApr 6, 2018
  8. 4/5 stash: convert branch to builtinJoel Teichroeb, Apr 5, 2018
  9. Johannes SchindelinApr 6, 2018
  10. 5/5 stash: convert pop to builtinJoel Teichroeb, Apr 5, 2018
  11. Johannes SchindelinApr 6, 2018
  12. 2/5 stash: convert apply to builtinJoel Teichroeb, Apr 5, 2018
  13. Christian CouderApr 5, 2018
  14. Christian CouderApr 5, 2018
  15. Christian CouderApr 5, 2018
  16. Johannes SchindelinApr 5, 2018
  17. Johannes SchindelinApr 6, 2018
  18. Johannes SchindelinApr 6, 2018
  19. Johannes SchindelinApr 6, 2018
  20. Paul-Sebastian UngureanuApr 28, 2018
  21. Johannes SchindelinApr 29, 2018
  22. 0/4 stash: add new tests and introduce a new helper functionPaul-Sebastian Ungureanu, Jun 25, 2018
  23. 1/4 sha1-name.c: added 'get_oidf', which acts like 'get_oid'Paul-Sebastian Ungureanu, Jun 25, 2018
  24. Johannes SchindelinJun 26, 2018
  25. 2/4 stash: improve option parsing test coveragePaul-Sebastian Ungureanu, Jun 25, 2018
  26. 3/4 stash: update test cases conform to coding guidelinesPaul-Sebastian Ungureanu, Jun 25, 2018
  27. Johannes SchindelinJun 26, 2018
  28. 4/4 stash: renamed test cases to be more descriptivePaul-Sebastian Ungureanu, Jun 25, 2018
  29. Johannes SchindelinJun 26, 2018
  30. 2/4 stash: convert drop and clear to builtinPaul-Sebastian Ungureanu, Jun 25, 2018
  31. Johannes SchindelinJun 26, 2018
  32. Paul-Sebastian UngureanuJun 28, 2018
  33. 1/4 stash: convert apply to builtinPaul-Sebastian Ungureanu, Jun 25, 2018
  34. 4/4 stash: convert pop to builtinPaul-Sebastian Ungureanu, Jun 25, 2018
  35. Johannes SchindelinJun 26, 2018
  36. 3/4 stash: convert branch to builtinPaul-Sebastian Ungureanu, Jun 25, 2018
  37. Johannes SchindelinJun 26, 2018
  38. Junio C HamanoJun 27, 2018
  39. Paul-Sebastian UngureanuJun 28, 2018
  40. 1/6 stash: implement the "list" command in the builtinPaul-Sebastian Ungureanu, Jun 25, 2018
  41. 3/6 stash: change `git stash show` usage text and documentationPaul-Sebastian Ungureanu, Jun 25, 2018
  42. 6/6 stash: convert store to builtinPaul-Sebastian Ungureanu, Jun 25, 2018
  43. 2/6 stash: convert show to builtinPaul-Sebastian Ungureanu, Jun 25, 2018
  44. 5/6 stash: update `git stash show` documentationPaul-Sebastian Ungureanu, Jun 25, 2018
  45. 4/6 stash: refactor `show_stash()` to use the diff APIPaul-Sebastian Ungureanu, Jun 25, 2018
  46. Johannes SchindelinJun 26, 2018
  47. Junio C HamanoJun 27, 2018
  48. Paul-Sebastian UngureanuJun 28, 2018
  49. Johannes SchindelinJun 26, 2018
  50. Paul-Sebastian UngureanuJun 28, 2018
  51. [GSoC][PATCH v7 00/26] Convert "git stash" to C builtinPaul-Sebastian Ungureanu, Aug 8, 2018
  52. [GSoC][PATCH v7 01/26] sha1-name.c: added 'get_oidf', which acts like 'get_oid'Paul-Sebastian Ungureanu, Aug 8, 2018
  53. [GSoC][PATCH v7 02/26] stash: improve option parsing test coveragePaul-Sebastian Ungureanu, Aug 8, 2018
  54. [GSoC][PATCH v7 03/26] stash: update test cases conform to coding guidelinesPaul-Sebastian Ungureanu, Aug 8, 2018
  55. [GSoC][PATCH v7 04/26] stash: renamed test cases to be more descriptivePaul-Sebastian Ungureanu, Aug 8, 2018
  56. Thomas GummererAug 15, 2018
  57. [GSoC][PATCH v7 05/26] stash: convert apply to builtinPaul-Sebastian Ungureanu, Aug 8, 2018
  58. Junio C HamanoAug 8, 2018
  59. Paul-Sebastian UngureanuAug 9, 2018
  60. Junio C HamanoAug 9, 2018
  61. Paul-Sebastian UngureanuAug 10, 2018
  62. Duy NguyenAug 18, 2018
  63. [GSoC][PATCH v7 07/26] stash: convert branch to builtinPaul-Sebastian Ungureanu, Aug 8, 2018
  64. [GSoC][PATCH v7 06/26] stash: convert drop and clear to builtinPaul-Sebastian Ungureanu, Aug 8, 2018
  65. [GSoC][PATCH v7 08/26] stash: convert pop to builtinPaul-Sebastian Ungureanu, Aug 8, 2018
  66. [GSoC][PATCH v7 10/26] stash: convert show to builtinPaul-Sebastian Ungureanu, Aug 8, 2018
  67. Thomas GummererAug 15, 2018
  68. Paul Sebastian UngureanuAug 18, 2018
  69. [GSoC][PATCH v7 11/26] stash: change `git stash show` usage text and documentationPaul-Sebastian Ungureanu, Aug 8, 2018
  70. Thomas GummererAug 15, 2018
  71. [GSoC][PATCH v7 12/26] stash: refactor `show_stash()` to use the diff APIPaul-Sebastian Ungureanu, Aug 8, 2018
  72. Thomas GummererAug 15, 2018
  73. Paul Sebastian UngureanuAug 18, 2018
  74. [GSoC][PATCH v7 13/26] stash: update `git stash show` documentationPaul-Sebastian Ungureanu, Aug 8, 2018
  75. Thomas GummererAug 15, 2018
  76. [GSoC][PATCH v7 09/26] stash: implement the "list" command in the builtinPaul-Sebastian Ungureanu, Aug 8, 2018
  77. Thomas GummererAug 15, 2018
  78. Paul Sebastian UngureanuAug 18, 2018
  79. [GSoC][PATCH v7 16/26] stash: replace spawning a "read-tree" processPaul-Sebastian Ungureanu, Aug 8, 2018
  80. Thomas GummererAug 18, 2018
  81. [GSoC][PATCH v7 14/26] stash: convert store to builtinPaul-Sebastian Ungureanu, Aug 8, 2018
  82. Thomas GummererAug 15, 2018
  83. [GSoC][PATCH v7 15/26] stash: convert create to builtinPaul-Sebastian Ungureanu, Aug 8, 2018
  84. Thomas GummererAug 15, 2018
  85. Paul Sebastian UngureanuAug 18, 2018
  86. Thomas GummererAug 18, 2018
  87. [GSoC][PATCH v7 17/26] stash: avoid spawning a "diff-index" processPaul-Sebastian Ungureanu, Aug 8, 2018
  88. Thomas GummererAug 18, 2018
  89. [GSoC][PATCH v7 18/26] stash: convert push to builtinPaul-Sebastian Ungureanu, Aug 8, 2018
  90. Thomas GummererAug 18, 2018
  91. [GSoC][PATCH v7 20/26] stash: add tests for `git stash push -q`Paul-Sebastian Ungureanu, Aug 8, 2018
  92. Thomas GummererAug 18, 2018
  93. [GSoC][PATCH v7 19/26] stash: make push to be quietPaul-Sebastian Ungureanu, Aug 8, 2018
  94. Thomas GummererAug 18, 2018
  95. [GSoC][PATCH v7 21/26] stash: replace spawning `git ls-files` child processPaul-Sebastian Ungureanu, Aug 8, 2018
  96. Thomas GummererAug 18, 2018
  97. [GSoC][PATCH v7 22/26] stash: convert save to builtinPaul-Sebastian Ungureanu, Aug 8, 2018
  98. Thomas GummererAug 18, 2018
  99. [GSoC][PATCH v7 24/26] stash: optimize `get_untracked_files()` and `check_changes()`Paul-Sebastian Ungureanu, Aug 8, 2018
  100. Thomas GummererAug 18, 2018
  101. [GSoC][PATCH v7 25/26] stash: replace all `write-tree` child processes with API callsPaul-Sebastian Ungureanu, Aug 8, 2018
  102. Thomas GummererAug 19, 2018
  103. [GSoC][PATCH v7 23/26] stash: convert `stash--helper.c` into `stash.c`Paul-Sebastian Ungureanu, Aug 8, 2018
  104. Thomas GummererAug 18, 2018
  105. [GSoC][PATCH v7 26/26] stash: replace all "git apply" child processes with API callsPaul-Sebastian Ungureanu, Aug 8, 2018
  106. Thomas GummererAug 19, 2018
  107. Thomas GummererAug 15, 2018
  108. Paul Sebastian UngureanuAug 16, 2018
  109. [GSoC][PATCH v8 00/20] Convert "git stash" to C builtinPaul-Sebastian Ungureanu, Aug 30, 2018
  110. [GSoC][PATCH v8 01/20] sha1-name.c: add `get_oidf()` which acts like `get_oid()`Paul-Sebastian Ungureanu, Aug 30, 2018
  111. [GSoC][PATCH v8 02/20] stash: improve option parsing test coveragePaul-Sebastian Ungureanu, Aug 30, 2018
  112. [GSoC][PATCH v8 03/20] stash: update test cases conform to coding guidelinesPaul-Sebastian Ungureanu, Aug 30, 2018
  113. Junio C HamanoAug 30, 2018
  114. [GSoC][PATCH v8 04/20] stash: rename test cases to be more descriptivePaul-Sebastian Ungureanu, Aug 30, 2018
  115. [GSoC][PATCH v8 05/20] stash: add tests for `git stash show` configPaul-Sebastian Ungureanu, Aug 30, 2018
  116. Junio C HamanoAug 30, 2018
  117. Johannes SchindelinSep 3, 2018
  118. [GSoC][PATCH v8 06/20] stash: convert apply to builtinPaul-Sebastian Ungureanu, Aug 30, 2018
  119. [GSoC][PATCH v8 07/20] stash: convert drop and clear to builtinPaul-Sebastian Ungureanu, Aug 30, 2018
  120. [GSoC][PATCH v8 09/20] stash: convert pop to builtinPaul-Sebastian Ungureanu, Aug 30, 2018
  121. [GSoC][PATCH v8 08/20] stash: convert branch to builtinPaul-Sebastian Ungureanu, Aug 30, 2018
  122. Johannes SchindelinSep 3, 2018
  123. [GSoC][PATCH v8 11/20] stash: convert show to builtinPaul-Sebastian Ungureanu, Aug 30, 2018
  124. [GSoC][PATCH v8 13/20] stash: convert store to builtinPaul-Sebastian Ungureanu, Aug 30, 2018
  125. Johannes SchindelinSep 3, 2018
  126. [GSoC][PATCH v8 14/20] stash: convert create to builtinPaul-Sebastian Ungureanu, Aug 30, 2018
  127. Johannes SchindelinSep 3, 2018
  128. Paul-Sebastian UngureanuSep 25, 2018
  129. Johannes SchindelinNov 9, 2018
  130. [GSoC][PATCH v8 12/20] stash: mention options in `show` synopsis.Paul-Sebastian Ungureanu, Aug 30, 2018
  131. [GSoC][PATCH v8 10/20] stash: convert list to builtinPaul-Sebastian Ungureanu, Aug 30, 2018
  132. [GSoC][PATCH v8 16/20] stash: make push -q quietPaul-Sebastian Ungureanu, Aug 30, 2018
  133. [GSoC][PATCH v8 17/20] stash: convert save to builtinPaul-Sebastian Ungureanu, Aug 30, 2018
  134. Johannes SchindelinSep 3, 2018
  135. Eric SunshineSep 3, 2018
  136. Johannes SchindelinSep 3, 2018
  137. [GSoC][PATCH v8 19/20] stash: optimize `get_untracked_files()` and `check_changes()`Paul-Sebastian Ungureanu, Aug 30, 2018
  138. Johannes SchindelinSep 3, 2018
  139. [GSoC][PATCH v8 18/20] stash: convert `stash--helper.c` into `stash.c`Paul-Sebastian Ungureanu, Aug 30, 2018
  140. Johannes SchindelinSep 3, 2018
  141. Paul-Sebastian UngureanuSep 25, 2018
  142. Johannes SchindelinNov 9, 2018
  143. [GSoC][PATCH v8 20/20] stash: replace all `write-tree` child processes with API callsPaul-Sebastian Ungureanu, Aug 30, 2018
  144. Johannes SchindelinSep 3, 2018
  145. [GSoC][PATCH v8 15/20] stash: convert push to builtinPaul-Sebastian Ungureanu, Aug 30, 2018
  146. Johannes SchindelinSep 3, 2018
  147. Ævar Arnfjörð BjarmasonAug 30, 2018
  148. Junio C HamanoAug 31, 2018
  149. Johannes SchindelinSep 3, 2018
  150. 00/21 Convert "git stash" to C builtinPaul-Sebastian Ungureanu, Sep 25, 2018
  151. 01/21 sha1-name.c: add `get_oidf()` which acts like `get_oid()`Paul-Sebastian Ungureanu, Sep 25, 2018
  152. 02/21 strbuf.c: add `strbuf_join_argv()`Paul-Sebastian Ungureanu, Sep 25, 2018
  153. Thomas GummererSep 30, 2018
  154. 03/21 stash: improve option parsing test coveragePaul-Sebastian Ungureanu, Sep 25, 2018
  155. 04/21 stash: update test cases conform to coding guidelinesPaul-Sebastian Ungureanu, Sep 25, 2018
  156. Thomas GummererSep 30, 2018
  157. 05/21 stash: rename test cases to be more descriptivePaul-Sebastian Ungureanu, Sep 25, 2018
  158. 06/21 stash: add tests for `git stash show` configPaul-Sebastian Ungureanu, Sep 25, 2018
  159. 07/21 stash: convert apply to builtinPaul-Sebastian Ungureanu, Sep 25, 2018
  160. Thomas GummererSep 30, 2018
  161. 08/21 stash: convert drop and clear to builtinPaul-Sebastian Ungureanu, Sep 25, 2018
  162. 10/21 stash: convert pop to builtinPaul-Sebastian Ungureanu, Sep 25, 2018
  163. 11/21 stash: convert list to builtinPaul-Sebastian Ungureanu, Sep 25, 2018
  164. 13/21 stash: mention options in `show` synopsis.Paul-Sebastian Ungureanu, Sep 25, 2018
  165. Thomas GummererOct 2, 2018
  166. 14/21 stash: convert store to builtinPaul-Sebastian Ungureanu, Sep 25, 2018
  167. 15/21 stash: convert create to builtinPaul-Sebastian Ungureanu, Sep 25, 2018
  168. Thomas GummererOct 2, 2018
  169. 16/21 stash: convert push to builtinPaul-Sebastian Ungureanu, Sep 25, 2018
  170. Thomas GummererOct 2, 2018
  171. 17/21 stash: make push -q quietPaul-Sebastian Ungureanu, Sep 25, 2018
  172. 18/21 stash: convert save to builtinPaul-Sebastian Ungureanu, Sep 25, 2018
  173. 19/21 stash: convert `stash--helper.c` into `stash.c`Paul-Sebastian Ungureanu, Sep 25, 2018
  174. Thomas GummererOct 2, 2018
  175. 12/21 stash: convert show to builtinPaul-Sebastian Ungureanu, Sep 25, 2018
  176. 21/21 stash: replace all `write-tree` child processes with API callsPaul-Sebastian Ungureanu, Sep 25, 2018
  177. 20/21 stash: optimize `get_untracked_files()` and `check_changes()`Paul-Sebastian Ungureanu, Sep 25, 2018
  178. 09/21 stash: convert branch to builtinPaul-Sebastian Ungureanu, Sep 25, 2018
  179. Thomas GummererSep 30, 2018
  180. Junio C HamanoSep 26, 2018
  181. Joel TeichroebApr 30, 2018

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.