Skip to content

addons/git: fix interaction with git's safe.directory#421

Merged
arthurzam merged 1 commit intomasterfrom
git-safe-directory
Aug 8, 2022
Merged

addons/git: fix interaction with git's safe.directory#421
arthurzam merged 1 commit intomasterfrom
git-safe-directory

Conversation

@arthurzam
Copy link
Copy Markdown
Member

When using GitLog class, it runs the git commands with clean git config, (aka it uses an empty one) which results in inability to use pkgcheck scan on overlays (as it tries to access system's gentoo repo, which is owned by root). If the user set safe.directory in his config, it will still not work, as we override user's config.

Fix it by creating a temporary file, which we fill with minimal config which disables safe.directory feature, and passing it as the config file to the git log command.

Resolves: #412

@codecov
Copy link
Copy Markdown

codecov Bot commented Aug 6, 2022

Codecov Report

Merging #421 (1b87672) into master (7056ff7) will increase coverage by 0.16%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #421      +/-   ##
==========================================
+ Coverage   95.86%   96.03%   +0.16%     
==========================================
  Files          55       55              
  Lines        7666     7888     +222     
  Branches     1870     1963      +93     
==========================================
+ Hits         7349     7575     +226     
+ Misses        196      194       -2     
+ Partials      121      119       -2     
Impacted Files Coverage Δ
src/pkgcheck/addons/git.py 97.40% <100.00%> (+0.08%) ⬆️
src/pkgcheck/results.py 86.91% <0.00%> (+1.04%) ⬆️
src/pkgcheck/checks/python.py 98.92% <0.00%> (+1.67%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Comment thread src/pkgcheck/addons/git.py Outdated
@arthurzam arthurzam force-pushed the git-safe-directory branch from 2642188 to 697dd59 Compare August 7, 2022 16:50
@arthurzam arthurzam requested a review from laumann August 7, 2022 19:44
@arthurzam
Copy link
Copy Markdown
Member Author

@thesamesam does this solution make sense for you?

Comment thread src/pkgcheck/addons/git.py Outdated
Comment thread src/pkgcheck/addons/git.py Outdated
Copy link
Copy Markdown
Contributor

@laumann laumann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, the debugging print line should probably go. Nice work.

@arthurzam arthurzam force-pushed the git-safe-directory branch from 697dd59 to 1b87672 Compare August 8, 2022 03:52
Copy link
Copy Markdown
Member

@thesamesam thesamesam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might need to revisit whether we really want to ignore 'git log' in future (probably by revisiting git bindings in future).

Unfortunately, not that long ago at all, when radhermit tried to use the various git Python bindings out there, IIRC they were all far slower and had other limitations. But w/e.

This is what I was expecting and looks good, thanks!

When using GitLog class, it runs the git commands with clean git config,
(aka it uses an empty one) which results in inability to use pkgcheck
scan on overlays (as it tries to access system's gentoo repo, which is
owned by root). If the user set safe.directory in his config, it will
still not work, as we override user's config.

Fix it by creating a temporary file, which we fill with minimal config
which disables safe.directory feature, and passing it as the config file
to the git log command.

Resolves: #412
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
@arthurzam arthurzam force-pushed the git-safe-directory branch from 1b87672 to 5c43a71 Compare August 8, 2022 04:06
@arthurzam arthurzam merged commit 5c43a71 into master Aug 8, 2022
@arthurzam arthurzam deleted the git-safe-directory branch August 8, 2022 04:06
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

Successfully merging this pull request may close these issues.

Safe directory feature in >= git 2.35.2 breaks git integration

3 participants