Skip to content

branch w/o depth parameter causes failure - "fatal: reference is not a tree" #367

@sergii-matus-rft

Description

@sergii-matus-rft

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions