You are not logged in.

#1 2023-06-01 02:16:56

milojarow
Member
From: texas
Registered: 2014-06-07
Posts: 13

[SOLVED] From what file is git getting its format?

When run git diff as normal user terminal displays the diff info in some ugly format
But tried the same git diff as sudo and the output gets shown in a clean and pretty format.

Thing is, from where is git reading this display formats? Some says to check in /etc/gitconfig for the root format and ~/.config/gitconfig for the format displayed as user.

But I don't have an /etc/gitconfig neither a ~/.config/gitconfig.

Can someone put some light over me to find this file pls.

I've been reading git-scm documentation, it says you can see from where is git getting its configuration with this command:

git config --list --show-origin

but the output of that command its just my git username and git email. It says the location of the file git uses to know my username and email but that file doesn't contain any format specifications.

Here some screenshots so you can see the two formats displayed

+--------------+--------------+
|   scrot1     |     scrot2  |
+--------------+--------------+

Last edited by milojarow (2023-06-05 19:00:48)

Offline

#2 2023-06-01 03:54:53

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,471
Website

Re: [SOLVED] From what file is git getting its format?

Do "git config --list" and "sudo git config --list" show any differences?  If not, any difference is likely due to pager settings.  Compare "env" and "sudo env" for any pager-relevant settings (most obviously PAGER, but also any LESS* variables if "less" is PAGER).

Last edited by Trilby (2023-06-01 03:57:14)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2023-06-01 06:16:47

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,238

Re: [SOLVED] From what file is git getting its format?

some ugly format … clean and pretty format

Can you provide a more objective description (link screenshots…)

Online

#4 2023-06-03 00:36:11

milojarow
Member
From: texas
Registered: 2014-06-07
Posts: 13

Re: [SOLVED] From what file is git getting its format?

seth wrote:

some ugly format … clean and pretty format

Can you provide a more objective description (link screenshots…)


Here is the screenshot: click to see img

The terminal at the top (what I call the ugly format) is displaying the output of $git diff

While the terminal below (pretty one) is showing $sudo git diff

As you can see in the one below the terminal prompt is showing while in the first terminal seems like taking me to another screen inside the terminal if that makes sense.

Just take a look at the different formats displayed there, I would like to know from where is that being read.

Offline

#5 2023-06-03 01:19:15

milojarow
Member
From: texas
Registered: 2014-06-07
Posts: 13

Re: [SOLVED] From what file is git getting its format?

Trilby wrote:

Do "git config --list" and "sudo git config --list" show any differences?  If not, any difference is likely due to pager settings.  Compare "env" and "sudo env" for any pager-relevant settings (most obviously PAGER, but also any LESS* variables if "less" is PAGER).

This is the output: screenshot

The one above is user mode the one below root ($sudo git config --list)

===========================================================

This is the output of $git config --list --show-origin as normal user:

$git config --list --show-origin

file:/home/xxxx/.gitconfig      user.name@hush.com=name@hush.com
file:/home/xxxx/.gitconfig      user.xxxx=user
file:/home/xxxx/.gitconfig      user.email=name@hush.com
file:/home/xxxx/.gitconfig      user.name=user
file:.git/config        core.repositoryformatversion=0
file:.git/config        core.filemode=true
file:.git/config        core.bare=false
file:.git/config        core.logallrefupdates=true
file:.git/config        remote.origin.url=git@github.com:user/dotfiles.git
file:.git/config        remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
file:.git/config        branch.main.remote=origin
file:.git/config        branch.main.merge=refs/heads/main
~
~

This is the one as root

$ sudo git config --list --show-origin

file:/root/.gitconfig   user.email=name@hush.com
file:/root/.gitconfig   user.name=user
file:.git/config        core.repositoryformatversion=0
file:.git/config        core.filemode=true
file:.git/config        core.bare=false
file:.git/config        core.logallrefupdates=true
file:.git/config        remote.origin.url=git@github.com:user/dotfiles.git
file:.git/config        remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
file:.git/config        branch.main.remote=origin
file:.git/config        branch.main.merge=refs/heads/main

As you can see it references some files, this is the content of those files:

$cat /home/xxxx/.gitconfig

[user "name@hush"]
	com = name@hush.com
[user]
	xxxx = user
[user]
	email = name@hush.com
	name = user
