René's URL Explorer Experiment


Title: GitCommand missing stderr · Issue #1221 · gitpython-developers/GitPython · GitHub

Open Graph Title: GitCommand missing stderr · Issue #1221 · gitpython-developers/GitPython

X Title: GitCommand missing stderr · Issue #1221 · gitpython-developers/GitPython

Description: With GitPython 3.1.14 GitCommandError, for failed clones would pass on the captured stderr output into its stderr attribute. With 3.1.15 this contains the empty string instead. This was caught by this unit test: https://github.com/tomtom...

Open Graph Description: With GitPython 3.1.14 GitCommandError, for failed clones would pass on the captured stderr output into its stderr attribute. With 3.1.15 this contains the empty string instead. This was caught by t...

X Description: With GitPython 3.1.14 GitCommandError, for failed clones would pass on the captured stderr output into its stderr attribute. With 3.1.15 this contains the empty string instead. This was caught by t...

Opengraph URL: https://github.com/gitpython-developers/GitPython/issues/1221

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"GitCommand missing stderr","articleBody":"With GitPython 3.1.14 `GitCommandError`, for failed clones would pass on the captured stderr output into its `stderr` attribute. With 3.1.15 this contains the empty string instead.\r\n\r\nThis was caught by this unit test: https://github.com/tomtom-international/hopic/blob/9a35520388f8109ccff6a89407bc2429ed0d0557/hopic/test/test_checkout.py#L84-L103\r\n\r\nA reduced test that reduces this to _only_ testing GitPython (instead of the full integration with hopic) looks like the code below. That exhibits the exact same problem:\r\n\r\n```python\r\nimport git\r\nimport pytest\r\n\r\ndef test_checkout_in_non_empty_dir(tmp_path):\r\n    orig_repo = tmp_path / \"orig\"\r\n    with git.Repo.init(orig_repo, expand_vars=False) as repo:\r\n        repo.index.commit(message='Initial commit', **_commitargs)\r\n\r\n    non_empty_dir = tmp_path / 'non-empty-clone'\r\n    non_empty_dir.mkdir(parents=True)\r\n    garbage_file = non_empty_dir / 'not-empty'\r\n    garbage_file.write_text('Garbage!')\r\n\r\n    # Verify that the clone fails complaining about the target directory not being empty/non-existent\r\n    with pytest.raises(git.GitCommandError, match=r'(?is).*\\bfatal:\\s+destination\\s+path\\b.*\\bexists\\b.*\\bnot\\b.*\\bempty\\s+directory\\b'):\r\n        git.Repo.clone_from(orig_repo, non_empty_dir)\r\n    assert garbage_file.exists()\r\n```\r\n\r\nWith 3.1.14 this passes. With the `pytest.raises` expectation removed this output is displayed:\r\n```console\r\n___________________________________________________________________ test_checkout_in_non_empty_dir ____________________________________________________________________\r\n\r\ntmp_path = PosixPath('/tmp/pytest-of-vanschig/pytest-334/test_checkout_in_non_empty_dir0')\r\n\r\n    def test_checkout_in_non_empty_dir(tmp_path):\r\n        orig_repo = tmp_path / \"orig\"\r\n        with git.Repo.init(orig_repo, expand_vars=False) as repo:\r\n            repo.index.commit(message='Initial commit', **_commitargs)\r\n\r\n        non_empty_dir = tmp_path / 'non-empty-clone'\r\n        non_empty_dir.mkdir(parents=True)\r\n        garbage_file = non_empty_dir / 'not-empty'\r\n        garbage_file.write_text('Garbage!')\r\n\r\n        # Verify that the clone fails complaining about the target directory not being empty/non-existent\r\n\u003e       git.Repo.clone_from(orig_repo, non_empty_dir)\r\n\r\nhopic/test/test_checkout.py:95:\r\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r\nv3.8/lib/python3.8/site-packages/git/repo/base.py:1032: in clone_from\r\n    return cls._clone(git, url, to_path, GitCmdObjectDB, progress, multi_options, **kwargs)\r\nv3.8/lib/python3.8/site-packages/git/repo/base.py:973: in _clone\r\n    finalize_process(proc, stderr=stderr)\r\nv3.8/lib/python3.8/site-packages/git/util.py:329: in finalize_process\r\n    proc.wait(**kwargs)\r\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r\n\r\nself = \u003cgit.cmd.Git.AutoInterrupt object at 0x7f6a5883f9a0\u003e\r\nstderr = b\"fatal: destination path '/tmp/pytest-of-vanschig/pytest-334/test_checkout_in_non_empty_dir0/non-empty-clone' already exists and is not an empty directory.\\n\"\r\n\r\n    def wait(self, stderr=b''):  # TODO: Bad choice to mimic `proc.wait()` but with different args.\r\n        \"\"\"Wait for the process and return its status code.\r\n\r\n        :param stderr: Previously read value of stderr, in case stderr is already closed.\r\n        :warn: may deadlock if output or error pipes are used and not handled separately.\r\n        :raise GitCommandError: if the return status is not 0\"\"\"\r\n        if stderr is None:\r\n            stderr = b''\r\n        stderr = force_bytes(data=stderr, encoding='utf-8')\r\n\r\n        status = self.proc.wait()\r\n\r\n        def read_all_from_possibly_closed_stream(stream):\r\n            try:\r\n                return stderr + force_bytes(stream.read())\r\n            except ValueError:\r\n                return stderr or b''\r\n\r\n        if status != 0:\r\n            errstr = read_all_from_possibly_closed_stream(self.proc.stderr)\r\n            log.debug('AutoInterrupt wait stderr: %r' % (errstr,))\r\n\u003e           raise GitCommandError(self.args, status, errstr)\r\nE           git.exc.GitCommandError: Cmd('git') failed due to: exit code(128)\r\nE             cmdline: git clone -v /tmp/pytest-of-vanschig/pytest-334/test_checkout_in_non_empty_dir0/orig /tmp/pytest-of-vanschig/pytest-334/test_checkout_in_non_empty_dir0/non-empty-clone\r\nE             stderr: 'fatal: destination path '/tmp/pytest-of-vanschig/pytest-334/test_checkout_in_non_empty_dir0/non-empty-clone' already exists and is not an empty directory.\r\nE           '\r\n\r\nv3.8/lib/python3.8/site-packages/git/cmd.py:408: GitCommandError\r\n```\r\n\r\nWith 3.1.15 this output is produced instead (notice the absence of the \"stderr: ...\" line):\r\n```console\r\n___________________________________________________________________ test_checkout_in_non_empty_dir ____________________________________________________________________\r\n\r\ntmp_path = PosixPath('/tmp/pytest-of-vanschig/pytest-336/test_checkout_in_non_empty_dir0')\r\n\r\n    def test_checkout_in_non_empty_dir(tmp_path):\r\n        orig_repo = tmp_path / \"orig\"\r\n        with git.Repo.init(orig_repo, expand_vars=False) as repo:\r\n            repo.index.commit(message='Initial commit', **_commitargs)\r\n\r\n        non_empty_dir = tmp_path / 'non-empty-clone'\r\n        non_empty_dir.mkdir(parents=True)\r\n        garbage_file = non_empty_dir / 'not-empty'\r\n        garbage_file.write_text('Garbage!')\r\n\r\n        # Verify that the clone fails complaining about the target directory not being empty/non-existent\r\n\u003e       git.Repo.clone_from(orig_repo, non_empty_dir)\r\n\r\nhopic/test/test_checkout.py:95:\r\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r\nv3.8/lib/python3.8/site-packages/git/repo/base.py:1087: in clone_from\r\n    return cls._clone(git, url, to_path, GitCmdObjectDB, progress, multi_options, **kwargs)\r\nv3.8/lib/python3.8/site-packages/git/repo/base.py:1017: in _clone\r\n    handle_process_output(proc, None, progress_checked.new_message_handler(),\r\nv3.8/lib/python3.8/site-packages/git/cmd.py:116: in handle_process_output\r\n    return finalizer(process)\r\nv3.8/lib/python3.8/site-packages/git/util.py:354: in finalize_process\r\n    proc.wait(**kwargs)\r\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r\n\r\nself = \u003cgit.cmd.Git.AutoInterrupt object at 0x7fcc8fd95820\u003e, stderr = b''\r\n\r\n    def wait(self, stderr=b''):  # TODO: Bad choice to mimic `proc.wait()` but with different args.\r\n        \"\"\"Wait for the process and return its status code.\r\n\r\n        :param stderr: Previously read value of stderr, in case stderr is already closed.\r\n        :warn: may deadlock if output or error pipes are used and not handled separately.\r\n        :raise GitCommandError: if the return status is not 0\"\"\"\r\n        if stderr is None:\r\n            stderr = b''\r\n        stderr = force_bytes(data=stderr, encoding='utf-8')\r\n\r\n        status = self.proc.wait()\r\n\r\n        def read_all_from_possibly_closed_stream(stream):\r\n            try:\r\n                return stderr + force_bytes(stream.read())\r\n            except ValueError:\r\n                return stderr or b''\r\n\r\n        if status != 0:\r\n            errstr = read_all_from_possibly_closed_stream(self.proc.stderr)\r\n            log.debug('AutoInterrupt wait stderr: %r' % (errstr,))\r\n\u003e           raise GitCommandError(remove_password_if_present(self.args), status, errstr)\r\nE           git.exc.GitCommandError: Cmd('git') failed due to: exit code(128)\r\nE             cmdline: git clone -v --progress /tmp/pytest-of-vanschig/pytest-336/test_checkout_in_non_empty_dir0/orig /tmp/pytest-of-vanschig/pytest-336/test_checkout_in_non_empty_dir0/non-empty-clone\r\n\r\nv3.8/lib/python3.8/site-packages/git/cmd.py:409: GitCommandError\r\n```\r\n\r\nWhen catching the exception and dumping it's `stderr` attribute it turns out to be an empty string (`''`).\r\n\r\nThis seems related to #1220. But it's presentation is different as that issue still reports having content, just wrongly encoded.","author":{"url":"https://github.com/muggenhor","@type":"Person","name":"muggenhor"},"datePublished":"2021-04-21T15:00:37.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/1221/GitPython/issues/1221"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:d1b3dbbd-71b7-ae7c-9037-88911de14b4e
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB45A:3AA0DE:8AB12:B9017:6969A0A9
html-safe-noncea95793a4fa514f64fbd82485ed1f0a9478b6ae283ba03d2f70fbcc1af591cf2a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNDVBOjNBQTBERTo4QUIxMjpCOTAxNzo2OTY5QTBBOSIsInZpc2l0b3JfaWQiOiIyNzIxNTkxNzM0OTUxMzIxNzY5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac2b8522e7b2a32e7db5069e79f8cacb2223d887662553d240248fcefc3d1c54c1
hovercard-subject-tagissue:863985313
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/gitpython-developers/GitPython/1221/issue_layout
twitter:imagehttps://opengraph.githubassets.com/c11a71a10e24d388bb3ef25349613a1cdec8f286ae936ad9dde24902cf98f4b6/gitpython-developers/GitPython/issues/1221
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/c11a71a10e24d388bb3ef25349613a1cdec8f286ae936ad9dde24902cf98f4b6/gitpython-developers/GitPython/issues/1221
og:image:altWith GitPython 3.1.14 GitCommandError, for failed clones would pass on the captured stderr output into its stderr attribute. With 3.1.15 this contains the empty string instead. This was caught by t...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamemuggenhor
hostnamegithub.com
expected-hostnamegithub.com
None24c4c97a2d520cb286b35e1a4c22d7a4df3c26a2fa28dd7cdf0e65db327b4de7
turbo-cache-controlno-preview
go-importgithub.com/gitpython-developers/GitPython git https://github.com/gitpython-developers/GitPython.git
octolytics-dimension-user_id503709
octolytics-dimension-user_logingitpython-developers
octolytics-dimension-repository_id1126087
octolytics-dimension-repository_nwogitpython-developers/GitPython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1126087
octolytics-dimension-repository_network_root_nwogitpython-developers/GitPython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release124667f43168afb6c9c03b7c02eb5b1d2e1be3d9
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/gitpython-developers/GitPython/issues/1221#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgitpython-developers%2FGitPython%2Fissues%2F1221
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgitpython-developers%2FGitPython%2Fissues%2F1221
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=gitpython-developers%2FGitPython
Reloadhttps://github.com/gitpython-developers/GitPython/issues/1221
Reloadhttps://github.com/gitpython-developers/GitPython/issues/1221
Reloadhttps://github.com/gitpython-developers/GitPython/issues/1221
gitpython-developers https://github.com/gitpython-developers
GitPythonhttps://github.com/gitpython-developers/GitPython
Please reload this pagehttps://github.com/gitpython-developers/GitPython/issues/1221
Notifications https://github.com/login?return_to=%2Fgitpython-developers%2FGitPython
Fork 964 https://github.com/login?return_to=%2Fgitpython-developers%2FGitPython
Star 5k https://github.com/login?return_to=%2Fgitpython-developers%2FGitPython
Code https://github.com/gitpython-developers/GitPython
Issues 169 https://github.com/gitpython-developers/GitPython/issues
Pull requests 8 https://github.com/gitpython-developers/GitPython/pulls
Discussions https://github.com/gitpython-developers/GitPython/discussions
Actions https://github.com/gitpython-developers/GitPython/actions
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/gitpython-developers/GitPython/security
Please reload this pagehttps://github.com/gitpython-developers/GitPython/issues/1221
Insights https://github.com/gitpython-developers/GitPython/pulse
Code https://github.com/gitpython-developers/GitPython
Issues https://github.com/gitpython-developers/GitPython/issues
Pull requests https://github.com/gitpython-developers/GitPython/pulls
Discussions https://github.com/gitpython-developers/GitPython/discussions
Actions https://github.com/gitpython-developers/GitPython/actions
Security https://github.com/gitpython-developers/GitPython/security
Insights https://github.com/gitpython-developers/GitPython/pulse
New issuehttps://github.com/login?return_to=https://github.com/gitpython-developers/GitPython/issues/1221
New issuehttps://github.com/login?return_to=https://github.com/gitpython-developers/GitPython/issues/1221
#1224https://github.com/gitpython-developers/GitPython/pull/1224
GitCommand missing stderrhttps://github.com/gitpython-developers/GitPython/issues/1221#top
#1224https://github.com/gitpython-developers/GitPython/pull/1224
v3.1.16 - Bugfixeshttps://github.com/gitpython-developers/GitPython/milestone/48
https://github.com/muggenhor
https://github.com/muggenhor
muggenhorhttps://github.com/muggenhor
on Apr 21, 2021https://github.com/gitpython-developers/GitPython/issues/1221#issue-863985313
https://github.com/tomtom-international/hopic/blob/9a35520388f8109ccff6a89407bc2429ed0d0557/hopic/test/test_checkout.py#L84-L103https://github.com/tomtom-international/hopic/blob/9a35520388f8109ccff6a89407bc2429ed0d0557/hopic/test/test_checkout.py#L84-L103
#1220https://github.com/gitpython-developers/GitPython/issues/1220
v3.1.16 - Bugfixeshttps://github.com/gitpython-developers/GitPython/milestone/48
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.