Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfcc166d

Browse files
committed
log: non-existing logs no longer throw an exception, but are ignored. Fixed critical bug which caused packed-ref files to be written with native line endings, which made git fail to parse it. I wonder why I never noticed this before, or ignored it. Unbelievable \!
1 parentc3b7263 commitfcc166d

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

‎.gitmodules

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff 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

‎git/refs/log.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,13 @@ def __init__(self, filepath=None):
129129
# END handle filepath
130130

131131
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+
exceptOSError:
135+
# it is possible and allowed that the file doesn't exist !
136+
return
137+
#END handle invalid log
138+
133139
try:
134140
self._deserialize(fmap)
135141
finally:

‎git/refs/symbolic.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def _iter_packed_refs(cls, repo):
7575
"""Returns an iterator yielding pairs of sha1/path pairs for the corresponding refs.
7676
:note: The packed refs file will be kept open as long as we iterate"""
7777
try:
78-
fp=open(cls._get_packed_refs_path(repo),'r')
78+
fp=open(cls._get_packed_refs_path(repo),'rb')
7979
forlineinfp:
8080
line=line.strip()
8181
ifnotline:
@@ -398,7 +398,7 @@ def delete(cls, repo, path):
398398
# check packed refs
399399
pack_file_path=cls._get_packed_refs_path(repo)
400400
try:
401-
reader=open(pack_file_path)
401+
reader=open(pack_file_path,'rb')
402402
except (OSError,IOError):
403403
pass# it didnt exist at all
404404
else:
@@ -425,7 +425,10 @@ def delete(cls, repo, path):
425425

426426
# write the new lines
427427
ifmade_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
429432
# END open exception handling
430433
# END handle deletion
431434

@@ -549,7 +552,7 @@ def _iter_items(cls, repo, common_path = None):
549552
# Currently we do not follow links
550553
forroot,dirs,filesinos.walk(join_path_native(repo.git_dir,common_path)):
551554
if'refs/'notinroot:# skip non-refs subfolders
552-
refs_id= [ifori,dinenumerate(dirs)ifd=='refs' ]
555+
refs_id= [dfordindirsifd=='refs' ]
553556
ifrefs_id:
554557
dirs[0:]= ['refs']
555558
# END prune non-refs folders
@@ -589,7 +592,7 @@ def iter_items(cls, repo, common_path = None):
589592
590593
:return:
591594
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
593596
594597
List is lexigraphically sorted
595598
The returned objects represent actual subclasses, such as Head or TagReference"""

‎git/util.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,15 @@ def join_path(a, *p):
4747
'/' instead of possibly '\' on windows."""
4848
path=a
4949
forbinp:
50+
iflen(b)==0:
51+
continue
5052
ifb.startswith('/'):
5153
path+=b[1:]
5254
elifpath==''orpath.endswith('/'):
5355
path+=b
5456
else:
5557
path+='/'+b
58+
# END for each path token to add
5659
returnpath
5760

5861
defto_native_path_windows(path):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp