Jelajahi Sumber

Merge upstream

John Carr 16 tahun lalu
induk
melakukan
19aa3322f3
2 mengubah file dengan 17 tambahan dan 5 penghapusan
  1. 15 4
      bin/dul-fetch-pack
  2. 2 1
      dulwich/repo.py

+ 15 - 4
bin/dul-fetch-pack

@@ -20,13 +20,24 @@
 from dulwich.client import TCPGitClient, SimpleFetchGraphWalker
 from dulwich.repo import Repo
 import sys
+from getopt import getopt
 
-(host, path) = sys.argv[1].split(":", 1)
-client = TCPGitClient(host)
+opts, args = getopt(sys.argv[1:], "", ["all"])
+
+opts = dict(opts)
+
+if args == []:
+	print "Usage: dul-fetch-pack host:path"
+	sys.exit(1)
 
-all = True
+if not ":" in args[0]:
+	print "Usage: dul-fetch-pack host:path"
+	sys.exit(1)
+
+(host, path) = args[0].split(":", 1)
+client = TCPGitClient(host)
 
-if all:
+if "--all" in opts:
     determine_wants = lambda x: x.values()
 else:
     determine_wants = lambda x: sys.argv[1:]

+ 2 - 1
dulwich/repo.py

@@ -70,7 +70,8 @@ class Repo(object):
     fd, path = tempfile.mkstemp(dir=self.pack_dir(), suffix=".pack")
     f = os.fdopen(fd, 'w')
     def commit():
-       self._move_in_pack(path)
+       if os.path.getsize(path) > 0:
+           self._move_in_pack(path)
     return f, commit
 
   def _move_in_pack(self, path):