Skip to content

Unexpected v7 error fatal: ambiguous argument on diff --stat #3311

Open

Description

@fatbasstard

Hi,

We've updated to V7 and now getting an (unexpected) error. Checked the "what's new" and changes and it didn't mention anything that could impact, but it did.

Error

Create or update the pull request branch
  /usr/bin/git symbolic-ref HEAD --short
  staging
  Working base is branch 'staging'
  /usr/bin/git checkout --progress -B 0fe2ab1b-5922-4136-bf19-07b126f04ed7 HEAD --
  Switched to a new branch '0fe2ab1b-5922-4136-bf19-07b126f04ed7'
  /usr/bin/git status --porcelain -unormal --
  /usr/bin/git diff --quiet --
  /usr/bin/git diff --quiet --staged --
  /usr/bin/git stash push --include-untracked
  No local changes to save
  Resetting working base branch 'staging'
  /usr/bin/git checkout --progress staging --
  Switched to branch 'staging'
  Your branch and 'origin/staging' have diverged,
  and have 8390 and 1 different commits each, respectively.
    (use "git pull" if you want to integrate the remote branch with yours)
  /usr/bin/git reset --hard origin/staging
  HEAD is now at 9ddb1d2a Merge pull request #[49](https://github.com/xxx/repository/actions/runs/xxx/job/xxx?pr=4929#step:4:55)26 from xxx/develop
  /usr/bin/git rev-list --right-only --count staging...0fe2ab1b-5922-4136-bf19-07b126f04ed7
  8391
  /usr/bin/git -c protocol.version=2 fetch --no-tags --progress --no-recurse-submodules --force --depth=8401 origin develop:refs/remotes/origin/develop
  remote: Total 0 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)        
  Pull request branch 'develop' already exists as remote branch 'origin/develop'
  /usr/bin/git checkout --progress develop --
  Switched to branch 'develop'
  /usr/bin/git rev-list --right-only --count staging...develop
  8391
  /usr/bin/git diff --quiet develop..0fe2ab1b-[59](https://github.com/xxx/repository/actions/runs/xxx/job/xxx?pr=4929#step:4:65)22-4136-bf19-07b126f04ed7
  /usr/bin/git diff --stat develop..develop~8391
  fatal: ambiguous argument 'develop..develop~8391': unknown revision or path not in the working tree.
  Use '--' to separate paths from revisions, like this:
  'git <command> [<revision>...] -- [<file>...]'
  Error: The process '/usr/bin/git' failed with exit code 128

Configuration

---
name: Create Develop to Staging branch Pull Request
on:
push:
  branches:
    - develop
workflow_call:

jobs:
sync-to-staging:
  runs-on: ubuntu-latest
  steps:
    - name: Check out code
      uses: actions/checkout@v4
      with:
        ref: staging
    - name: Reset promotion branch
      run: |
        git fetch origin develop:develop
        git reset --hard develop
    - name: Create Pull Request
      uses: peter-evans/[email protected]
      with:
        title: Sync (Develop) to Staging
        body: Synchronize all changes from `develop` to `staging`
        branch: develop
        token: ${{ secrets.OUR_CUSTOM_TOKEN }}

In short, we have bunch or repositories which have a DTAP setup (develop->staging->main) where we use branch promotion to push changes to main. So simplify this process we use this action to automatically create a Sync to staging PR with changes from the develop branch.

Works like a charm with 6.1.0, breaks in 7.0

Activity

  1. fatbasstard commented on Sep 4, 2024

    @fatbasstard
    Author

    Reverted, output from 6.1.0:

      /usr/bin/git symbolic-ref HEAD --short
      staging
      Working base is branch 'staging'
      /usr/bin/git checkout --progress -B 1e85ea96-86ff-4bb2-8710-7d0e8b720737 HEAD --
      Switched to a new branch '1e85ea96-86ff-4bb2-8710-7d0e8b720737'
      /usr/bin/git status --porcelain -unormal --
      /usr/bin/git diff --quiet --
      /usr/bin/git diff --quiet --staged --
      /usr/bin/git stash push --include-untracked
      No local changes to save
      Resetting working base branch 'staging'
      /usr/bin/git checkout --progress staging --
      Switched to branch 'staging'
      Your branch and 'origin/staging' have diverged,
      and have 8390 and 1 different commits each, respectively.
        (use "git pull" if you want to integrate the remote branch with yours)
      /usr/bin/git reset --hard origin/staging
      HEAD is now at 9ddb1d2a Merge pull request #4926 from xxx/develop
      /usr/bin/git rev-list --right-only --count staging...1e85ea96-86ff-4bb2-8710-7d0e8b720737
      8391
      /usr/bin/git -c protocol.version=2 fetch --no-tags --progress --no-recurse-submodules --force --depth=8401 origin develop:refs/remotes/origin/develop
      remote: Total 0 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)        
      Pull request branch 'develop' already exists as remote branch 'origin/develop'
      /usr/bin/git checkout --progress develop --
      Switched to branch 'develop'
      /usr/bin/git rev-list --right-only --count staging...develop
      8391
      /usr/bin/git diff --quiet develop..1e85ea96-86ff-4bb2-8710-7d0e8b720737
      /usr/bin/git rev-list --right-only --count origin/develop...develop
      0
      /usr/bin/git rev-list --left-only --count origin/develop...develop
      0
      Branch 'develop' is even with its remote and will not be updated
      /usr/bin/git rev-list --right-only --count staging...develop
      8391
      /usr/bin/git rev-parse HEAD
      8dbc75970dd07e073ccb96f3fe709dfa5da76831
      /usr/bin/git branch --delete --force 1e85ea96-86ff-4bb2-8710-7d0e8b720737
      Deleted branch 1e85ea96-86ff-4bb2-8710-7d0e8b720737 (was 8dbc7597).
      /usr/bin/git checkout --progress staging --
      Switched to branch 'staging'
      Your branch is up to date with 'origin/staging'.
    Create or update the pull request
      Attempting creation of pull request
      A pull request already exists for xxx:develop
      Fetching existing pull request
      Attempting update of pull request
      Updated pull request #4929 (xxx:develop => staging)
    Setting outputs
    Restore git configuration
    
  2. davidjb commented on Sep 5, 2024

    @davidjb

    Can confirm this happened to me as well when migrating between the same versions - 6.1.0 to 7.0.0. The only difference between my workflow config and @fatbasstard's above is I don't have a token specified; they're otherwise identical. Had to roll back to 6.1.0.

  3. peter-evans commented on Sep 5, 2024

    @peter-evans
    Owner

    Thank you for reporting this. I've released a fix for this in v7.0.1 / v7.

    https://github.com/peter-evans/create-pull-request/releases/tag/v7.0.1

    I'm going to keep this issue open for now because the "fix" is more of a workaround, and I would like to try and reproduce this error so I can solve it in a more satisfactory way.

  4. changed the title [-]Unexpected error when upgrading to V7[/-] [+]Unexpected v7 error `fatal: ambiguous argument` on `diff --stat`[/+] on Sep 5, 2024
  5. fatbasstard commented on Sep 5, 2024

    @fatbasstard
    Author

    Thanks @peter-evans,

    Will try it out ❤️

  6. fatbasstard commented on Sep 6, 2024

    @fatbasstard
    Author

    Functionality works as expected again with 7.0.1

    Thanks for the quick fix!

  7. vparmeland commented on Feb 18, 2025

    @vparmeland

    Hi @peter-evans. I also encountered this issue with v6.0.1, v7, and v7.0.6 #3311 (comment).

        steps:
          - name: Pull foo/bar-repo repository
            uses: actions/checkout@v4
            with:
              repository: "foo/bar-repo"
              path: "${{ github.workspace }}/foo/bar-repo"
              fetch-depth: 0
              token: <REDACTED>
    
          - name: Update image tag for XXX
            id: update-step  
            working-directory: ${{ github.workspace }}/foo/bar-repo
            run: |
              ...
              echo "Processing file: $FILE_PATH"
              BRANCH_NAME="update-image-${VERSION}"
              git checkout -b "$BRANCH_NAME"
              ...
              echo "branch=${BRANCH_NAME}" >> $GITHUB_OUTPUT
    
          - name: Create Pull Request
            uses: peter-evans/create-pull-request@v7
            with:
              token: <REDACTED>
              path: ${{ github.workspace }}/foo/bar-repo
              base: main
              branch: "${{ steps.update-step.outputs.branch }}" # e.g. will be update-image-v1.1.0
              title: "Bump ${COMPONENT_NAME} to ${VERSION}"
              body: |
                <REDACTED>
              delete-branch: false
              labels: Automated PR
    

    CI Logs

    Create or update the pull request branch
      /usr/bin/git symbolic-ref HEAD --short
      update-image-v1.1.0
      Working base is branch 'update-image-v1.1.0'
      /usr/bin/git checkout --progress -B xxxxxxx-xxxx-xxxx-xxx-xxxxxxxx HEAD --
      Switched to a new branch 'xxxxxxx-xxxx-xxxx-xxx-xxxxxxxx'
      M xxx/webapp/config.json
      /usr/bin/git status --porcelain -unormal --
       M xxx/webapp/config.json
      Uncommitted changes found. Adding a commit.
      /usr/bin/git add -A
      /usr/bin/git -c author.name=<REDACTED> -c author.email=<REDACTED>@users.noreply.github.com -c committer.name=github-actions[bot] -c committer.email=<REDACTED> commit -m [create-pull-request] automated change
      [xxxxxxx-xxxx-xxxx-xxx-xxxxxxxx 53a3519] [create-pull-request] automated change
       Author: <REDACTED>@users.noreply.github.com>
       1 file changed, 1 insertion(+), 1 deletion(-)
      /usr/bin/git stash push --include-untracked
      No local changes to save
      Resetting working base branch 'update-image-v1.1.0'
      /usr/bin/git checkout --progress update-image-v1.1.0 --
      Switched to branch 'update-image-v1.1.0'
      /usr/bin/git reset --hard origin/update-image-v1.1.0
      fatal: ambiguous argument 'origin/update-image-v1.1.0': unknown revision or path not in the working tree.
      Use '--' to separate paths from revisions, like this:
      'git <command> [<revision>...] -- [<file>...]'
      Error: The process '/usr/bin/git' failed with exit code 128
    
  8. peter-evans commented on Feb 18, 2025

    @peter-evans
    Owner

    @vparmeland Your issue is different. It's caused because you are trying the create the pull request branch with git checkout -b "$BRANCH_NAME". You don't need to do that, just make the changes locally and let the action create the branch for you.

  9. fabioguarrasi commented on Mar 3, 2025

    @fabioguarrasi

    @vparmeland Your issue is different. It's caused because you are trying the create the pull request branch with git checkout -b "$BRANCH_NAME". You don't need to do that, just make the changes locally and let the action create the branch for you.

    @peter-evans I'm having the same problem. Is there a way to work around this? The reason is that my action is updating the packages.json version and then opening a PR. Doing this locally would erase the purpose of this automation. Thanks!!

  10. peter-evans commented on Mar 3, 2025

    @peter-evans
    Owner

    By locally, I mean make the changes during the workflow on the runner. Don't try and create the branch yourself, or use a remote branch, the action will create and update the branch itself.

    This is off-topic now so if you need further help please open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions