Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix shallow git clone in docker-build #33704
Some more context (pasted from #33701)
See also: #12502 (comment), which is the reason that we need to check for smart-vs-dumb http to begin with.
referenced this pull request
Jul 4, 2017
Sorry for the back and forth; discussing with @tonistiigi - we were wondering if there's still servers around that don't support this option, and what kind of error would be returned by such a server.
Perhaps we can do a "happy path" and just assume it's not supported, and if it fails, fall back to non-shallow clone?
Would you be interested in investigating that, and see if that would be a viable option?
Basically considering to "just do a shallow clone" and assuming it is supported; if (e.g.) 99% of the servers out there support this, then the extra handling is resulting in extra overhead for 99% of the cases, and only used for 1%.
I spent some time to look into what makes a "dumb" server, and how git/docker works with that. Apparently, git should fallback to the "dumb" protocol, but I guess this doesn't work if
This is how to test a "dumb" server;
Build a dumb server image;
$ docker build -t dumb-git -<<EOF FROM nginx:alpine WORKDIR /usr/share/nginx/html/ RUN apk add --no-cache git RUN git clone --bare https://github.com/thaJeztah/pgadmin4-docker.git \ && cd pgadmin4-docker.git \ && git update-server-info EOF
Start the server
$ docker run -d --name gitty -p 80:80 dumb-git
Try to clone from this server;
$ git clone http://localhost/pgadmin4-docker.git --depth 1 Cloning into 'pgadmin4-docker'... fatal: dumb http transport does not support shallow capabilities
$ git clone http://localhost/pgadmin4-docker.git Cloning into 'pgadmin4-docker'...
Next, I built a Docker CLI, but with the feature detection disabled (i.e., always
$ docker build -t foo http://192.168.65.2/pgadmin4-docker.git unable to prepare context: unable to 'git clone' to temporary context directory: error fetching: fatal: dumb http transport does not support shallow capabilities : exit status 128
So, possibly we can detect the
Unfortunately setting up a dumb server is super trivial (expose a directory via http(s) and try to remember to run
Perhaps the smart one supports some sort of
My concern was that if the clone failed for some other reason we don't just assume it was due to the shallow clone, perhaps matching on
@ijc I think the
@ecnerwala I agree. I think the code is correct but could do with some additional comments explaining why it is looking at the things it is looking at, in particular the aspect that
So the GH implementation (which rejects
I think the patch could be improved by believing the checking content type on a
You should probably use
I don't know enough about these things to say if you should also accept other (or all)
I originally wrote it to accept all