GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add way to get only topmost untracked folders/files · gitpython-developers/GitPython · Discussion #1150

Add way to get only topmost untracked folders/files #1150

Answered by BeayemX
BeayemX asked this question in Q&A
Add way to get only topmost untracked folders/files #1150
@BeayemX BeayemX
Mar 8, 2020 · 2 comments · 1 reply
Answered by BeayemX Return to top
Discussion options
  • Uh oh!

    There was an error while loading. Please reload this page.

BeayemX
Mar 8, 2020

Let's say I have a new folder with three new files in it.

When I use git status it will show like this:

MyProject/New Folder/

But when I use GitPython's repo.untracked_files it will show like this:

MyProject/New Folder/file_a.txt
MyProject/New Folder/file_b.txt
MyProject/New Folder/file_c.txt

Is there a way to get the same result as the git status version?

You must be logged in to vote
All reactions
Answered by BeayemX Mar 8, 2020

Hello, thanks for the response.

For the time being I Implemented a workaround that calls git directly.
I am not sure if this is useful for you, but here is the code:

import subprocess
command = ["git", "ls-files", "--others", "--directory", "--exclude-standard", "--no-empty-directory"]
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
untracked_files_and_folders = [u.decode().strip() for u in process.stdout]
View full answer

Replies: 2 comments · 1 reply

Comment options
  • Uh oh!

    There was an error while loading. Please reload this page.

Byron
Mar 8, 2020
Maintainer

Indeed it would be nice to have additional options to make GitPython more like 'porcelain', and less like the 'plumbing' it was intended to be.

The recommended action is to transform the returned set of untracked files into the form that Git provides. This algorithm could potentially be donated back to GitPython, which supports it using an additional function, maybe along the line of repo.status.

Thanks for understanding that GitPython is in maintenance mode and thus is hesitant to take on feature requests unless they are accompanied by a PR implementing them.

Please feel free to comment on the closed issue if there are any follow-up questions.

You must be logged in to vote
All reactions
0 replies
Comment options
  • Uh oh!

    There was an error while loading. Please reload this page.

BeayemX
Mar 8, 2020
Author

Hello, thanks for the response.

For the time being I Implemented a workaround that calls git directly.
I am not sure if this is useful for you, but here is the code:

import subprocess
command = ["git", "ls-files", "--others", "--directory", "--exclude-standard", "--no-empty-directory"]
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
untracked_files_and_folders = [u.decode().strip() for u in process.stdout]
You must be logged in to vote
All reactions
  • 👍 2
1 reply
@Anton-V-K
Comment options
  • Uh oh!

    There was an error while loading. Please reload this page.

Anton-V-K Jun 11, 2024

repo.git.ls_files("--others", "--directory", "--exclude-standard", "--no-empty-directory") may also help same way

All reactions
Answer selected by Byron
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
3 participants
@BeayemX @Byron @Anton-V-K
Converted from issue

This discussion was converted from issue #996 on February 26, 2021 11:18.

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.