git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] git-p4: fix failed submit by skip non-text data files

From
DGdorgon chang via GitGitGadget <gitgitgadget@gmail.com>
Date
Mar 12, 2021, 07:47 UTC
Message-ID
<pull.977.git.git.1615535270135.gitgitgadget@gmail.com>
From: "dorgon.chang" <dorgonman@hotmail.com>
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.
Signed-off-by: dorgon.chang <dorgonman@hotmail.com>
---
    git-p4: fix failed submit by skip non-text data files
    
    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.
    
    I am using git-p4 with UnrealEngine game projects and this fix works for
    me.
    
    Signed-off-by: dorgon.chang dorgonman@hotmail.com
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-977%2Fdorgonman%2Fdorgon%2Ffix_gitp4_get_diff_description-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-977/dorgonman/dorgon/fix_gitp4_get_diff_description-v1
Pull-Request: https://github.com/git/git/pull/977
 git-p4.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/git-p4.py b/git-p4.py
index 4433ca53de7e..29a8c202399a 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -1977,8 +1977,11 @@ def get_diff_description(self, editedFiles, filesToAdd, symlinks):
                 newdiff += "+%s\n" % os.readlink(newFile)
             else:
                 f = open(newFile, "r")
-                for line in f.readlines():
-                    newdiff += "+" + line
+                try:
+                    for line in f.readlines():
+                        newdiff += "+" + line
+                except UnicodeDecodeError:
+                    pass # Fond non-text data
                 f.close()
 
         return (diff + newdiff).replace('\r\n', '\n')

base-commit: d4a392452e292ff924e79ec8458611c0f679d6d4
-- 
gitgitgadget
Next: Simon Hausmann
Message 1 of 9 in “git-p4: fix failed submit by skip non-text data files”
  1. git-p4: fix failed submit by skip non-text data filesdorgon chang via GitGitGadget, Mar 12, 2021
  2. Simon HausmannJun 17, 2021
  3. Johannes SchindelinJun 18, 2021
  4. Junio C HamanoJun 29, 2021
  5. Simon HausmannJun 18, 2021
  6. Junio C HamanoJun 19, 2021
  7. dorgon.changJun 20, 2021
  8. Junio C HamanoJun 21, 2021
  9. git-p4: fix failed submit by skip non-text data filesdorgon chang via GitGitGadget, Jun 21, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.