2

I am having an issue where the output of git branch is empty without sudo. This applies to any git repo (at least all that I have tested), including new ones. I have tested this in zsh, bash3 and bash5, both with the bundled version of git and the Homebrew version. Interestingly, git checkout autocomplete (using git plugin of oh-my-zsh) still works as expected, as well as git branch --show-current.

I suspect a UNIX permission problem, but I cannot find any file or directory in .git/ that does not have -r--r--r-- permissions or higher, or that are not owned by current user.

oguz ismail
  • 1
  • 16
  • 47
  • 69
choffa
  • 51
  • 4
  • Try `git --no-pager branch` – phd Mar 30 '21 at 11:18
  • That worked? What..? – choffa Mar 30 '21 at 12:34
  • Seems like a broken pager. You need to investigate what's going on: what is your current pager and its configuration. – phd Mar 30 '21 at 12:45
  • Problem was indeed my pager, see my own answer below. Thanks! :D – choffa Mar 30 '21 at 12:51
  • What is a pager (is it like less?) and how do I find out if that's the problem and how do I fix it? – loco.loop Jul 07 '22 at 17:08
  • `less` is an example of a pager, yes. It is a program that takes an input and buffers it to the screen. If you have the same problem as me, then running the command in question with `--no-pager` as @phd suggest should work. To fix you must edit the git config – choffa Aug 02 '22 at 14:03

1 Answers1

2

The problem was a bad .gitconfig. I had the pager set to LESSCHARSET="UFT-8 less -RF. -F causes the pager to terminate when it hits EOF and less does not keep output after termination, causing the apparent empty output.

choffa
  • 51
  • 4
  • 2
    Add the `-X` option to your `less` command option set, so as to avoid using the init/deinit sequences; or switch to a Terminal emulator that doesn't use the Alternate Screen. See https://superuser.com/questions/134598/how-can-you-turn-off-alternate-screen-in-osxs-terminal-app (not the answer, just the question and its links). – torek Mar 30 '21 at 19:00