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

Commit69b75e1

Browse files
marxinByron
authored andcommitted
Fix handle_diff_line for -z option.
1 parent8218939 commit69b75e1

File tree

1 file changed

+49
-49
lines changed

1 file changed

+49
-49
lines changed

‎git/diff.py

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -479,55 +479,55 @@ def _index_from_raw_format(cls, repo, proc):
479479

480480
index=DiffIndex()
481481

482-
defhandle_diff_line(line):
483-
line=line.decode(defenc)
484-
ifnotline.startswith(":"):
485-
return
486-
487-
meta,_,path=line[1:].partition('\x00')
488-
old_mode,new_mode,a_blob_id,b_blob_id,_change_type=meta.split(None,4)
489-
# Change type can be R100
490-
# R: status letter
491-
# 100: score (in case of copy and rename)
492-
change_type=_change_type[0]
493-
score_str=''.join(_change_type[1:])
494-
score=int(score_str)ifscore_str.isdigit()elseNone
495-
path=path.strip()
496-
a_path=path.encode(defenc)
497-
b_path=path.encode(defenc)
498-
deleted_file=False
499-
new_file=False
500-
copied_file=False
501-
rename_from=None
502-
rename_to=None
503-
504-
# NOTE: We cannot conclude from the existence of a blob to change type
505-
# as diffs with the working do not have blobs yet
506-
ifchange_type=='D':
507-
b_blob_id=None
508-
deleted_file=True
509-
elifchange_type=='A':
510-
a_blob_id=None
511-
new_file=True
512-
elifchange_type=='C':
513-
copied_file=True
514-
a_path,b_path=path.split('\x00',1)
515-
a_path=a_path.encode(defenc)
516-
b_path=b_path.encode(defenc)
517-
elifchange_type=='R':
518-
a_path,b_path=path.split('\x00',1)
519-
a_path=a_path.encode(defenc)
520-
b_path=b_path.encode(defenc)
521-
rename_from,rename_to=a_path,b_path
522-
elifchange_type=='T':
523-
# Nothing to do
524-
pass
525-
# END add/remove handling
526-
527-
diff=Diff(repo,a_path,b_path,a_blob_id,b_blob_id,old_mode,new_mode,
528-
new_file,deleted_file,copied_file,rename_from,rename_to,
529-
'',change_type,score)
530-
index.append(diff)
482+
defhandle_diff_line(lines):
483+
lines=lines.decode(defenc)
484+
485+
forlineinlines.split(':')[1:]:
486+
meta,_,path=line.partition('\x00')
487+
path=path.rstrip('\x00')
488+
old_mode,new_mode,a_blob_id,b_blob_id,_change_type=meta.split(None,4)
489+
# Change type can be R100
490+
# R: status letter
491+
# 100: score (in case of copy and rename)
492+
change_type=_change_type[0]
493+
score_str=''.join(_change_type[1:])
494+
score=int(score_str)ifscore_str.isdigit()elseNone
495+
path=path.strip()
496+
a_path=path.encode(defenc)
497+
b_path=path.encode(defenc)
498+
deleted_file=False
499+
new_file=False
500+
copied_file=False
501+
rename_from=None
502+
rename_to=None
503+
504+
# NOTE: We cannot conclude from the existence of a blob to change type
505+
# as diffs with the working do not have blobs yet
506+
ifchange_type=='D':
507+
b_blob_id=None
508+
deleted_file=True
509+
elifchange_type=='A':
510+
a_blob_id=None
511+
new_file=True
512+
elifchange_type=='C':
513+
copied_file=True
514+
a_path,b_path=path.split('\x00',1)
515+
a_path=a_path.encode(defenc)
516+
b_path=b_path.encode(defenc)
517+
elifchange_type=='R':
518+
a_path,b_path=path.split('\x00',1)
519+
a_path=a_path.encode(defenc)
520+
b_path=b_path.encode(defenc)
521+
rename_from,rename_to=a_path,b_path
522+
elifchange_type=='T':
523+
# Nothing to do
524+
pass
525+
# END add/remove handling
526+
527+
diff=Diff(repo,a_path,b_path,a_blob_id,b_blob_id,old_mode,new_mode,
528+
new_file,deleted_file,copied_file,rename_from,rename_to,
529+
'',change_type,score)
530+
index.append(diff)
531531

532532
handle_process_output(proc,handle_diff_line,None,finalize_process,decode_streams=False)
533533

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp