Skip to content

Commit 54662d5

Browse files
dorgonmangitster
authored andcommitted
git-p4: fix failed submit by skip non-text data files
If the submit contain binary files, it will throw exception and stop submit when try to append diff line description. This commit will skip non-text data files when exception UnicodeDecodeError thrown. The skip will not affect actual submit files in the resulting cl, the diff line description will only appear in submit template, so you can review what changed before actully submit to p4. I don't know if add any message here will be helpful for users, so I choose to just skip binary content, since it already append filename previously. Signed-off-by: dorgon.chang <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ebf3c04 commit 54662d5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

git-p4.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1977,8 +1977,11 @@ def get_diff_description(self, editedFiles, filesToAdd, symlinks):
19771977
newdiff += "+%s\n" % os.readlink(newFile)
19781978
else:
19791979
f = open(newFile, "r")
1980-
for line in f.readlines():
1981-
newdiff += "+" + line
1980+
try:
1981+
for line in f.readlines():
1982+
newdiff += "+" + line
1983+
except UnicodeDecodeError:
1984+
pass # Found non-text data and skip, since diff description should only include text
19821985
f.close()
19831986

19841987
return (diff + newdiff).replace('\r\n', '\n')

0 commit comments

Comments
 (0)