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

Re: [PATCH v2 00/94] libify apply and use lib in am

From
Junio C Hamano <gitster@pobox.com>
Date
May 14, 2016, 18:31 UTC
Message-ID
<xmqqwpmw7aow.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<CAP8UFD376guRRPpMVjC36K0dvWy17xdaHvV1WoRjMaNpdp0bqQ@mail.gmail.com>
Christian Couder <christian.couder@gmail.com> writes:
Show 20 quoted lines
>>> So it looks to me that --quiet means something like "don't tell the
>>> story of your life, but in case of problem you are allowed to
>>> complain". In other word --quiet generally doesn't suppress error
>>> messages from error() or die().
>>
>> Right.
>>
>> And if you care to take a step back, this is most likely what we want in
>> libified code.
>
> In the previous discussion, Junio asked:
>
> "How far can you go with just set-error-routine?  Are there things,
> other than the file descriptors, that you need to futz with in order
> to covert that "we'd fallback, so this early round must be silent"
> codepath?"
>
> So it looks to me that the goal is to have something that replicate
> the current behavior, which is to not even display messages from
> error().

Note that I was not endorsing the approach to use set-error-routine, one of whose downside is that it is easy to silence everything unconditionally. Between --quiet/--silent, I wasn't making any choice, as I hadn't even formed an opinion back when I wrote it.

I was merely asking "is use of set-error-routine the worst thing you need to do, or do you need to do anything more gross?", half anticipating "no, it turns out that I need to longjmp(3) from my die-routine to come back from deep in the existing code because I do not think I'd bother propagating the error status all the way along the call stack", at which point my response would have been "Ugh, use of set-error-routine to avoid properly refactoring, even if we assume it is OK to squelch the errors unconditionally, is bad enough. If you need to longjmp(3), that's no longer a libification. You are better off using the run_command() interface to give the caller and the callee a proper isolation".

Libification is not just "now it runs inside a single process" at all. It is more about "it has proper abstraction and separation so that callers have _more_ control than they used to (compared to interacting with a spawned process) while retaining the control of their own environment".

And as this thread showed, when turning an implementation that uses run-command with program's standard error sent to /dev/null into a "libified" implementation, we _gain_ a possibility to be more selective in what we silence. I think that exactly falls into "callers have more control" category of libification benefit.

Quite honestly, I was sort of surprised by the quality of the argument for proper libification Dscho has been making in this thread, and that was why I didn't say much here.

Having said all that, as to --quiet/--silent, another way to surface the "even more quiet" used is with "-q -q" (i.e. multiple levels of quietness). I am just saying this for the record without suggesting it is better or worse suited for this case than what has been discussed.

In any case, I do see the need for what your --silent option does internally when a caller like "am" calls into the libified "apply" machinery. When we _know_ we will run a "fallback" invocation after an initial "more strict" apply attempt fails, we do want the initial invocation to be totally silent, not even with any error message, because we know that it is sufficient to let the fallback invocation show its error message (if it fails). The fallback may even succeed in which case error messages from the initial invocation serves only as an explanation of the reason why we used fallback, which is not interesting to the end user at all.

I however do not see a reason why you need to expose that feature to the users of "git apply". So I am not sure if any of us care deeply the choice among --silent, --quiet and -q -q.

