Title: untracked_files no longer detected · Issue #138 · gitpython-developers/GitPython · GitHub
Open Graph Title: untracked_files no longer detected · Issue #138 · gitpython-developers/GitPython
X Title: untracked_files no longer detected · Issue #138 · gitpython-developers/GitPython
Description: Hi, The output of git status is no longer in the format expected by python-git, in particular the Repo.untracked_files property parses the git status output expecting a: # Untracked files: while later versions of git droped the #, also t...
Open Graph Description: Hi, The output of git status is no longer in the format expected by python-git, in particular the Repo.untracked_files property parses the git status output expecting a: # Untracked files: while la...
X Description: Hi, The output of git status is no longer in the format expected by python-git, in particular the Repo.untracked_files property parses the git status output expecting a: # Untracked files: while la...
Opengraph URL: https://github.com/gitpython-developers/GitPython/issues/138
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"untracked_files no longer detected","articleBody":"Hi,\n\nThe output of git status is no longer in the format expected by python-git, in\nparticular the Repo.untracked_files property parses the git status output\nexpecting a:\n\n```\n# Untracked files:\n```\n\nwhile later versions of git droped the #, also there are some subtleties in\nthe management of the file names (avoid the use of replace and rstrip\nremoves spaces not only '\\n').\n\nHere is a patch that fixes the untracked_files property. There might be other parts affected by the change in the git output.\n\n```\ndiff -Naru python-git/git/repo/base.py python-git.new/git/repo/base.py\n--- python-git/git/repo/base.py 2011-07-05 21:50:02.000000000 +0200\n+++ python-git.new/git/repo/base.py 2014-02-23 17:54:32.157547255 +0100\n@@ -512,35 +512,33 @@\n return True\n # END untracked files\n return False\n- \n+\n @property\n def untracked_files(self):\n \"\"\"\n :return:\n list(str,...)\n- \n+\n Files currently untracked as they have not been staged yet. Paths \n are relative to the current working directory of the git command.\n- \n+\n :note:\n ignored files will not appear here, i.e. files mentioned in .gitignore\"\"\"\n # make sure we get all files, no only untracked directores\n- proc = self.git.status(untracked_files=True, as_process=True)\n- stream = iter(proc.stdout)\n+ proc = self.git.status(porcelain=True,\n+ untracked_files=True,\n+ as_process=True)\n+ # Untracked files preffix in porcelain mode\n+ preffix = \"?? \"\n untracked_files = list()\n- for line in stream:\n- if not line.startswith(\"# Untracked files:\"):\n+ for line in proc.stdout:\n+ if not line.startswith(preffix):\n continue\n- # skip two lines\n- stream.next()\n- stream.next()\n- \n- for untracked_info in stream:\n- if not untracked_info.startswith(\"#\\t\"):\n- break\n- untracked_files.append(untracked_info.replace(\"#\\t\", \"\").rstrip())\n- # END for each utracked info line\n- # END for each line\n+ filename = line[len(preffix):].rstrip('\\n')\n+ # Special characters are escaped\n+ if filename[0] == filename[-1] == '\"':\n+ filename = filename[1:-1].decode('string_escape')\n+ untracked_files.append(filename)\n return untracked_files\n\n @property\n```\n","author":{"url":"https://github.com/maxyz","@type":"Person","name":"maxyz"},"datePublished":"2014-02-23T17:05:33Z","url":"https://github.com/gitpython-developers/GitPython/issues/138"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:9c4fc9f3-26e4-0342-fcdd-ff8af9dd4301 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 98E0:683FF:98FAC5:C66A98:6B00E008 |
| html-safe-nonce | 62bf5d0ef37806f72e59499c1a8eab28cd3797101f6c1e59bfd38d8b2f7862cb |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OEUwOjY4M0ZGOjk4RkFDNTpDNjZBOTg6NkIwMEUwMDgiLCJ2aXNpdG9yX2lkIjoiMzg3MjA0MTc4NjU1MzcyMDg0MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 418d660ef033a13415577fde3f211178122d42745f228492b43645f8300aee7b |
| hovercard-subject-tag | issue:28122139 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/gitpython-developers/GitPython/138/issue_layout |
| twitter:image | https://opengraph.githubassets.com/56b24f9c9ff2dec01fd47074d82bae8f130c7bc7dd915ae2e0f42d9228f823ca/gitpython-developers/GitPython/issues/138 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/56b24f9c9ff2dec01fd47074d82bae8f130c7bc7dd915ae2e0f42d9228f823ca/gitpython-developers/GitPython/issues/138 |
| og:image:alt | Hi, The output of git status is no longer in the format expected by python-git, in particular the Repo.untracked_files property parses the git status output expecting a: # Untracked files: while la... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | maxyz |
| hostname | github.com |
| expected-hostname | github.com |
| None | 043c3f30fbcbe2c6c8e729e10cbbbc90c406546f9fbbb67c648d38f6b7d16daf |
| turbo-cache-control | no-preview |
| go-import | github.com/gitpython-developers/GitPython git https://github.com/gitpython-developers/GitPython.git |
| octolytics-dimension-user_id | 503709 |
| octolytics-dimension-user_login | gitpython-developers |
| octolytics-dimension-repository_id | 1126087 |
| octolytics-dimension-repository_nwo | gitpython-developers/GitPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1126087 |
| octolytics-dimension-repository_network_root_nwo | gitpython-developers/GitPython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 5425dc24e8bd8d6fca9641a12afc984825a43875 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width