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

Re: [PATCH v2] checkout & worktree: introduce checkout.implicitRemote

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
May 4, 2018, 18:02 UTC
Message-ID
<87k1sjxps6.fsf@evledraar.gmail.com>
In-Reply-To
<CACsJy8D+k+9SNBq7SNFpUhhdZDH7QaZ3+_rXMrge+b5KF_j9xA@mail.gmail.com>
On Fri, May 04 2018, Duy Nguyen wrote:
Show 38 quoted lines
> On Fri, May 4, 2018 at 9:54 AM, Ævar Arnfjörð Bjarmason
> <avarab@gmail.com> wrote:
>> Realistically the way we do hooks now would make the UI of this suck,
>> i.e. you couldn't configure it globally or system-wide easily. Something
>> like what I noted in
>> https://public-inbox.org/git/871sf3el01.fsf@evledraar.gmail.com/ would
>> make it suck less, but that's a much bigger task.
>
> I thought you would bring this up :) I've given some more thoughts on
> this topic and am willing to implement something like below, in a week
> or two. Would that help change your mind?
>
> I proposed hooks.* config space in that same thread. Here is the
> extension to make it cover both of your points.
>
> hooks.* can have multiple values. So you can specify
> hooks.post-checkout multiple times and all those scripts will run (in
> the same order you specified). Since we already have a search path for
> config (/etc/gitconfig -> $HOME/.gitconfig -> $REPO/config) this helps
> hooks management as well. Execution order is still the same: if you
> specify hooks.post-checkout in both /etc/gitconfig and .git/config,
> then the one in /etc/gitconfig is executed first, the one in .git
> second.
>
> And here's something extra to make it possible to override the search
> order: if you specify hooks.post-checkout = reset (reset is a random
> keyword) then _all_ post-checkout hooks before this point are ignored.
> So you can put this in .git/config
>
> [hooks]
>     post-checkout = reset
>     post-checkout = ~/some-hook
>
> and can be sure that post-checkout specified in $HOME and /etc will
> not affect you, only ~/some-hook will run. If you drop the second line
> then you have no post-checkout hooks. This is a workaround for a
> bigger problem (not being able to unset a config entry) but I think
> it's sufficient for this use case.
A few things:
 1) I don't see a reason to hold back this feature in particular waiting
    for some way to do it via config / hooks. If we grow some compatible
    way to do it via hooks in the future, great, then we can just make
    this (and numerous other config values) historical aliases for that
    facility.
 2) Let's not have some per-config type way to reset earlier config. I
    suggested a way to do it generally in
    https://public-inbox.org/git/874lkq11ug.fsf@evledraar.gmail.com/ I'm
    not saying we should go for that suggestion in particular, but that
    we should have something general.
 3) Doing #2 will take a lot longer to implement than what you're
    suggesting.
 4) I think such a facility should also be able to replace something
    like https://docs.gitlab.com/ee/administration/custom_hooks.html
    which requires not just supporting hooks from the config, but
    executing some hooks on the FS in glob() order.
 5) What you're describing above is just 1/2 of what we need to have a
    viable way to replace something like this checkout.implicitRemote
    with a hook while providing the same functionality to the end
    user.
    If something ships as a config value like checkout.implicitRemote
    users can just turn it on in their ~/.gitconfig without any further
    config, or you can tell users in docs via one-liner to enable it.
    We also need the other half which some method of shipping "standard"
    hooks with git, i.e. with your proposal something like (along with
    the general config reset):
        [config]
            reject = hooks.post-checkout
        [hooks]
            # Reads config from hooks.post-checkout-implicit-remote.*
            # (e.g. hooks.post-checkout-implicit-remote.remote = origin)
            post-checkout = git-hooks://post-checkout-implicit-remote-config
   Only then will this be as easy to enable as `git config --global..`
   (although you'll need two invocations of that, which is fine...)
 6) The feature being discussed here would not be a post-checkout hook,
    but would need to be fairly integrated with the internals of
    checkout, see `dwim_ok` and the big comment in
    parse_branchname_arg().
    I.e. the thing that makes this work is the Nth step in some fairly
    intricate fallback logic. It's not clear to me in the general case
    how we'd turn this into a hook without having N number of
    checkout-what-step-N-hooks, or requiring every checkout-what hook to
    implement a huge part of what checkout.c is doing now just to tweak
    some tiny aspect of it, such as this tweak of
    unique_tracking_name().
