| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c3b7263 commit fcc166d
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,4 @@ | |||
| 1 | - [submodule "gitdb"] | ||
| 2 | - path = git/ext/gitdb | ||
| 3 | - url = git://github.com/gitpython-developers/gitdb.git | ||
| 4 | - branch = master | ||
| 1 | + [submodule "gitdb"] | ||
| 2 | + path = git/ext/gitdb | ||
| 3 | + url = git://github.com/gitpython-developers/gitdb.git | ||
| 4 | + branch = master | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -129,7 +129,13 @@ def __init__(self, filepath=None): | |||
| 129 | 129 | # END handle filepath | |
| 130 | 130 | ||
| 131 | 131 | def _read_from_file(self): | |
| 132 | - fmap = file_contents_ro_filepath(self._path, stream=False, allow_mmap=True) | ||
| 132 | + try: | ||
| 133 | + fmap = file_contents_ro_filepath(self._path, stream=False, allow_mmap=True) | ||
| 134 | + except OSError: | ||
| 135 | + # it is possible and allowed that the file doesn't exist ! | ||
| 136 | + return | ||
| 137 | + #END handle invalid log | ||
| 138 | + | ||
| 133 | 139 | try: | |
| 134 | 140 | self._deserialize(fmap) | |
| 135 | 141 | finally: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -75,7 +75,7 @@ def _iter_packed_refs(cls, repo): | |||
| 75 | 75 | """Returns an iterator yielding pairs of sha1/path pairs for the corresponding refs. | |
| 76 | 76 | :note: The packed refs file will be kept open as long as we iterate""" | |
| 77 | 77 | try: | |
| 78 | - fp = open(cls._get_packed_refs_path(repo), 'r') | ||
| 78 | + fp = open(cls._get_packed_refs_path(repo), 'rb') | ||
| 79 | 79 | for line in fp: | |
| 80 | 80 | line = line.strip() | |
| 81 | 81 | if not line: | |
@@ -398,7 +398,7 @@ def delete(cls, repo, path): | |||
| 398 | 398 | # check packed refs | |
| 399 | 399 | pack_file_path = cls._get_packed_refs_path(repo) | |
| 400 | 400 | try: | |
| 401 | - reader = open(pack_file_path) | ||
| 401 | + reader = open(pack_file_path, 'rb') | ||
| 402 | 402 | except (OSError,IOError): | |
| 403 | 403 | pass # it didnt exist at all | |
| 404 | 404 | else: | |
@@ -425,7 +425,10 @@ def delete(cls, repo, path): | |||
| 425 | 425 | ||
| 426 | 426 | # write the new lines | |
| 427 | 427 | if made_change: | |
| 428 | - open(pack_file_path, 'w').writelines(new_lines) | ||
| 428 | + # write-binary is required, otherwise windows will | ||
| 429 | + # open the file in text mode and change LF to CRLF ! | ||
| 430 | + open(pack_file_path, 'wb').writelines(new_lines) | ||
| 431 | + # END write out file | ||
| 429 | 432 | # END open exception handling | |
| 430 | 433 | # END handle deletion | |
| 431 | 434 | ||
@@ -549,7 +552,7 @@ def _iter_items(cls, repo, common_path = None): | |||
| 549 | 552 | # Currently we do not follow links | |
| 550 | 553 | for root, dirs, files in os.walk(join_path_native(repo.git_dir, common_path)): | |
| 551 | 554 | if 'refs/' not in root: # skip non-refs subfolders | |
| 552 | - refs_id = [ i for i,d in enumerate(dirs) if d == 'refs' ] | ||
| 555 | + refs_id = [ d for d in dirs if d == 'refs' ] | ||
| 553 | 556 | if refs_id: | |
| 554 | 557 | dirs[0:] = ['refs'] | |
| 555 | 558 | # END prune non-refs folders | |
@@ -589,7 +592,7 @@ def iter_items(cls, repo, common_path = None): | |||
| 589 | 592 | ||
| 590 | 593 | :return: | |
| 591 | 594 | git.SymbolicReference[], each of them is guaranteed to be a symbolic | |
| 592 | - ref which is not detached. | ||
| 595 | + ref which is not detached and pointing to a valid ref | ||
| 593 | 596 | ||
| 594 | 597 | List is lexigraphically sorted | |
| 595 | 598 | The returned objects represent actual subclasses, such as Head or TagReference""" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -47,12 +47,15 @@ def join_path(a, *p): | |||
| 47 | 47 | '/' instead of possibly '\' on windows.""" | |
| 48 | 48 | path = a | |
| 49 | 49 | for b in p: | |
| 50 | + if len(b) == 0: | ||
| 51 | + continue | ||
| 50 | 52 | if b.startswith('/'): | |
| 51 | 53 | path += b[1:] | |
| 52 | 54 | elif path == '' or path.endswith('/'): | |
| 53 | 55 | path += b | |
| 54 | 56 | else: | |
| 55 | 57 | path += '/' + b | |
| 58 | + # END for each path token to add | ||
| 56 | 59 | return path | |
| 57 | 60 | ||
| 58 | 61 | def to_native_path_windows(path): | |
| Back | FazBrowse Home | New Git URL |
0 commit comments