#cat /root/.gitconfig

[user]
	email = name@hush.com
	name = user

The file: $cat ~/.git/config contains just the core, remote and branch info, there's no format defining code.

/root/.git/config doesn't exist.

There's no code defining format in those files, so the question remains, from where is git reading the format?.

Last edited by milojarow (2023-06-03 01:32:06)

Offline

#6 2023-06-03 01:30:15

skunktrader
Member
From: Brisbane, Australia
Registered: 2010-02-14
Posts: 1,676

Re: [SOLVED] From what file is git getting its format?

Perhaps your terminal is getting different environment variables depending on user / root

Offline

#7 2023-06-03 01:38:12

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,471
Website

Re: [SOLVED] From what file is git getting its format?

That's just differences in the terminal / pager and not at all related to git itself.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#8 2023-06-03 02:11:23

milojarow
Member
From: texas
Registered: 2014-06-07
Posts: 13

Re: [SOLVED] From what file is git getting its format?

skunktrader wrote:

Perhaps your terminal is getting different environment variables depending on user / root

Do you mean this?

User env

[user@host] $ env

SHELL=/bin/bash
WINDOWID=54525954
COLORTERM=truecolor
LESS=-M
HISTCONTROL=ignoreboth
_ZO_MAXAGE=1000
SSH_AUTH_SOCK=/home/user/.ssh/ssh_auth_sock
SSH_AGENT_PID=492
_ZO_RESOLVE_SYMLINKS=1
EDITOR=vim
XDG_SEAT=seat0
PWD=/home/user
LOGNAME=user
XDG_SESSION_TYPE=tty
SYSTEMD_EXEC_PID=406
XAUTHORITY=/home/user/.Xauthority
WINDOWPATH=1
MOTD_SHOWN=pam
HOME=/home/user
LANG=en_US.UTF-8
_JAVA_AWT_WM_NONREPARENTING=1
XDG_CURRENT_DESKTOP=LeftWM
STARSHIP_SHELL=bash
CLICOLOR=1
_ZO_ECHO=1
INVOCATION_ID=26178a1e88274db98d7b45d8c1f60a7b
STARSHIP_SESSION_KEY=1072522450646228
_ZO_DATA_DIR=/home/user/.local/share
ALACRITTY_SOCKET=/run/user/1000/Alacritty-:0-18035.sock
XDG_SESSION_CLASS=user
TERM=xterm-256color
USER=user
VISUAL=vim
DISPLAY=:0
SHLVL=2
XDG_VTNR=1
XDG_SESSION_ID=1
_ZO_EXCLUDE_DIRS=/home/user
XDG_RUNTIME_DIR=/run/user/1000
DEBUGINFOD_URLS=https://debuginfod.archlinux.org
GCC_COLORS=error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01
PATH=/home/user/.scripts:/home/user/.scripts:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/opt/rocm-5.4.3/bin:/opt/rocm-5.4.3/hip/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/usr/lib/rustup/bin
ALACRITTY_LOG=/tmp/Alacritty-18035.log
DBUS_SESSION_BUS_ADDRESS=unix:path=/tmp/dbus-H6t8Ke9JID,guid=fa59f58d77ca52fddb6ae784647a1641
MAIL=/var/spool/mail/user
ALACRITTY_WINDOW_ID=54525954
_=/usr/bin/env


Root env

[root@host] # env

