Skip to content

git status porcelain output should include remote details #1715

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
shiftkey opened this issue Jun 11, 2018 · 9 comments
Closed

git status porcelain output should include remote details #1715

shiftkey opened this issue Jun 11, 2018 · 9 comments
Assignees

Comments

@shiftkey
Copy link

This isn't a defect but is instead an opportunity to improve Git for scripting scenarios.

In Git 2.16 git for-each-ref learned about how to list upstream and push information - for when a local branch is tracking a remote branch:

* The "--format=..." option "git for-each-ref" takes learned to show
the name of the 'remote' repository and the ref at the remote side
that is affected for 'upstream' and 'push' via "%(push:remotename)"
and friends.

An example of this:

$ git for-each-ref --format="'%(refname)' -> '%(upstream:remotename) %(upstream:lstrip=3)'" refs/heads/
'refs/heads/add-permissions-hash-for-repository' -> ' '
'refs/heads/add-support-for-previewing-svgs' -> ' '
'refs/heads/another-minification-bug' -> 'origin another-minification-bug'
'refs/heads/b-b-b-banner' -> 'origin b-b-b-banner'
'refs/heads/beta-link-to-release-notes-works' -> ' '
'refs/heads/buffer-rule' -> ' '
'refs/heads/bump-for-new-git-lfs' -> 'origin bump-for-new-git-lfs'
'refs/heads/catch-errors-betterer' -> 'origin catch-errors-betterer'
'refs/heads/config-shows-untracked-files' -> ' '
'refs/heads/contributor-stats' -> 'origin contributor-stats'
'refs/heads/database-field-naming' -> 'origin database-field-naming'
'refs/heads/defer-remote-detection-to-dialog' -> 'origin defer-remote-detection-to-dialog'
'refs/heads/detect-bare-repository' -> ' '
'refs/heads/docs-about-labels' -> ' '
'refs/heads/document-discard-changes' -> 'origin document-discard-changes'
'refs/heads/drop-back-to-classic-api' -> 'origin drop-back-to-classic-api'
'refs/heads/dynamically-stylable-svg' -> 'OiYouYeahYou dynamically-stylable-svg'
'refs/heads/encodings-as-a-first-class-thing' -> ' '
'refs/heads/experimental-ssh-setup' -> 'origin experimental-ssh-setup'
'refs/heads/extract-settings-into-own-store' -> ' '
...

This means we can handle scenarios where users have a / in their remote name - it's not something that users often do, but it's something that we should be able to handle when working with Git repositories.

One place related to this is git status - it has a way to emit the ahead/behind information for-free alongside seeing what's changed in your directory:

$ git status --porcelain=2 --branch
# branch.oid 2b111155914cb44824b39ee197deed23bb825a1a
# branch.head master
# branch.upstream origin/master
# branch.ab +0 -0

It'd be nice to be able to emit these new values from (I talked about this with @dscho a while ago and he indicated this should be a new version of the porcelain format for backwards compatibility reasons):

$ git status --porcelain=3 --branch
# branch.oid 2b111155914cb44824b39ee197deed23bb825a1a
# branch.head master
# upstream.remote origin
# upstream.branch master
# branch.ab +0 -0
@nocnokneo
Copy link

label:enhancement?

@dscho
Copy link
Member

dscho commented Feb 27, 2019

@shiftkey do you have any cycles to spare to work on this? I could assist, but sadly I won't find the time to work on this any time soon...

@shiftkey
Copy link
Author

@dscho no problem. I've been mulling this over again recently to take it further than just adding upstream.remote, and I need to do a brain dump of that and the motivations behind it. Maybe next month I'll have some time to spike getting this working.

@dscho
Copy link
Member

dscho commented Feb 27, 2019

@shiftkey we could also just add it to the ideas for Outreachy/Google Summer of Code...

@shiftkey
Copy link
Author

@dscho my elevator pitch:

git status provides some human-friendly context that isn't easily accessible to tools that prefer the porcelain output. One example is when the repository is in the middle of a rebase and the user needs to resolve conflicts:

$ git status
rebase in progress; onto 191dbf5
You are currently rebasing branch '2-simple-rebase-conflict-target-branch' on '191dbf5'.
 (fix conflicts and then run "git rebase --continue")
 (use "git rebase --skip" to skip this patch)
 (use "git rebase --abort" to check out the original branch)

Unmerged paths:
 (use "git reset HEAD <file>..." to unstage)
 (use "git add <file>..." to mark resolution)

  both added:      2-simple-rebase-conflict/LICENSE.md

no changes added to commit (use "git add" and/or "git commit -a")

versus the output with --porcelain and --branch:

$ git status --porcelain=2 --branch
# branch.oid 191dbf58f8b005cb36517b4c89198e58176e7b9b
# branch.head (detached)
u AA N... 000000 100644 100644 100644 0000000000000000000000000000000000000000 92e1d113360ed6e6c50b7187fd4be008ee855f48 a612ad9813b006ce81d1ee438dd784da99a54007 2-simple-rebase-conflict/LICENSE.md

In particular the details in the header of the rebase details

rebase in progress; onto 191dbf5
You are currently rebasing branch '2-simple-rebase-conflict-target-branch' on '191dbf5'.

One can cobble together these pieces if you know where to look inside .git but this feels like a more natural fit for the porcelain of Git

I haven't thought much about what this would look like, but I'm happy to ponder on this more and submit it wherever you think fits best.

@dscho
Copy link
Member

dscho commented Feb 28, 2019

@shiftkey why not just add that elevator pitch? It might be a good idea for the person who picks up that project to decide upon the details of the implementation.

@dscho
Copy link
Member

dscho commented Oct 13, 2019

In the meantime, somebody gave me the idea to open up https://github.com/gitgitgadget/git/issues for ideas like this (in particular non-Windows-specific ones). It does seem as if volunteers show up occasionally, plucking off some tickets here and there.

@shiftkey how about closing this here ticket and opening a fresh one over there, leading with your elevator pitch?

@dscho
Copy link
Member

dscho commented Oct 15, 2021

Closing this as stale.

@dscho dscho closed this as completed Oct 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants