aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFahad Alrashed <fahad@keylock.net>2024-05-08 22:11:05 +0000
committerJunio C Hamano <gitster@pobox.com>2024-05-08 15:44:14 -0700
commit55702c543ea39230847dfc635ea1b604d66d9b83 (patch)
treed68c293ca6ebef6409f33158d8338797a0a0d37f
parent786a3e4b8d754d2b14b1208b98eeb0a554ef19a8 (diff)
downloadgit-55702c543ea39230847dfc635ea1b604d66d9b83.tar.gz
git-p4: show Perforce error to the user
During "git p4 clone" if p4 process returns an error from the server, it will store the message in the 'err' variable. Then it will send a text command "die-now" to git-fast-import. However, git-fast-import raises an exception: "fatal: Unsupported command: die-now" and err is never displayed. This patch ensures that err is shown to the end user. Signed-off-by: Fahad Alrashed <fahad@keylock.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rwxr-xr-xgit-p4.py24
1 files changed, 13 insertions, 11 deletions
diff --git a/git-p4.py b/git-p4.py
index 28ab12c72b..f1ab31d540 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -3253,17 +3253,19 @@ class P4Sync(Command, P4UserMap):
if self.stream_have_file_info:
if "depotFile" in self.stream_file:
f = self.stream_file["depotFile"]
- # force a failure in fast-import, else an empty
- # commit will be made
- self.gitStream.write("\n")
- self.gitStream.write("die-now\n")
- self.gitStream.close()
- # ignore errors, but make sure it exits first
- self.importProcess.wait()
- if f:
- die("Error from p4 print for %s: %s" % (f, err))
- else:
- die("Error from p4 print: %s" % err)
+ try:
+ # force a failure in fast-import, else an empty
+ # commit will be made
+ self.gitStream.write("\n")
+ self.gitStream.write("die-now\n")
+ self.gitStream.close()
+ # ignore errors, but make sure it exits first
+ self.importProcess.wait()
+ finally:
+ if f:
+ die("Error from p4 print for %s: %s" % (f, err))
+ else:
+ die("Error from p4 print: %s" % err)
if 'depotFile' in marshalled and self.stream_have_file_info:
# start of a new file - output the old one first