Closed worm2fed closed 11 months ago
I have the same issue and it's not clear to me why the git
invocation from the OCaml code does not use the global config.
I think this has to do with environment variables. Is there one that controls where git
should look for global .gitignore
?
For example, if I run env
, I can see lots of env variables in my setup:
$ env
SHELL=/bin/bash
WSL2_GUI_APPS_ENABLED=1
WSL_DISTRO_NAME=Ubuntu
NAME=ocaml-machine
PWD=/home/chshersh
LOGNAME=chshersh
MOTD_SHOWN=update-motd
HOME=/home/chshersh
LANG=C.UTF-8
Unfortunately, the environment is not passed automatically, so I'm passing relevant bits explicitly. Example here:
https://github.com/chshersh/zbg/blob/998403c52fb2083984404f90739cd18c26dd78be/lib/git.ml#L21-L27
Looks like I need to pass $HOME
directory to more git
commands 🤔
@chshersh global ignore is a param in a git config, so basically seems that you're right and root is the missing HOME variable.
To do this properly a consistently, I imagine having a global function git
that would take all git
arguments as an input parameter and will get the home_dir
before each invocation. After that, all calls to "git ..."
should be replaced with the usages of this function.
Implementing this refactoring is not on my top priority list but I'm happy to review the PR if anyone gives it a try 🙂
@chshersh I was about to push a PR with what you proposed but I wonder what harm there would be in specifying HOME
before each command executed via the Process
module? Here is the corresponding PR: https://github.com/chshersh/zbg/pull/32.
I attempted the refactoring you mentioned at first but this command eventually made me think twice. Not a simple git
call :-):
let is_rebase_in_progress () : bool =
let git_dirs = Process.proc_stdout "ls `git rev-parse --git-dir`" in
String.is_substring ~substring:"rebase" git_dirs
@etorreborre I see. Indeed, it turned out to be not that trivial 😅
I'm okay with adding HOME
before each command. I want to avoid seeing this HOME
prefix in the CLI output. But for now, I don't see any harm in adding it before each command.
For reference here is the other branch I started with a git
function. It was nice anyway to start writing my first OCaml lines of code :-).
Resolved by #32
Thanks again, @etorreborre!
@worm2fed, give it a try, the latest version from the main
branch should work 🙂
Now it's working! cool, thanks guys!
Seems like zbg do not take in account by global
.gitignore
fileTake a look
and