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

[PATCHv2 1/3] git-p4: do not fail in verbose mode for missing 'fileSize' key

From
Luke Diamand <luke@diamand.org>
Date
Oct 15, 2018, 11:14 UTC
Message-ID
<20181015111408.17618-2-luke@diamand.org>
In-Reply-To
<20181015111408.17618-1-luke@diamand.org>
If deleting or moving a file, sometimes P4 doesn't report the file size.

The code handles this just fine but some logging crashes. Stop this happening.

There was some earlier discussion on the list about this:
https://public-inbox.org/git/xmqq1sqpp1vv.fsf@gitster.mtv.corp.google.com/
Signed-off-by: Luke Diamand <luke@diamand.org>
---
 git-p4.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/git-p4.py b/git-p4.py
index 7fab255584..5701bad06a 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -2775,7 +2775,10 @@ def streamOneP4File(self, file, contents):
         relPath = self.stripRepoPath(file['depotFile'], self.branchPrefixes)
         relPath = self.encodeWithUTF8(relPath)
         if verbose:
-            size = int(self.stream_file['fileSize'])
+            if 'fileSize' in self.stream_file:
+                size = int(self.stream_file['fileSize'])
+            else:
+                size = 0 # deleted files don't get a fileSize apparently
             sys.stdout.write('\r%s --> %s (%i MB)\n' % (file['depotFile'], relPath, size/1024/1024))
             sys.stdout.flush()
 
-- 
2.19.1.331.gae0ed827e6
Previous: Luke DiamandNext: Luke Diamand
Message 2 of 6 in “[PATCHv2 0/3] git-p4: improved unshelving - small fixes”
  1. Luke DiamandOct 15, 2018
  2. 1/3 git-p4: do not fail in verbose mode for missing 'fileSize' keyLuke Diamand, Oct 15, 2018
  3. 2/3 git-p4: unshelve into refs/remotes/p4-unshelved, not refs/remotes/p4/unshelvedLuke Diamand, Oct 15, 2018
  4. 3/3 git-p4: fully support unshelving changelistsLuke Diamand, Oct 15, 2018
  5. Junio C HamanoOct 16, 2018
  6. Luke DiamandOct 24, 2018

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.