concourse / concourse/git-resource
branch w/o depth parameter causes failure - "fatal: reference is not a tree"
Nobody has claimed this yet.
- Dominant language
- Shell
- Stars
- 203
- Forks
- 305
- Avg merge
- 11d 14h
- Merged PRs (30d)
- 2
Description
Issue: if "branch:" parameter is a custom, not a master and "version: ref:" is not specified with proper revision, and if master contains fresher commit then the branch, $ref will pick up and shallow a commit which HEAD of master.
In such case, it will be incorrect revision taken by Concourse which then causes a failure with the message:
"fatal: reference is not a tree". See example:
Cloning into '/tmp/build/get'...
fatal: reference is not a tree: <ref>_
Looking at https://github.com/concourse/git-resource/blob/master/assets/in
the answer can be partially explained by the piece of code which is deciding what needs to be checkout - there is no $branch specified and just $ref used which is HEAD, if depth > 0 :
if [ "$depth" -gt 0 ]; then
"$bin_dir"/deepen_shallow_clone_until_ref_is_found_then_check_out "$depth" "$ref" "$tagflag"
else
git checkout -q "$ref"
fi
As a workaround setting flag "depth: " helps in case of "branch" parameter is custom (not a master).
Could you please explain behaviour, if anything can be done to fix this behaviour?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with assets/in and the deepen_shallow_clone_until_ref_is_found_then_check_out entry point, then reproduce the custom-branch case without a version ref while master has a newer commit. Trace how branch, ref, and depth determine the checkout target; done means the scenario no longer produces “fatal: reference is not a tree” or its expected behavior is clearly documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git, shell
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100