]> arthur.barton.de Git - bup.git/commitdiff
Add git.shorten_hash(), printing only the first few bytes of a sha1.
authorAvery Pennarun <apenwarr@gmail.com>
Fri, 18 Feb 2011 07:36:49 +0000 (23:36 -0800)
committerAvery Pennarun <apenwarr@gmail.com>
Fri, 18 Feb 2011 07:38:07 +0000 (23:38 -0800)
The full name is rarely needed and clutters the output.  Let's try this
instead in a few places.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
cmd/server-cmd.py
lib/bup/client.py
lib/bup/git.py

index ff4db47788e34697742c179852847e94eb573db6..acd61191804db7f32ba4840cb05b6f12f5b3c263 100755 (executable)
@@ -101,7 +101,8 @@ def receive_objects_v2(conn, junk):
                 assert(oldpack.endswith('.idx'))
                 (dir,name) = os.path.split(oldpack)
                 if not (name in suggested):
-                    debug1("bup server: suggesting index %s\n" % name)
+                    debug1("bup server: suggesting index %s\n"
+                           % git.shorten_hash(name))
                     debug1("bup server:   because of object %s\n"
                            % shar.encode('hex'))
                     conn.write('index %s\n' % name)
index 22fa38ddcb1f8b1e6d24933afb1a5d43660482f4..f941067237b1f574d93bb2b40668c5f5eb20dfca 100644 (file)
@@ -216,11 +216,13 @@ class Client:
             debug2('%s\n' % line)
             if line.startswith('index '):
                 idx = line[6:]
-                debug1('client: received index suggestion: %s\n' % idx)
+                debug1('client: received index suggestion: %s\n'
+                       % git.shorten_hash(idx))
                 suggested.append(idx)
             else:
                 assert(line.endswith('.idx'))
-                debug1('client: completed writing pack, idx: %s\n' % line)
+                debug1('client: completed writing pack, idx: %s\n'
+                       % git.shorten_hash(line))
                 suggested.append(line)
         self.check_ok()
         if ob:
index 79df185d107d166559476dfbdd1c06d93738793b..ace4e4cb84118ee67682c998fa0956d48efc7042 100644 (file)
@@ -38,6 +38,11 @@ def repo(sub = ''):
     return os.path.join(repodir, sub)
 
 
+def shorten_hash(s):
+    return re.sub(r'([^0-9a-z]|\b)([0-9a-z]{7})[0-9a-z]{33}([^0-9a-z]|\b)',
+                  r'\1\2*\3', s)
+
+
 def repo_rel(path):
     full = os.path.abspath(path)
     fullrepo = os.path.abspath(repo(''))
@@ -47,7 +52,7 @@ def repo_rel(path):
         path = full[len(fullrepo):]
     if path.startswith('index-cache/'):
         path = path[len('index-cache/'):]
-    return path
+    return shorten_hash(path)
 
 
 def all_packdirs():