Skip to content
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

git log is empty #1049

Open
tushar-deepsource opened this issue Dec 15, 2022 · 5 comments
Open

git log is empty #1049

tushar-deepsource opened this issue Dec 15, 2022 · 5 comments

Comments

@tushar-deepsource
Copy link

tushar-deepsource commented Dec 15, 2022

Using the following method to checkout:

steps:
- name: Checkout code
  uses: actions/checkout@v2
  with:
    fetch-depth: 50
    ref: ${{ github.event.pull_request.head.sha }}

The git directory (/github/workspace) gets into this state:

fatal: detected dubious ownership in repository at '/github/workspace'
To add an exception for this directory, call:

	git config --global --add safe.directory /github/workspace

The suggested command doesn't work because that would need higher privilege.

This changed recently, within the past couple days -- git log didn't use to be empty before.

@cory-miller
Copy link
Contributor

Could you try an older release to see if v2.6.0 caused an issue (v2 is just an alias to the latest)?

uses: actions/checkout@v2.5.0

I'm not able to reproduce this so far. If you could add some logs or a workflow example I can take a look.

@tusharsadhwani
Copy link

tusharsadhwani commented Dec 15, 2022

@cory-miller I've narrowed it down to this: when a GitHub action tries to run git commands on the repo cloned via the checkout action, it fails. This seems like the behaviour change in the latest git itself, due to the user cloning the repo being different from the user trying to read it (as actions run in a container).

It seems to be due to #766, and the workaround of adding a step that puts

[safe]
directory = /github/workspace

inside .gitconfig in the folder that will be mounted as /github/home in the action seems to solve the problem.

@oalders
Copy link

oalders commented Jan 2, 2023

I'm seeing issues with safe.directory as well. I bumped to @v3 of checkout and I see the following in the logs:

Adding repository directory to the temporary git global config as a safe directory
/usr/bin/git config --global --add safe.directory /__w/HTTP-Message/HTTP-Message
Deleting the contents of '/__w/HTTP-Message/HTTP-Message'

Later on I get:

fatal: detected dubious ownership in repository at '/__w/HTTP-Message/HTTP-Message'
To add an exception for this directory, call:

	git config --global --add safe.directory /__w/HTTP-Message/HTTP-Message

https://github.com/libwww-perl/HTTP-Message/actions/runs/3825324809/jobs/6508226477

Not sure if the global git config is in the directory that's getting deleted?

As a stopgap, I've got it working right by running git config after the initial checkout step and before any further git commands are run:

      - uses: actions/checkout@v3
      - name: Allow for file ownership conflicts with Docker and GitHub Actions
        run: git config --global --add safe.directory '*'

@jiridanek
Copy link

@oalders I'm having the same problem in https://github.com/skupperproject/skupper-router/actions/runs/3951927345/jobs/6766390478, the error message there is not shown, but I debugged it and saw that it says

$ git status
fatal: detected dubious ownership in repository at '/__w/skupper-router/skupper-router'
To add an exception for this directory, call:

	git config --global --add safe.directory /__w/skupper-router/skupper-router

My workaround is doing a chown

      - uses: actions/checkout@v3

      - name: Take ownership of the checkout directory (Git CVE-2022-24765)
        run: chown --recursive --reference=/ .

@oalders
Copy link

oalders commented Jan 21, 2023

I should add that for pre-built Docker containers that I'm using in my workflows, I've added

git config --system --add safe.directory '*'

to the Dockerfile. Doing it via --global didn't seem to work when using the checkout action, so I resorted to --system.

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

5 participants