Skip to content

Core lib/git.zsh depends on current_branch() from git plugin #4085

Closed
@apjanke

Description

Some of the theme-related functions defined in lib/git.zsh call current_branch. But current_branch is only defined in the git plugin. So if that plugin is not loaded, themes which use these functions will produce an error like git_prompt_ahead:1: command not found: current_branch each time the prompt is issued.

Functions affected:

  • git_prompt_ahead()
  • git_prompt_behind()
  • git_prompt_remote()

Themes affected:

➜  .oh-my-zsh git:(master) egrep -r -l 'git_prompt_(ahead|behind|remote)' themes/*
themes/juanghurtado.zsh-theme
themes/sunrise.zsh-theme
themes/wedisagree.zsh-theme
➜  .oh-my-zsh git:(master) grep -rl current_branch themes/*
themes/eastwood.zsh-theme
themes/gallois.zsh-theme
themes/josh.zsh-theme
themes/juanghurtado.zsh-theme
themes/mortalscumbag.zsh-theme
themes/peepcode.zsh-theme
themes/sunrise.zsh-theme

I don't think the core stuff should depend on plugins, or at least, it should be an optional, declared dependency.

Workaround is to load the git plugin. Easy enough, but I don't think it should be required.

The current_branch() function definition should probably be moved from the git plugin to the core lib/git.zsh to remove this plugin dependency. Possibly, it should be renamed (e.g. to git_current_branch) to make it clear that it's for Git and not Mercurial or Bazaar or whatever, and a current_branch back-compatibility wrapper left in the git plugin.

Caused #4059.
Caused #4084.
Probably caused #2193.
Caused #331.
Caused by #329, in part.
Caused by #2723 (in #3809).

Fixed by #2386, I think, but that PR has a lot of other stuff going on, too, and has been sitting for 18 months without getting merged. Should probably do a smaller, easier-to-review patch to fix this issue independently.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions