From b4fd74ce8e28c372c511db2e0a491fa8b67c93f4 Mon Sep 17 00:00:00 2001
From: Eliah Kagan <degeneracypressure@gmail.com>
Date: Sun, 26 Jan 2025 11:51:11 -0500
Subject: [PATCH] Improve description of backoff sequence in db.loose

The sequence of backoff wait times used in `gitdb.db.loose` is
quadratic rather than exponential, as discussed in:
https://github.com/gitpython-developers/gitdb/pull/115#discussion_r1903215598

This corrects the variable name by making it more general, and the
comment by having it explicitly describe the backoff as quadratic.

This is conceptually related to GitoxideLabs/gitoxide#1815, but
this is a non-breaking change, as no interfaces are affected: only
a local variable and comment.
---
 gitdb/db/loose.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gitdb/db/loose.py b/gitdb/db/loose.py
index 03d387e..e6765cd 100644
--- a/gitdb/db/loose.py
+++ b/gitdb/db/loose.py
@@ -230,16 +230,16 @@ def store(self, istream):
             # end rename only if needed
 
             # Ensure rename is actually done and file is stable
-            # Retry up to 14 times - exponential wait & retry in ms.
+            # Retry up to 14 times - quadratic wait & retry in ms.
             # The total maximum wait time is 1000ms, which should be vastly enough for the
             # OS to return and commit the file to disk.
-            for exp_backoff_ms in [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 181]:
+            for backoff_ms in [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 181]:
                 with suppress(PermissionError):
                     # make sure its readable for all ! It started out as rw-- tmp file
                     # but needs to be rwrr
                     chmod(obj_path, self.new_objects_mode)
                     break
-                time.sleep(exp_backoff_ms / 1000.0)
+                time.sleep(backoff_ms / 1000.0)
             else:
                 raise PermissionError(
                     "Impossible to apply `chmod` to file {}".format(obj_path)