You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi. Thank you for building buf, it's a great tool.
I've run into an issue a few times in CI:
% buf breaking --against .git#ref=<sha>
Failure: could not clone file://$PWD/.git: exit status 128
fatal: reference is not a tree: <sha>
I've noticed this happens when HEAD is relatively far away from ref, for example a long standing feature branch being compared against main.
Here are steps to reproduce:
% git clone https://github.com/bufbuild/buf.git
% cd buf
% git checkout v1.5.0
% buf breaking --against .git#ref=066e7afe5c0e0fe663b6b215a5a495310fb4bf4a
Failure: could not clone file:///Users/jkegelman/buf/.git: exit status 128
fatal: reference is not a tree: 066e7afe5c0e0fe663b6b215a5a495310fb4bf4a
// After fetch we won't have checked out any refs. This
// will cause `refs=` containing "HEAD" to fail, as HEAD
// is a special case that is not fetched into a ref but
// instead refers to the current commit checked out. By
// checking out "FETCH_HEAD" before checking out the
// user supplied ref, we behave similarly to git clone.
return"HEAD", "FETCH_HEAD", gitName.checkout()
One idea would be to fetch the ref directly (could use default --depth=1) and then do the checkout. To support users providing a ref relative to HEAD like in #419 I believe you might have to incorporate something like git rev-parse because git fetch origin HEAD~1 doesn't work (invalid refspec).
I'm not sure if I've hunted this down correctly so let me know if you need any additional information or if I'm drawing the wrong conclusions.
Again, thanks for building buf it's really alleviated a lot of headaches.
The text was updated successfully, but these errors were encountered:
Unfortunately this is not widely supported by git servers. Fetching by a commit sha directly rather than by ref requires the origin server has uploadpack.allowReachableSHA1InWant=true (or equivalent) set, which is not the default and still quite uncommon (github does not support this if I recall correctly).
Given that your example is about using a local git directory, we may be able to special case there if it would help. For now, I would recommend using named refs rather than shas's (or if you're doing something like HEAD~51 then depth=51 could be a workaround).
ah makes sense, thanks. On the failing cases (hasn't happened very often) I tried manually passing depth=n but I ran into context timeouts. Unfortunately the repository is rather large.
We are checking against a local git directory because we try to minimize the number of fetches from remote during CI and the local repository already has the two relevant refs fetched when buf runs.
I will try to see if we can use named refs in this case.
Hi. Thank you for building buf, it's a great tool.
I've run into an issue a few times in CI:
I've noticed this happens when
HEAD
is relatively far away fromref
, for example a long standing feature branch being compared againstmain
.Here are steps to reproduce:
for reference
This is from Mac OS 12.3.1 with
but I've been able to reproduce on Linux (Ubuntu)
Looking through the code I suspect it might be coming from the git fetch and checkout strategy with a default depth of 50 when using
ref
buf/private/buf/buffetch/internal/ref_parser.go
Lines 220 to 221 in 0729ac1
I may not have enough context but it looks like the
cloner
is fetchingHEAD
with--depth=50
and then trying to check outref
(which fails).buf/private/pkg/git/cloner.go
Lines 356 to 363 in 0729ac1
One idea would be to fetch the
ref
directly (could use default--depth=1
) and then do the checkout. To support users providing a ref relative toHEAD
like in #419 I believe you might have to incorporate something likegit rev-parse
becausegit fetch origin HEAD~1
doesn't work (invalid refspec
).I'm not sure if I've hunted this down correctly so let me know if you need any additional information or if I'm drawing the wrong conclusions.
Again, thanks for building buf it's really alleviated a lot of headaches.
The text was updated successfully, but these errors were encountered: