]> arthur.barton.de Git - bup.git/commitdiff
git: use git's int parsing with pack.packSizeLimit config
authorJohannes Berg <johannes@sipsolutions.net>
Thu, 9 Jan 2020 12:27:35 +0000 (13:27 +0100)
committerRob Browning <rlb@defaultvalue.org>
Sun, 13 Jun 2021 16:32:17 +0000 (11:32 -0500)
Our parse_num() understands a little more than git, in particular
 * T for terabytes
 * b suffix when you specify Kb, Mb, Gb or Tb.

Neither of those are understood by git, it only understands the
K, M and G suffixes (case-insensitive). However, a git repository
that actually states 'pack.packSizeLimit' as something that git
doesn't understand is broken for every single git command, and as
we call git, the added flexibility of parse_num() cannot be used.

Thus, simplify the code and just use opttype='int' for this.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/git.py

index f6ae9e3765472f0e3e85c0764c72c384b49c9ff0..5144e70dd8bf8c3993d5bcb590d7294614f3fc74 100644 (file)
@@ -718,9 +718,8 @@ class PackWriter:
         self.on_pack_finish = on_pack_finish
         if not max_pack_size:
             max_pack_size = git_config_get(b'pack.packSizeLimit',
-                                           repo_dir=self.repo_dir)
-            if max_pack_size is not None:
-                max_pack_size = parse_num(max_pack_size)
+                                           repo_dir=self.repo_dir,
+                                           opttype='int')
             if not max_pack_size:
                 # larger packs slow down pruning
                 max_pack_size = 1000 * 1000 * 1000