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

Re: The git spring cleanup challenge

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Jun 3, 2021, 12:18 UTC
Message-ID
<87zgw75dyi.fsf@evledraar.gmail.com>
In-Reply-To
<60b8a98d11d7c_1a0a2d20856@natae.notmuch>
On Thu, Jun 03 2021, Felipe Contreras wrote:
Show 112 quoted lines
> Ævar Arnfjörð Bjarmason wrote:
>> 
>> On Tue, Jun 01 2021, Felipe Contreras wrote:
>> 
>> > Đoàn Trần Công Danh wrote:
>> >> On 2021-06-01 05:48:41-0500, Felipe Contreras <felipe.contreras@gmail.com> wrote:
>> >> > > How about alias? It's part of my muscle memory.
>> >> > 
>> >> > No aliases.
>> >> > 
>> >> > If a new user doesn't have them, neither should you.
>> >> > 
>> >> > All VCSs have default aliases, and I advocated for git to do the same
>> >> > [1], but it wasn't accepted.
>> >> > 
>> >> > The whole point is to suffer like them.
>> >> 
>> >> Get back to the alias topic.
>> >> I also agree with other people's opinion in that thread.
>> >> IOW, I support the decision to not accept those default alias ;)
>> >
>> > Why?
>> >
>> >> It's not required to be different people to have alias defined to
>> >> different command. I have alias conditionally defined to different
>> >> command based on git-dir. For example, I had ci alias to "commit" by
>> >> default, and "commit -s" on other repositories.
>> >
>> > So? They would still work.
>> >
>> >> So, Git decides alias for me will not only break my current alias, but
>> >> also break my conditional alias.
>> >
>> > No it wouldn't. They are *default* aliases, not overriding aliases. They
>> > would be used only if you haven't set the same alias yourself.
>> >
>> > Try it.
>> >
>> > --- a/alias.c
>> > +++ b/alias.c
>> > @@ -28,13 +28,27 @@ static int config_alias_cb(const char *key, const char *value, void *d)
>> >         return 0;
>> >  }
>> >  
>> > +struct config_alias_data default_aliases[] = {
>> > +       { "co", "checkout" },
>> > +       { "ci", "checkout" },
>> > +       { "rb", "rebase" },
>> > +       { "st", "status" },
>> > +};
>> > +
>> >  char *alias_lookup(const char *alias)
>> >  {
>> >         struct config_alias_data data = { alias, NULL };
>> > +       int i;
>> >  
>> >         read_early_config(config_alias_cb, &data);
>> > +       if (data.v)
>> > +               return data.v;
>> > +       for (i = 0; i < ARRAY_SIZE(default_aliases); i++) {
>> > +               if (!strcmp(alias, default_aliases[i].alias))
>> > +                       return xstrdup(default_aliases[i].v);
>> > +       }
>> >  
>> > -       return data.v;
>> > +       return NULL;
>> >  }
>> >  
>> >  void list_aliases(struct string_list *list)
>> >
>> >
>> >> Anyway, remotes/branches are all configuration values.
>> >> Would you prefer:
>> >
>> > I meant global configurations. If it's a per-repository setting surely
>> > it wouldn't be something amenable for the Git project to set as default.
>> 
>> I agree with this batteries included sentiment, but would very much like
>> to not see this as hardcoding of ours, but us shipping optional config
>> files to be included.
>
> The problem with optional config files is that you can't standardize
> that way.
>
> If hard-coded default aliases they can be included in the documentation.
>
> Pluse we all start to typing similar commands, instead of each having
> completely different alias to the next.
>
> For example in 3 days of doing this experiment I've typed 'g c'
> countless of times (alias for `commit -v`). I added an alias for `ci`
> instead, since that what other VCSs use, like Mercurial. But I don't
> think `ci` makes sense for commit. It would be better if `co` was
> available, but then checkout needs another alias.
>
> If we could replace checkout with switch, then we could have an alias
> `sw` for switch, and another `co` for commit.
>
> But that requires that switch is actually usable (it isn't for me right
> now).
>
> This increases the urgency to fix `git switch` for me. If other
> developers were trying the same aliases they might see the same issues.
>
>> We could then just extend the include syntax rather easily to include
>> "libraries", which would be like the current include.path, but would
>> understand a library:: prefix (better name bikeshedding welcome). We'd
>> then just ship these in /usr/share/git-core/config/includes or whatever,
>> e.g. /usr/share/git-core/config/includes/aliases/svn-like.cfg
>
> I wouldn't be against some some suggested defaults, but *in addition* to
> some hardcoded default aliases that are documented.

I'm talking about in terms of the flexibility of implementation of on-by-default defaults. We could implement it as I suggested and then just have a core.defaultIncludes, which would by default be set to git::aliases/svn-like.cfg or whatever, i.e. equivalent to:

    [core]
    defaultIncludes = "git::default.cfg"

Which itself would include a /usr/share/git-core/config/includes/default.cfg which would do:

    [include]
    path = "git::aliases/svn-like.cfg"
    paht = <some other default file>

So it would work out of the box on a vanilla git install, you could then in ~/.gitconfig or whatever set:

    [core]
    defaultIncludes = false

Or whatever, which we'd check for early with repo_config_get_bool() (see repo-settings.c).

So you'd have an out from these optional vanilla includes. Then to address the concern in [1] we could (sans the user-diff specific limitations in that thread) treat the default userdiff "config" this way and (optionally) slurp these up into a generated *.c file at build-time.

In a way this is total bikeshedding, I just think it's worth doing it this way up-front.

It gives you a lot more flexibility than hardcoding these in the source somewhere. It becomes easy e.g. to have multiple "default" variants, so feature.experimental or whatever could give you early opt-in to new aliases, or the other way around of new versions maintaining compatibility with older style invocations via aliases.

1. https://lore.kernel.org/git/87czvoowg2.fsf@evledraar.gmail.com/
Previous: Sergey OrganovNext: Felipe Contreras
Message 15 of 55 in “The git spring cleanup challenge”
  1. Felipe ContrerasJun 1, 2021
  2. AndyJun 1, 2021
  3. Felipe ContrerasJun 1, 2021
  4. Đoàn Trần Công DanhJun 1, 2021
  5. Felipe ContrerasJun 1, 2021
  6. Đoàn Trần Công DanhJun 1, 2021
  7. Felipe ContrerasJun 1, 2021
  8. Đoàn Trần Công DanhJun 1, 2021
  9. Felipe ContrerasJun 1, 2021
  10. Đoàn Trần Công DanhJun 2, 2021
  11. Felipe ContrerasJun 2, 2021
  12. Ævar Arnfjörð BjarmasonJun 3, 2021
  13. Felipe ContrerasJun 3, 2021
  14. Sergey OrganovJun 3, 2021
  15. Ævar Arnfjörð BjarmasonJun 3, 2021
  16. Felipe ContrerasJul 2, 2021
  17. Ævar Arnfjörð BjarmasonJul 2, 2021
  18. Felipe ContrerasJul 2, 2021
  19. David AguilarJun 1, 2021
  20. Junio C HamanoJun 1, 2021
  21. Junio C HamanoJun 1, 2021
  22. Felipe ContrerasJun 1, 2021
  23. Johannes SixtJun 2, 2021
  24. Felipe ContrerasJun 2, 2021
  25. Junio C HamanoJun 2, 2021
  26. Felipe ContrerasJun 2, 2021
  27. Đoàn Trần Công DanhJun 2, 2021
  28. Johannes SixtJun 2, 2021
  29. Felipe ContrerasJun 1, 2021
  30. Sergey OrganovJun 2, 2021
  31. Junio C HamanoJun 3, 2021
  32. Sergey OrganovJun 3, 2021
  33. Sergey OrganovJun 1, 2021
  34. Felipe ContrerasJun 1, 2021
  35. Sergey OrganovJun 2, 2021
  36. Felipe ContrerasJun 2, 2021
  37. Sergey OrganovJun 2, 2021
  38. Felipe ContrerasJun 2, 2021
  39. Sergey OrganovJun 2, 2021
  40. Junio C HamanoJun 3, 2021
  41. Felipe ContrerasJun 3, 2021
  42. Elijah NewrenJun 3, 2021
  43. Felipe ContrerasJun 3, 2021
  44. Elijah NewrenJun 3, 2021
  45. Felipe ContrerasJun 3, 2021
  46. Sergey OrganovJun 3, 2021
  47. Bagas SanjayaJun 2, 2021
  48. Felipe ContrerasJun 2, 2021
  49. Ævar Arnfjörð BjarmasonJun 3, 2021
  50. Felipe ContrerasJun 3, 2021
  51. Ævar Arnfjörð BjarmasonJun 3, 2021
  52. Phillip WoodJun 3, 2021
  53. Ævar Arnfjörð BjarmasonJun 3, 2021
  54. Phillip WoodJun 4, 2021
  55. Felipe ContrerasJun 3, 2021

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.