diff mbox series

[RFC,21/21] parallel-checkout: skip checking the working tree on clone

Message ID 6356b499a4c12c86ec12ca6309c12e16662996f9.1597093021.git.matheus.bernardino@usp.br (mailing list archive)
State New, archived
Headers show
Series Parallel checkout | expand

Commit Message

Matheus Tavares Aug. 10, 2020, 9:33 p.m. UTC
If the current checkout process is part of a clone, we can skip some
steps that check paths in the working tree, as we know it was previously
empty. More specifically, we can enqueue the entry for parallel checkout
before calling check_path() to see if the path was already present and
up-to-date. We can also skip calling remove_non_dirs().

Note: this optimization is only possible because the parallel checkout
machinery will detect path collisions, and call checkout_entry_ca()
again for them, going through the check_path() logic.

Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
---
 entry.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/entry.c b/entry.c
index 5dfd4d150d..8c03e23811 100644
--- a/entry.c
+++ b/entry.c
@@ -513,12 +513,24 @@  int checkout_entry_ca(struct cache_entry *ce, struct conv_attrs *ca,
 		return 0;
 	}
 
-	if (topath) {
+	if (topath || state->clone) {
 		if (S_ISREG(ce->ce_mode) && !ca) {
 			convert_attrs(state->istate, &ca_buf, ce->name);
 			ca = &ca_buf;
 		}
-		return write_entry(ce, topath, ca, state, 1);
+		if (topath)
+			return write_entry(ce, topath, ca, state, 1);
+		/*
+		 * Since we are cloning, there should be no previous files in
+		 * the working tree. So we can skip calling remove_non_dirs()
+		 * and check_path(). (parallel-checkout.c will take care of path
+		 * collision.)
+		 */
+		if (!enqueue_checkout(ce, ca)) {
+			if (nr_checkouts)
+				(*nr_checkouts)++;
+			return 0;
+		}
 	}
 
 	/*