SHELL=/bin/bash
WINDOWID=65011714
COLORTERM=truecolor
LESS=-M
HISTCONTROL=ignoreboth
_ZO_MAXAGE=1000
SSH_AUTH_SOCK=/home/user/.ssh/ssh_auth_sock
SSH_AGENT_PID=492
_ZO_RESOLVE_SYMLINKS=1
EDITOR=vim
XDG_SEAT=seat0
PWD=/home/user
LOGNAME=user
XDG_SESSION_TYPE=tty
SYSTEMD_EXEC_PID=406
XAUTHORITY=/home/user/.Xauthority
WINDOWPATH=1
MOTD_SHOWN=pam
HOME=/root
LANG=en_US.UTF-8
_JAVA_AWT_WM_NONREPARENTING=1
XDG_CURRENT_DESKTOP=LeftWM
STARSHIP_SHELL=bash
CLICOLOR=1
_ZO_ECHO=1
INVOCATION_ID=26178a1e88274db98d7b45d8c1f60a7b
STARSHIP_SESSION_KEY=1823918458167198
_ZO_DATA_DIR=/home/user/.local/share
ALACRITTY_SOCKET=/run/user/1000/Alacritty-:0-18150.sock
XDG_SESSION_CLASS=user
TERM=xterm-256color
USER=user
VISUAL=vim
DISPLAY=:0
SHLVL=4
XDG_VTNR=1
XDG_SESSION_ID=1
_ZO_EXCLUDE_DIRS=/home/user
XDG_RUNTIME_DIR=/run/user/1000
DEBUGINFOD_URLS=https://debuginfod.archlinux.org
GCC_COLORS=error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01
PATH=/home/user/.scripts:/home/user/.scripts:/home/user/.scripts:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/opt/rocm-5.4.3/bin:/opt/rocm-5.4.3/hip/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/usr/lib/rustup/bin
ALACRITTY_LOG=/tmp/Alacritty-18150.log
DBUS_SESSION_BUS_ADDRESS=unix:path=/tmp/dbus-H6t8Ke9JID,guid=fa59f58d77ca52fddb6ae784647a1641
MAIL=/var/spool/mail/user
ALACRITTY_WINDOW_ID=65011714
_=/usr/bin/env

The only difference I see is in $SHLVL

Offline

#9 2023-06-03 02:17:42

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,471
Website

Re: [SOLVED] From what file is git getting its format?

There are quite a few differences in PATH too which may be relevant again depend on the pager in use which I think defaults to less  - from each session (user and root):

type less

I'd guess you have a non-standard or aliased less in one of the environments.  Notably, you set LESS in both environments and exclude the -R flag, so really it should be "ugly" in both conditions if there were not some other difference on top of this.

You could also confirm that this is at least the right track to follow by testing the following in each session:

LESS=-FRX git diff

Last edited by Trilby (2023-06-03 02:22:04)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#10 2023-06-03 06:15:15

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,238

Re: [SOLVED] From what file is git getting its format?

The "root" env also has "XDG_RUNTIME_DIR=/run/user/1000", so that was probably an environment preserving sudo/su
=> Most likely the bogus $LESS variable is really the only problem.

On a sidenote:

DBUS_SESSION_BUS_ADDRESS=unix:path=/tmp/dbus-H6t8Ke9JID,guid=fa59f58d77ca52fddb6ae784647a1641

Looks like you're using dbus-launch and/or your session script (xinitrc?) is broken, last link below.

Online

#11 2023-06-05 19:00:29

milojarow
Member
From: texas
Registered: 2014-06-07
Posts: 13

Re: [SOLVED] From what file is git getting its format?

Trilby wrote:

There are quite a few differences in PATH too which may be relevant again depend on the pager in use which I think defaults to less  - from each session (user and root):

type less

I'd guess you have a non-standard or aliased less in one of the environments.  Notably, you set LESS in both environments and exclude the -R flag, so really it should be "ugly" in both conditions if there were not some other difference on top of this.

You could also confirm that this is at least the right track to follow by testing the following in each session:

LESS=-FRX git diff

Parrot-san this did it. Now I'm getting the 'pretty' output even when running command as regular user.

I'm amazed how you where able to deduct that just from seeing the env output of user and root.

I'm still a noob, right now I'm looking info about LESS to get an idea of what the heck is happening here.

Solution:
I defined LESS=-FRX in my .bashrc

Offline

#12 2023-06-05 19:07:57

milojarow
Member
From: texas
Registered: 2014-06-07
Posts: 13

Re: [SOLVED] From what file is git getting its format?

seth wrote:

The "root" env also has "XDG_RUNTIME_DIR=/run/user/1000", so that was probably an environment preserving sudo/su
=> Most likely the bogus $LESS variable is really the only problem.

On a sidenote:

DBUS_SESSION_BUS_ADDRESS=unix:path=/tmp/dbus-H6t8Ke9JID,guid=fa59f58d77ca52fddb6ae784647a1641

Looks like you're using dbus-launch and/or your session script (xinitrc?) is broken, last link below.


Incredible how you can get all that info by looking at the env output.

I need to train to one day have the eyes you guys have.

Thanks Seth and Trilby.

P.S.
about that .xinit being broken, I'll look into it

Offline

Board footer

Powered by FluxBB