Previous: Christian CouderNext: Christian Couder
Message 146 of 148 in “libify apply and use lib in am”
  1. 00/94 libify apply and use lib in amChristian Couder, May 11, 2016
  2. 01/94 builtin/apply: make gitdiff_verify_name() return voidChristian Couder, May 11, 2016
  3. Junio C HamanoMay 12, 2016
  4. 02/94 builtin/apply: avoid parameter shadowing 'p_value' globalChristian Couder, May 11, 2016
  5. Junio C HamanoMay 12, 2016
  6. 03/94 builtin/apply: avoid parameter shadowing 'linenr' globalChristian Couder, May 11, 2016
  7. Junio C HamanoMay 12, 2016
  8. 04/94 builtin/apply: avoid local variable shadowing 'len' parameterChristian Couder, May 11, 2016
  9. 05/94 builtin/apply: extract line_by_line_fuzzy_match() from match_fragment()Christian Couder, May 11, 2016
  10. Junio C HamanoMay 12, 2016
  11. 06/94 builtin/apply: move 'options' variable into cmd_apply()Christian Couder, May 11, 2016
  12. 07/94 builtin/apply: move 'read_stdin' global into cmd_apply()Christian Couder, May 11, 2016
  13. 08/94 builtin/apply: introduce 'struct apply_state' to start libifyingChristian Couder, May 11, 2016
  14. 09/94 builtin/apply: move 'state' init into init_apply_state()Christian Couder, May 11, 2016
  15. Junio C HamanoMay 12, 2016
  16. 10/94 builtin/apply: move 'unidiff_zero' global into 'struct apply_state'Christian Couder, May 11, 2016
  17. Junio C HamanoMay 12, 2016
  18. Christian CouderMay 12, 2016
  19. 11/94 builtin/apply: move 'check' global into 'struct apply_state'Christian Couder, May 11, 2016
  20. 12/94 builtin/apply: move 'check_index' global into 'struct apply_state'Christian Couder, May 11, 2016
  21. 13/94 builtin/apply: move 'apply_in_reverse' global into 'struct apply_state'Christian Couder, May 11, 2016
  22. 14/94 builtin/apply: move 'apply_with_reject' global into 'struct apply_state'Christian Couder, May 11, 2016
  23. 15/94 builtin/apply: move 'apply_verbosely' global into 'struct apply_state'Christian Couder, May 11, 2016
  24. 16/94 builtin/apply: move 'update_index' global into 'struct apply_state'Christian Couder, May 11, 2016
  25. Junio C HamanoMay 12, 2016
  26. 17/94 builtin/apply: move 'allow_overlap' global into 'struct apply_state'Christian Couder, May 11, 2016
  27. 18/94 builtin/apply: move 'cached' global into 'struct apply_state'Christian Couder, May 11, 2016
  28. Junio C HamanoMay 12, 2016
  29. 19/94 builtin/apply: move 'diffstat' global into 'struct apply_state'Christian Couder, May 11, 2016
  30. 20/94 builtin/apply: move 'numstat' global into 'struct apply_state'Christian Couder, May 11, 2016
  31. 21/94 builtin/apply: move 'summary' global into 'struct apply_state'Christian Couder, May 11, 2016
  32. 22/94 builtin/apply: move 'threeway' global into 'struct apply_state'Christian Couder, May 11, 2016
  33. Junio C HamanoMay 12, 2016
  34. Christian CouderMay 12, 2016
  35. Junio C HamanoMay 12, 2016
  36. 23/94 builtin/apply: move 'no_add' global into 'struct apply_state'Christian Couder, May 11, 2016
  37. 24/94 builtin/apply: move 'unsafe_paths' global into 'struct apply_state'Christian Couder, May 11, 2016
  38. 25/94 builtin/apply: move 'line_termination' global into 'struct apply_state'Christian Couder, May 11, 2016
  39. 26/94 builtin/apply: move 'fake_ancestor' global into 'struct apply_state'Christian Couder, May 11, 2016
  40. 27/94 builtin/apply: move 'p_context' global into 'struct apply_state'Christian Couder, May 11, 2016
  41. 28/94 builtin/apply: move 'apply' global into 'struct apply_state'Christian Couder, May 11, 2016
  42. 29/94 builtin/apply: move 'patch_input_file' global into 'struct apply_state'Christian Couder, May 11, 2016
  43. 30/94 builtin/apply: move 'limit_by_name' global into 'struct apply_state'Christian Couder, May 11, 2016
  44. 31/94 builtin/apply: move 'has_include' global into 'struct apply_state'Christian Couder, May 11, 2016
  45. 32/94 builtin/apply: move 'p_value' global into 'struct apply_state'Christian Couder, May 11, 2016
  46. 33/94 builtin/apply: move 'p_value_known' global into 'struct apply_state'Christian Couder, May 11, 2016
  47. Junio C HamanoMay 12, 2016
  48. 34/94 builtin/apply: move 'root' global into 'struct apply_state'Christian Couder, May 11, 2016
  49. 35/94 builtin/apply: move 'whitespace_error' global into 'struct apply_state'Christian Couder, May 11, 2016
  50. 36/94 builtin/apply: move 'whitespace_option' into 'struct apply_state'Christian Couder, May 11, 2016
  51. 37/94 builtin/apply: remove whitespace_option arg from set_default_whitespace_mode()Christian Couder, May 11, 2016
  52. 38/94 builtin/apply: move 'squelch_whitespace_errors' into 'struct apply_state'Christian Couder, May 11, 2016
  53. 39/94 builtin/apply: move 'applied_after_fixing_ws' into 'struct apply_state'Christian Couder, May 11, 2016
  54. 40/94 builtin/apply: move 'ws_error_action' into 'struct apply_state'Christian Couder, May 11, 2016
  55. Junio C HamanoMay 12, 2016
  56. 41/94 builtin/apply: move 'ws_ignore_action' into 'struct apply_state'Christian Couder, May 11, 2016
  57. 42/94 builtin/apply: move 'max_change' and 'max_len' into 'struct apply_state'Christian Couder, May 11, 2016
  58. 43/94 builtin/apply: move 'state_linenr' global into 'struct apply_state'Christian Couder, May 11, 2016
  59. 44/94 builtin/apply: move 'fn_table' global into 'struct apply_state'Christian Couder, May 11, 2016
  60. 45/94 builtin/apply: move 'symlink_changes' global into 'struct apply_state'Christian Couder, May 11, 2016
  61. 46/94 builtin/apply: move 'state' check into check_apply_state()Christian Couder, May 11, 2016
  62. 47/94 builtin/apply: move applying patches into apply_all_patches()Christian Couder, May 11, 2016
  63. 48/94 builtin/apply: rename 'prefix_' parameter to 'prefix'Christian Couder, May 11, 2016
  64. Junio C HamanoMay 12, 2016
  65. Junio C HamanoMay 12, 2016
  66. Christian CouderMay 13, 2016
  67. Junio C HamanoMay 14, 2016
  68. Christian CouderMay 24, 2016
  69. Christian CouderMay 13, 2016
  70. Christian CouderMay 24, 2016
  71. 49/94 builtin/apply: move 'lock_file' global into 'struct apply_state'Christian Couder, May 11, 2016
  72. 50/94 builtin/apply: move 'newfd' global into 'struct apply_state'Christian Couder, May 11, 2016
  73. 51/94 builtin/apply: make apply_patch() return -1 instead of die()ingChristian Couder, May 11, 2016
  74. 52/94 builtin/apply: read_patch_file() return -1 instead of die()ingChristian Couder, May 11, 2016
  75. Eric SunshineMay 16, 2016
  76. Christian CouderMay 16, 2016
  77. 53/94 builtin/apply: make find_header() return -1 instead of die()ingChristian Couder, May 11, 2016
  78. 54/94 builtin/apply: make parse_chunk() return a negative integer on errorChristian Couder, May 11, 2016
  79. Eric SunshineMay 16, 2016
  80. Christian CouderMay 16, 2016
  81. Christian CouderJun 8, 2016
  82. 55/94 builtin/apply: make parse_single_patch() return -1 on errorChristian Couder, May 11, 2016
  83. 56/94 apply: move 'struct apply_state' to apply.hChristian Couder, May 11, 2016
  84. Eric SunshineMay 16, 2016
  85. Junio C HamanoMay 16, 2016
  86. Christian CouderJun 8, 2016
  87. 57/94 builtin/apply: make parse_whitespace_option() return -1 instead of die()ingChristian Couder, May 11, 2016
  88. 58/94 builtin/apply: make parse_ignorewhitespace_option() return -1 instead of die()ingChristian Couder, May 11, 2016
  89. 59/94 builtin/apply: move init_apply_state() to apply.cChristian Couder, May 11, 2016
  90. Eric SunshineMay 16, 2016
  91. 60/94 apply: make init_apply_state() return -1 instead of exit()ingChristian Couder, May 11, 2016
  92. Eric SunshineMay 16, 2016
  93. 61/94 builtin/apply: make check_apply_state() return -1 instead of die()ingChristian Couder, May 11, 2016
  94. 62/94 builtin/apply: move check_apply_state() to apply.cChristian Couder, May 11, 2016
  95. 63/94 builtin/apply: make apply_all_patches() return -1 on errorChristian Couder, May 11, 2016
  96. Eric SunshineMay 16, 2016
  97. Christian CouderJun 8, 2016
  98. Eric SunshineJun 8, 2016
  99. Christian CouderJun 9, 2016
  100. 64/94 builtin/apply: make parse_traditional_patch() return -1 on errorChristian Couder, May 11, 2016
  101. 65/94 builtin/apply: make gitdiff_*() return 1 at end of headerChristian Couder, May 11, 2016
  102. 66/94 builtin/apply: make gitdiff_*() return -1 on errorChristian Couder, May 11, 2016
  103. 67/94 builtin/apply: change die_on_unsafe_path() to check_unsafe_path()Christian Couder, May 11, 2016
  104. 68/94 builtin/apply: make build_fake_ancestor() return -1 on errorChristian Couder, May 11, 2016
  105. 69/94 builtin/apply: make remove_file() return -1 on errorChristian Couder, May 11, 2016
  106. 70/94 builtin/apply: make add_conflicted_stages_file() return -1 on errorChristian Couder, May 11, 2016
  107. 71/94 builtin/apply: make add_index_file() return -1 on errorChristian Couder, May 11, 2016
  108. 72/94 builtin/apply: make create_file() return -1 on errorChristian Couder, May 11, 2016
  109. 73/94 builtin/apply: make write_out_one_result() return -1 on errorChristian Couder, May 11, 2016
  110. 74/94 builtin/apply: make write_out_results() return -1 on errorChristian Couder, May 11, 2016
  111. 75/94 builtin/apply: make try_create_file() return -1 on errorChristian Couder, May 11, 2016
  112. 76/94 builtin/apply: make create_one_file() return -1 on errorChristian Couder, May 11, 2016
  113. 77/94 builtin/apply: rename option parsing functionsChristian Couder, May 11, 2016
  114. 78/94 apply: rename and move opt constants to apply.hChristian Couder, May 11, 2016
  115. 80/94 apply: make some parsing functions static againChristian Couder, May 11, 2016
  116. 81/94 run-command: make dup_devnull() non staticChristian Couder, May 11, 2016
  117. 82/94 apply: roll back index lock file in case of errorChristian Couder, May 11, 2016
  118. 83/94 environment: add set_index_file()Christian Couder, May 11, 2016
  119. 84/94 builtin/am: use apply api in run_apply()Christian Couder, May 11, 2016
  120. 85/94 write_or_die: use warning() instead of fprintf(stderr, ...)Christian Couder, May 11, 2016
  121. 86/94 apply: add 'be_silent' variable to 'struct apply_state'Christian Couder, May 11, 2016
  122. 87/94 apply: make 'be_silent' incomatible with 'apply_verbosely'Christian Couder, May 11, 2016
  123. 88/94 apply: don't print on stdout when be_silent is setChristian Couder, May 11, 2016
  124. 89/94 usage: add set_warn_routine()Christian Couder, May 11, 2016
  125. 90/94 usage: add get_error_routine() and get_warn_routine()Christian Couder, May 11, 2016
  126. 91/94 apply: change error_routine when be_silent is setChristian Couder, May 11, 2016
  127. 92/94 am: use be_silent in 'struct apply_state' to shut up applying patchesChristian Couder, May 11, 2016
  128. 93/94 run-command: make dup_devnull() static againChristian Couder, May 11, 2016
  129. 94/94 builtin/apply: add a cli option for be_silentChristian Couder, May 11, 2016
  130. Johannes SixtMay 12, 2016
  131. Christian CouderMay 12, 2016
  132. Johannes SixtJun 9, 2016
  133. Christian CouderJun 10, 2016
  134. Johannes SchindelinJun 10, 2016
  135. Christian CouderJun 10, 2016
  136. Johannes SchindelinJun 10, 2016
  137. Johannes SixtJun 10, 2016
  138. Christian CouderJun 10, 2016
  139. Johannes SchindelinJun 11, 2016
  140. Junio C HamanoMay 12, 2016
  141. Christian CouderMay 12, 2016
  142. Johannes SchindelinMay 13, 2016
  143. Christian CouderMay 13, 2016
  144. Johannes SchindelinMay 14, 2016
  145. Christian CouderMay 14, 2016
  146. Junio C HamanoMay 14, 2016
  147. Christian CouderMay 14, 2016
  148. Junio C HamanoMay 15, 2016

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.