Previous: Duy NguyenNext: Eric Sunshine
Message 10 of 95 in “checkout & worktree: introduce a core.DWIMRemote setting”
  1. checkout & worktree: introduce a core.DWIMRemote settingÆvar Arnfjörð Bjarmason, May 2, 2018
  2. Duy NguyenMay 2, 2018
  3. Eric SunshineMay 2, 2018
  4. Duy NguyenMay 2, 2018
  5. Ævar Arnfjörð BjarmasonMay 2, 2018
  6. checkout & worktree: introduce checkout.implicitRemoteÆvar Arnfjörð Bjarmason, May 3, 2018
  7. Duy NguyenMay 3, 2018
  8. Ævar Arnfjörð BjarmasonMay 4, 2018
  9. Duy NguyenMay 4, 2018
  10. Ævar Arnfjörð BjarmasonMay 4, 2018
  11. Eric SunshineMay 4, 2018
  12. checkout & worktree: introduce checkout.implicitRemoteÆvar Arnfjörð Bjarmason, May 24, 2018
  13. Junio C HamanoMay 25, 2018
  14. Duy NguyenMay 25, 2018
  15. Ævar Arnfjörð BjarmasonMay 25, 2018
  16. Duy NguyenMay 26, 2018
  17. Ævar Arnfjörð BjarmasonMay 31, 2018
  18. 0/9 ambiguous checkout UI & checkout.defaultRemoteÆvar Arnfjörð Bjarmason, May 31, 2018
  19. 1/9 checkout tests: index should be clean after dwim checkoutÆvar Arnfjörð Bjarmason, May 31, 2018
  20. Junio C HamanoJun 1, 2018
  21. Ævar Arnfjörð BjarmasonJun 1, 2018
  22. 2/9 checkout.h: wrap the arguments to unique_tracking_name()Ævar Arnfjörð Bjarmason, May 31, 2018
  23. 3/9 checkout.[ch]: move struct declaration into *.hÆvar Arnfjörð Bjarmason, May 31, 2018
  24. Thomas GummererMay 31, 2018
  25. Junio C HamanoJun 1, 2018
  26. Ævar Arnfjörð BjarmasonJun 1, 2018
  27. 4/9 checkout.[ch]: introduce an *_INIT macroÆvar Arnfjörð Bjarmason, May 31, 2018
  28. Junio C HamanoJun 1, 2018
  29. 5/9 checkout.[ch]: change "unique" member to "num_matches"Ævar Arnfjörð Bjarmason, May 31, 2018
  30. 7/9 builtin/checkout.c: use "ret" variable for returnÆvar Arnfjörð Bjarmason, May 31, 2018
  31. 6/9 checkout: pass the "num_matches" up to callersÆvar Arnfjörð Bjarmason, May 31, 2018
  32. 9/9 checkout & worktree: introduce checkout.defaultRemoteÆvar Arnfjörð Bjarmason, May 31, 2018
  33. Stefan BellerMay 31, 2018
  34. Eric SunshineJun 1, 2018
  35. Ævar Arnfjörð BjarmasonJun 1, 2018
  36. Thomas GummererMay 31, 2018
  37. Junio C HamanoJun 1, 2018
  38. 8/9 checkout: add advice for ambiguous "checkout <branch>"Ævar Arnfjörð Bjarmason, May 31, 2018
  39. Junio C HamanoJun 1, 2018
  40. Junio C HamanoJun 1, 2018
  41. Ævar Arnfjörð BjarmasonJun 1, 2018
  42. Junio C HamanoJun 4, 2018
  43. Ævar Arnfjörð BjarmasonJun 1, 2018
  44. Eric SunshineJun 1, 2018
  45. Ævar Arnfjörð BjarmasonJun 1, 2018
  46. 0/8 ambiguous checkout UI & checkout.defaultRemoteÆvar Arnfjörð Bjarmason, Jun 1, 2018
  47. 1/8 checkout tests: index should be clean after dwim checkoutÆvar Arnfjörð Bjarmason, Jun 1, 2018
  48. 2/8 checkout.h: wrap the arguments to unique_tracking_name()Ævar Arnfjörð Bjarmason, Jun 1, 2018
  49. 3/8 checkout.[ch]: introduce an *_INIT macroÆvar Arnfjörð Bjarmason, Jun 1, 2018
  50. Eric SunshineJun 1, 2018
  51. 4/8 checkout.[ch]: change "unique" member to "num_matches"Ævar Arnfjörð Bjarmason, Jun 1, 2018
  52. Eric SunshineJun 1, 2018
  53. 6/8 builtin/checkout.c: use "ret" variable for returnÆvar Arnfjörð Bjarmason, Jun 1, 2018
  54. 5/8 checkout: pass the "num_matches" up to callersÆvar Arnfjörð Bjarmason, Jun 1, 2018
  55. 8/8 checkout & worktree: introduce checkout.defaultRemoteÆvar Arnfjörð Bjarmason, Jun 1, 2018
  56. 7/8 checkout: add advice for ambiguous "checkout <branch>"Ævar Arnfjörð Bjarmason, Jun 1, 2018
  57. Eric SunshineJun 1, 2018
  58. 0/8 ambiguous checkout UI & checkout.defaultRemoteÆvar Arnfjörð Bjarmason, Jun 2, 2018
  59. 1/8 checkout tests: index should be clean after dwim checkoutÆvar Arnfjörð Bjarmason, Jun 2, 2018
  60. 2/8 checkout.h: wrap the arguments to unique_tracking_name()Ævar Arnfjörð Bjarmason, Jun 2, 2018
  61. 3/8 checkout.c: introduce an *_INIT macroÆvar Arnfjörð Bjarmason, Jun 2, 2018
  62. 4/8 checkout.c]: change "unique" member to "num_matches"Ævar Arnfjörð Bjarmason, Jun 2, 2018
  63. 6/8 builtin/checkout.c: use "ret" variable for returnÆvar Arnfjörð Bjarmason, Jun 2, 2018
  64. 5/8 checkout: pass the "num_matches" up to callersÆvar Arnfjörð Bjarmason, Jun 2, 2018
  65. 7/8 checkout: add advice for ambiguous "checkout <branch>"Ævar Arnfjörð Bjarmason, Jun 2, 2018
  66. 8/8 checkout & worktree: introduce checkout.defaultRemoteÆvar Arnfjörð Bjarmason, Jun 2, 2018
  67. Eric SunshineJun 3, 2018
  68. 0/8 ambiguous checkout UI & checkout.defaultRemoteÆvar Arnfjörð Bjarmason, Jun 5, 2018
  69. 1/8 checkout tests: index should be clean after dwim checkoutÆvar Arnfjörð Bjarmason, Jun 5, 2018
  70. SZEDER GáborJun 5, 2018
  71. tests: make use of the test_must_be_empty functionÆvar Arnfjörð Bjarmason, Jul 27, 2018
  72. Junio C HamanoJul 27, 2018
  73. SZEDER GáborJul 31, 2018
  74. t6018-rev-list-glob: fix 'empty stdin' testSZEDER Gábor, Aug 22, 2018
  75. Eric SunshineAug 22, 2018
  76. SZEDER GáborAug 22, 2018
  77. Eric SunshineAug 22, 2018
  78. Junio C HamanoAug 22, 2018
  79. Junio C HamanoAug 22, 2018
  80. Jeff KingAug 22, 2018
  81. rev-list: make empty --stdin not an errorJeff King, Aug 22, 2018
  82. Junio C HamanoAug 22, 2018
  83. Jeff KingAug 22, 2018
  84. Junio C HamanoAug 22, 2018
  85. Jeff KingAug 22, 2018
  86. Junio C HamanoAug 22, 2018
  87. 3/8 checkout.c: introduce an *_INIT macroÆvar Arnfjörð Bjarmason, Jun 5, 2018
  88. 2/8 checkout.h: wrap the arguments to unique_tracking_name()Ævar Arnfjörð Bjarmason, Jun 5, 2018
  89. 4/8 checkout.c: change "unique" member to "num_matches"Ævar Arnfjörð Bjarmason, Jun 5, 2018
  90. 6/8 builtin/checkout.c: use "ret" variable for returnÆvar Arnfjörð Bjarmason, Jun 5, 2018
  91. 7/8 checkout: add advice for ambiguous "checkout <branch>"Ævar Arnfjörð Bjarmason, Jun 5, 2018
  92. 8/8 checkout & worktree: introduce checkout.defaultRemoteÆvar Arnfjörð Bjarmason, Jun 5, 2018
  93. 5/8 checkout: pass the "num_matches" up to callersÆvar Arnfjörð Bjarmason, Jun 5, 2018
  94. Eric SunshineMay 4, 2018
  95. Eric SunshineMay 4, 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.