@@ -89,6 +89,8 @@ public class CommitGraphCollector {
8989
9090 private int maxDays ;
9191
92+ private boolean reportAllFiles ;
93+
9294 private boolean audit ;
9395
9496 private boolean dryRun ;
@@ -150,7 +152,7 @@ public void transfer(URL service, Authenticator authenticator, boolean enableTim
150152 }
151153 CloseableHttpResponse latestResponse = client .execute (new HttpGet (latestUrl .toExternalForm ()));
152154 ImmutableList <ObjectId > advertised = getAdvertisedRefs (handleError (latestUrl , latestResponse ));
153- honorMaxDaysHeader (latestResponse );
155+ honorControlHeaders (latestResponse );
154156
155157 // every time a new stream is needed, supply ByteArrayOutputStream, and when the data is all
156158 // written, turn around and ship that over
@@ -301,16 +303,21 @@ public void accept(VirtualFile f) {
301303 }
302304 }
303305
304- /**
305- * When a user incorrectly configures shallow clone, the incremental nature of commit collection
306- * makes it really hard for us and users to collaboratively reset and repopulate the commit data.
307- * This server-side override mechanism makes it easier.
308- */
309- private void honorMaxDaysHeader (HttpResponse response ) {
306+ private void honorControlHeaders (HttpResponse response ) {
307+ // When a user incorrectly configures shallow clone, the incremental nature of commit collection
308+ // makes it really hard for us and users to collaboratively reset and repopulate the commit data.
309+ // This server-side override mechanism makes it easier.
310310 Header h = response .getFirstHeader ("X-Max-Days" );
311311 if (h !=null ) {
312312 maxDays = Integer .parseInt (h .getValue ());
313313 }
314+ // File transfer is supposed to work incrementally, but we are investigating the problem where
315+ // not all files get collected prior to commit collection, resulting in incomplete data on the server side.
316+ // As a temporary mitigation, allow the server to request all files to be reported.
317+ h = response .getFirstHeader ("X-Report-All-Files" );
318+ if (h !=null ) {
319+ reportAllFiles = true ;
320+ }
314321 }
315322
316323 private ImmutableList <ObjectId > getAdvertisedRefs (HttpResponse response ) throws IOException {
@@ -436,7 +443,9 @@ public void transfer(Collection<ObjectId> advertised, Consumer<JSCommit> commitR
436443 try {
437444 RevCommit c = walk .parseCommit (id );
438445 walk .markUninteresting (c );
439- treeWalk .addTree (c .getTree ());
446+ if (!reportAllFiles ) {
447+ treeWalk .addTree (c .getTree ());
448+ }
440449 } catch (MissingObjectException e ) {
441450 // it's possible that the server advertises a commit we don't have.
442451 //
0 commit comments