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

Atlantis warning ("could not determine correct commit"), Git error "Use '--' to separate paths from revisions" #584

Closed
kipkoan opened this issue Apr 10, 2019 · 9 comments
Labels
bug Something isn't working

Comments

@kipkoan
Copy link
Contributor

kipkoan commented Apr 10, 2019

Atlantis (0.7.0) gives a warning when trying to determine if it's at the correct commit. The underlying git command is giving an error, requesting that -- be used to separate paths from revisions.

Apr 10 17:30:24 ip-10-79-21-49.us-west-2.compute.internal env[3341]: 2019/04/10 17:30:24+0000 [DBUG] working_dir.go:79 Analytics Terraform/atlantis-testing#25: Clone directory "/home/ec2-user/.atlantis/repos/Analytics Terraform/atlantis-testing/25/default" already exists, checking if it's at the right commit
Apr 10 17:30:24 ip-10-79-21-49.us-west-2.compute.internal env[3341]: 2019/04/10 17:30:24+0000 [WARN] working_dir.go:94 Analytics Terraform/atlantis-testing#25: Will re-clone repo, could not determine if was at correct commit: git rev-parse HEAD^2: exit status 128: fatal: ambiguous argument 'HEAD^2': unknown revision or path not in the working tree.
Apr 10 17:30:24 ip-10-79-21-49.us-west-2.compute.internal env[3341]: Use '--' to separate paths from revisions, like this:
Apr 10 17:30:24 ip-10-79-21-49.us-west-2.compute.internal env[3341]: 'git <command> [<revision>...] -- [<file>...]'
Apr 10 17:30:24 ip-10-79-21-49.us-west-2.compute.internal env[3341]: HEAD^2
Apr 10 17:30:24 ip-10-79-21-49.us-west-2.compute.internal env[3341]: 2019/04/10 17:30:24+0000 [INFO] working_dir.go:123 Analytics Terraform/atlantis-testing#25: Creating dir "/home/ec2-user/.atlantis/repos/Analytics Terraform/atlantis-testing/25/default"
Apr 10 17:30:25 ip-10-79-21-49.us-west-2.compute.internal env[3341]: 2019/04/10 17:30:25+0000 [DBUG] working_dir.go:181 Analytics Terraform/atlantis-testing#25: Ran: git clone --branch master --single-branch https://bitbucket.zgtools.net/scm/anatf/atlantis-testing.git /home/ec2-user/.atlantis/repos/Analytics Terraform/atlantis-testing/25/default. Output: Cloning into '/home/ec2-user/.atlantis/repos/Analytics Terraform/atlantis-testing/25/default'...
Apr 10 17:30:25 ip-10-79-21-49.us-west-2.compute.internal env[3341]: 2019/04/10 17:30:25+0000 [DBUG] working_dir.go:181 Analytics Terraform/atlantis-testing#25: Ran: git remote add head https://bitbucket.zgtools.net/scm/anatf/atlantis-testing.git. Output:
Apr 10 17:30:25 ip-10-79-21-49.us-west-2.compute.internal env[3341]: 2019/04/10 17:30:25+0000 [DBUG] working_dir.go:181 Analytics Terraform/atlantis-testing#25: Ran: git fetch head +refs/heads/feature/DEVINFRA-114-testing-scenery:. Output: From https://bitbucket.zgtools.net/scm/anatf/atlantis-testing
Apr 10 17:30:25 ip-10-79-21-49.us-west-2.compute.internal env[3341]: * branch                    feature/DEVINFRA-114-testing-scenery -> FETCH_HEAD
Apr 10 17:30:25 ip-10-79-21-49.us-west-2.compute.internal env[3341]: * [new branch]              feature/DEVINFRA-114-testing-scenery -> head/feature/DEVINFRA-114-testing-scenery
Apr 10 17:30:25 ip-10-79-21-49.us-west-2.compute.internal env[3341]: 2019/04/10 17:30:25+0000 [DBUG] working_dir.go:181 Analytics Terraform/atlantis-testing#25: Ran: git merge -q -m atlantis-merge FETCH_HEAD. Output:
@lkysow
Copy link
Member

lkysow commented Apr 10, 2019

What does your git repo look like at that commit?

@lkysow
Copy link
Member

lkysow commented Apr 10, 2019

The -- won't work, it's just running git rev-parse HEAD^2

@lkysow
Copy link
Member

lkysow commented Apr 10, 2019

 git log --graph --oneline --all

@lkysow lkysow added the bug Something isn't working label Apr 10, 2019
@lkysow
Copy link
Member

lkysow commented Apr 10, 2019

Okay I think I know how to fix this, it occurs if the branch can be fast-forward merged into the base branch. Then after we merge, it looks like:

* 1aa8191 b
* 8fd6fcf Initial commit

And so HEAD^2 fails because there are no parents, the history is straight.

But if we use git merge --no-ff then we get

*   d77019a atlantis-merge
|\
| * 1aa8191 b
|/

And so HEAD^2 will give us 1aa8191 as expected.

@kipkoan
Copy link
Contributor Author

kipkoan commented Apr 10, 2019

@lkysow - do you still need me to give you the git log output?

@lkysow
Copy link
Member

lkysow commented Apr 10, 2019

Can you confirm that it was going to be a fast-forward merge?

@kipkoan
Copy link
Contributor Author

kipkoan commented Apr 10, 2019

Confirmed.

$ git log --graph --oneline --all
* 01aa0abd098 (HEAD -> master, head/feature/DEVINFRA-114-testing-scenery) count 1
* 1f55c09847e (origin/master, origin/HEAD) count 0
* 66813d4e2b3 feature/DEVINFRA-114-testing-scenery
* 7e55ea61f0b count 0
...

@kipkoan
Copy link
Contributor Author

kipkoan commented Apr 10, 2019

@lkysow - I think this may be the root cause of #582

@kipkoan
Copy link
Contributor Author

kipkoan commented Apr 10, 2019

Confirmed fixed:

Apr 10 18:55:47 ip-10-79-21-49.us-west-2.compute.internal env[7160]: 2019/04/10 18:55:47+0000 [INFO] working_dir.go:123 Analytics Terra
form/atlantis-testing#29: Creating dir "/home/ec2-user/.atlantis/repos/Analytics Terraform/atlantis-testing/29/default"
Apr 10 18:55:48 ip-10-79-21-49.us-west-2.compute.internal env[7160]: 2019/04/10 18:55:48+0000 [DBUG] working_dir.go:187 Analytics Terra
form/atlantis-testing#29: Ran: git clone --branch master --single-branch https://bitbucket.zgtools.net/scm/anatf/atlantis-testing.git /home/ec2-user/.atlantis/repos/Analytics Terraform/atlantis-testing/29/default. Output: Cloning into '/home/ec2-user/.atlantis/repos/Ana
lytics Terraform/atlantis-testing/29/default'...
Apr 10 18:55:48 ip-10-79-21-49.us-west-2.compute.internal env[7160]: 2019/04/10 18:55:48+0000 [DBUG] working_dir.go:187 Analytics Terra
form/atlantis-testing#29: Ran: git remote add head https://bitbucket.zgtools.net/scm/anatf/atlantis-testing.git. Output:
Apr 10 18:55:48 ip-10-79-21-49.us-west-2.compute.internal env[7160]: 2019/04/10 18:55:48+0000 [DBUG] working_dir.go:187 Analytics Terra
form/atlantis-testing#29: Ran: git fetch head +refs/heads/feature/DEVINFRA-114-testing-scenery:. Output: From https://bitbucket.zgtools.net/scm/anatf/atlantis-testing
Apr 10 18:55:48 ip-10-79-21-49.us-west-2.compute.internal env[7160]: * branch                    feature/DEVINFRA-114-testing-scenery -> FETCH_HEAD
Apr 10 18:55:48 ip-10-79-21-49.us-west-2.compute.internal env[7160]: * [new branch]              feature/DEVINFRA-114-testing-scenery -> head/feature/DEVINFRA-114-testing-scenery
Apr 10 18:55:48 ip-10-79-21-49.us-west-2.compute.internal env[7160]: 2019/04/10 18:55:48+0000 [DBUG] working_dir.go:187 Analytics Terraform/atlantis-testing#29: Ran: git merge -q --no-ff -m atlantis-merge FETCH_HEAD. Output:
...
Apr 10 18:55:48 ip-10-79-21-49.us-west-2.compute.internal env[7160]: 2019/04/10 18:55:48+0000 [DBUG] working_dir.go:79 Analytics Terraf
orm/atlantis-testing#29: Clone directory "/home/ec2-user/.atlantis/repos/Analytics Terraform/atlantis-testing/29/default" already exist
s, checking if it's at the right commit
Apr 10 18:55:48 ip-10-79-21-49.us-west-2.compute.internal env[7160]: 2019/04/10 18:55:48+0000 [DBUG] working_dir.go:101 Analytics Terra
form/atlantis-testing#29: Repo is at correct commit "89eec49da1f17638f1a7be47aea75736a0752316" so will not re-clone
...
Apr 10 18:55:53 ip-10-79-21-49.us-west-2.compute.internal env[7160]: 2019/04/10 18:55:53+0000 [DBUG] working_dir.go:79 Analytics Terraf
orm/atlantis-testing#29: Clone directory "/home/ec2-user/.atlantis/repos/Analytics Terraform/atlantis-testing/29/default" already exist
s, checking if it's at the right commit
Apr 10 18:55:53 ip-10-79-21-49.us-west-2.compute.internal env[7160]: 2019/04/10 18:55:53+0000 [DBUG] working_dir.go:101 Analytics Terra
form/atlantis-testing#29: Repo is at correct commit "89eec49da1f17638f1a7be47aea75736a0752316" so will not re-clone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants