powerlevel10k icon indicating copy to clipboard operation
powerlevel10k copied to clipboard

Prompt git status wrong after git hook

Open Tyler-Keith-Thompson opened this issue 2 years ago • 6 comments

Hello! Long-time user, first time issue opener here :)

My auto-formatter seems to be messing with my prompt. I've got it set up with a git hook so it formats when I push and what I'm seeing is after the push the prompt gets tricked into thinking there are changes.

The good news is there's an easy fix, if I run git status the prompt gets the up-to-date information and quits showing me there are changes when there aren't.

Screenshot 2023-12-26 at 12 19 29 PM

Tyler-Keith-Thompson avatar Dec 26 '23 19:12 Tyler-Keith-Thompson

It's unlikely that I'll find time to debug this. Sorry.

romkatv avatar Jan 04 '24 10:01 romkatv

Same issue here, albeit I'm a new user and have huge number differences. image

Not sure if it's the theme or if my .git file is picking up other files?

PapaniaP avatar Jan 14 '24 00:01 PapaniaP

If you are experiencing the same issue, then the same "resolution" applies.

However, your comment has no indication that you are indeed experiencing the same issue. It could be https://github.com/romkatv/powerlevel10k/issues/2232#issuecomment-1478166292, which has a simple workaround.

romkatv avatar Jan 14 '24 06:01 romkatv

@Tyler-Keith-Thompson I don't have this issue with my Git Hooks. Can you share your Git Hook responsible for formatting? I can be wrong, but I suspect that you don't git add the file again after the formatting, which cause formatted files to not be added to the commit.

image

dragonis41 avatar Feb 13 '24 10:02 dragonis41

Nothing quite so simple I’m afraid. I didn’t screenshot it well but I did document that if I simply run git status my prompt becomes aware of what’s up.

to be fair, this hook looks like it’s trying to be awfully clever: https://github.com/hallettj/git-format-staged

Tyler-Keith-Thompson avatar Feb 13 '24 14:02 Tyler-Keith-Thompson

Oh, yes, it's not because of what I suspected then. Oh wow, that's a very big hook !

dragonis41 avatar Feb 13 '24 14:02 dragonis41