romkatv/powerlevel10k

Doesn't play nicely with a single remote using two distinct push- and fetch- urls

Closed this issue · 0 comments

I'm running into some issue whereby p10k doesn't quite give me the "drifts" (in terms of the number of commits ahead and behind) from both the push- and the fetch-remotes at the same time.

I'm not too certain what the most adequate terminology is here, but I'm actually just talking about a single remote, with two different endpoints for fetching and pulling.

--

Okay, forget about the above, it's not a Powerlevel10k issue, it's a user issue. Nonetheless, since @romkatv may know about it, I'll leave this open for a few days, but I'm fully aware I'm hoping for some personal assistance regarding a project that's not Powerlevel10k...

How does one go about having at any time an accurate ahead-behind "drift" tally of one's current HEAD against its tracked counterpart at a single remote that specifies two distinct fetch and push URLs?

I mean "a single remote" as far as git remote is concerned; I'm actually talking about two separate repositories hosted on GitHub in this example. For the record, I tried earlier this year with some remotes also belonging on my physical drive, just for sport/exploration, and the behaviour was the same.

What I'm doing:

Here I set up a local clone of your (excellent) project, and ensure my own fork of it is perfectly in sync (with push --force).
I then create a commit for myself and publish it to my fork.

mkdir test && cd test
git init
git remote add upstream git@github.com:romkatv/powerlevel10k
git remote set-url --push upstream git@github.com:ccjmne/powerlevel10k
git fetch --set-upstream upstream master
git checkout master
git push upstream --force
echo beep > boop && git add boop && git commit --message DONTMERGEME && git push upstream

I'm now in sync with the push remote, and ahead by 1 of the fetch one.
However, the rev-list doesn't seem to make the distinction between @{upstream} and @{push}...
Note that it shows that HEAD corresponds to master as well as upstream/master.

> git remote -vvv
upstream        git@github.com:romkatv/powerlevel10k (fetch)
upstream        git@github.com:ccjmne/powerlevel10k (push)
> git branch -vvv
* master 0c70b1db [upstream/master] DONTMERGEME
> git log -1
commit 0c70b1dbff6310559435c620b0c78bf84b2b3609 (HEAD -> master, upstream/master)
Author: Éric NICOLAS <ccjmne@gmail.com>
Date:   Tue Dec 3 23:05:04 2024 +0100

    DONTMERGEME
> git rev-list --left-right --count ...@{upstream}
0       0
> git rev-list --left-right --count ...@{push}
0       0

I'll fetch again (from upstream) (oh yeah, I name my remote upstream by default; I started quite some time before it became the de-facto name for the "remote you originally forked", and I stuck with it 'cause I don't often end up having to explain myself ;) ).

HEAD now corresponds to master but not upstream/master anymore.
I still am, in reality, in sync with my fork and ahead of upstream@{fetch} (it's not valid syntax, but let's call it that nonetheless) by 1, but rev-list makes no distinction still.

> git fetch
> git log -1
commit 0c70b1dbff6310559435c620b0c78bf84b2b3609 (HEAD -> master)
Author: Éric NICOLAS <ccjmne@gmail.com>
Date:   Tue Dec 3 23:05:04 2024 +0100

    DONTMERGEME
> git rev-list --left-right --count ...@{upstream}
1       0
> git rev-list --left-right --count ...@{push}
1       0

I can fetch from upstream@{push} and nothing effectively changes (but the FETCH_HEAD):

> git fetch $(git remote get-url --push upstream)
From github.com:ccjmne/powerlevel10k
 * branch              HEAD       -> FETCH_HEAD
> git rev-list --left-right --count ...@{upstream}
1       0
> git rev-list --left-right --count ...@{push}
1       0

Crucially, pushing to the upstream@{push} actually resets my state and Git now believes again that I am in sync with... both @{fetch} and @{push}:

> git push upstream
Everything up-to-date
> git rev-list --left-right --count ...@{upstream}
0       0
> git rev-list --left-right --count ...@{push}
0       0

Do you have any idea what I'm doing wrong?
It's been bugging me in the past and I figured I'd just "deal with it later" and/or use several remotes...

But I see that it's supposed to be able to work just fine:
https://github.com/romkatv/powerlevel10k?tab=readme-ov-file#what-do-different-symbols-in-git-status-mean

Does it really work on your end? Do you have any idea what I'm doing wrong?

My set-up:

I cleaned up my .zshrc, here's all it contains as I conduct these tests:

if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
  source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi

[[ -d /usr/share/zsh-theme-powerlevel10k ]] && source /usr/share/zsh-theme-powerlevel10k/powerlevel10k.zsh-theme
[[ -f "$ZDOTDIR/.p10k.zsh" ]]               && source "$ZDOTDIR/.p10k.zsh"

# I kinda need this in order to even breathe, but it's irrelevant to the issue I'm facing
if [[ -n "$SSH_AGENT_PID" && -e "/proc/$SSH_AGENT_PID" ]]; then
  systemctl --user disable --now ssh-agent
  systemctl --user enable  --now gpg-agent
fi
if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then
  export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
fi
export GPG_TTY=$TTY
gpg-connect-agent updatestartuptty /bye > /dev/null
>  git config --list
user.email=ccjmne@gmail.com
user.name=Éric NICOLAS
user.signingkey=9B49C8C163B3320C!
core.editor=nvim +'set filetype=gitcommit textwidth=72 spell' +'normal $'
core.pager=less -SFX -x2
core.excludesfile=/home/ccjmne/.config/.gitignore-global
sequence.editor=nvim +'set filetype=gitrebase'
commit.gpgsign=true
diff.wserrorhighlight=all
checkout.defaultremote=upstream
clone.defaultremotename=upstream
init.defaultbranch=master
gpg.program=gpg2

Versions:

  • Powerlevel10k: current latest state from GitHub
  • Git: 2.47.1 (latest, published last week)

--

I did search the Web a bit—multiple times across several years, in fact—but I'm sure you can tell how bad the results would be when you start typing about "git issue push remote fetch" into any search engine that tries to be smart about providing you with links to places that see a lot of activity rather than somehow understanding precisely which semi-arcane feature you mean to talk about, of the VCS that a large majority of people just end up fighting to get their "change button colour" not revert their colleague's "implement button functionality".

I would love to get your support here, but I entirely understand that this is not at all what you signed up for when you set out to deliver this project to the world, and I don't expect anything :)

If you have an idea where this sort of question is best asked, please don't hesitate to redirect me to the right place.
In any case, I'll close this issue by the end of the week so as to not make it seem like there's a pending task/issue here.

Cheers, and thank you for your dedication to delivering an uncompromisingly efficient suite of tools—a lot of alternatives just don't cut it, despite having tried pretty hard to switch to something I could hack away at in a programming language rather than a shell-scripting one.