Skip to content

Commit 0e36f2d

Browse files
committed
git-p4: Removed git-p4 submit --direct.
This feature was originally meant to allow for quicker direct submits into perforce, but it turns out that it is not actually quicker than doing a git commit and then running git-p4 submit. Signed-off-by: Simon Hausmann <[email protected]>
1 parent edae1e2 commit 0e36f2d

File tree

1 file changed

+11
-45
lines changed

1 file changed

+11
-45
lines changed

contrib/fast-import/git-p4

Lines changed: 11 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,6 @@ class P4Submit(Command):
468468
optparse.make_option("--verbose", dest="verbose", action="store_true"),
469469
optparse.make_option("--origin", dest="origin"),
470470
optparse.make_option("--reset", action="store_true", dest="reset"),
471-
optparse.make_option("--direct", dest="directSubmit", action="store_true"),
472471
optparse.make_option("-M", dest="detectRename", action="store_true"),
473472
]
474473
self.description = "Submit changes from git to the perforce depot."
@@ -478,7 +477,6 @@ class P4Submit(Command):
478477
self.interactive = True
479478
self.firstTime = True
480479
self.origin = ""
481-
self.directSubmit = False
482480
self.detectRename = False
483481
self.verbose = False
484482
self.isWindows = (platform.system() == "Windows")
@@ -494,12 +492,9 @@ class P4Submit(Command):
494492
"maybe you want to call git-p4 submit --reset" % self.configFile)
495493

496494
commits = []
497-
if self.directSubmit:
498-
commits.append("0")
499-
else:
500-
for line in read_pipe_lines("git rev-list --no-merges %s..%s" % (self.origin, self.master)):
501-
commits.append(line.strip())
502-
commits.reverse()
495+
for line in read_pipe_lines("git rev-list --no-merges %s..%s" % (self.origin, self.master)):
496+
commits.append(line.strip())
497+
commits.reverse()
503498

504499
self.config["commits"] = commits
505500

@@ -556,13 +551,9 @@ class P4Submit(Command):
556551
return template
557552

558553
def applyCommit(self, id):
559-
if self.directSubmit:
560-
print "Applying local change in working directory/index"
561-
diff = self.diffStatus
562-
else:
563-
print "Applying %s" % (read_pipe("git log --max-count=1 --pretty=oneline %s" % id))
564-
diffOpts = ("", "-M")[self.detectRename]
565-
diff = read_pipe_lines("git diff-tree -r %s \"%s^\" \"%s\"" % (diffOpts, id, id))
554+
print "Applying %s" % (read_pipe("git log --max-count=1 --pretty=oneline %s" % id))
555+
diffOpts = ("", "-M")[self.detectRename]
556+
diff = read_pipe_lines("git diff-tree -r %s \"%s^\" \"%s\"" % (diffOpts, id, id))
566557
filesToAdd = set()
567558
filesToDelete = set()
568559
editedFiles = set()
@@ -597,10 +588,7 @@ class P4Submit(Command):
597588
else:
598589
die("unknown modifier %s for %s" % (modifier, path))
599590

600-
if self.directSubmit:
601-
diffcmd = "cat \"%s\"" % self.diffFile
602-
else:
603-
diffcmd = "git format-patch -k --stdout \"%s^\"..\"%s\"" % (id, id)
591+
diffcmd = "git format-patch -k --stdout \"%s^\"..\"%s\"" % (id, id)
604592
patchcmd = diffcmd + " | git apply "
605593
tryPatchCmd = patchcmd + "--check -"
606594
applyPatchCmd = patchcmd + "--check --apply -"
@@ -648,12 +636,10 @@ class P4Submit(Command):
648636
mode = filesToChangeExecBit[f]
649637
setP4ExecBit(f, mode)
650638

651-
logMessage = ""
652-
if not self.directSubmit:
653-
logMessage = extractLogMessageFromGitCommit(id)
654-
if self.isWindows:
655-
logMessage = logMessage.replace("\n", "\r\n")
656-
logMessage = logMessage.strip()
639+
logMessage = extractLogMessageFromGitCommit(id)
640+
if self.isWindows:
641+
logMessage = logMessage.replace("\n", "\r\n")
642+
logMessage = logMessage.strip()
657643

658644
template = self.prepareSubmitTemplate()
659645

@@ -692,12 +678,6 @@ class P4Submit(Command):
692678
if self.isWindows:
693679
submitTemplate = submitTemplate.replace("\r\n", "\n")
694680

695-
if self.directSubmit:
696-
print "Submitting to git first"
697-
os.chdir(self.oldWorkingDirectory)
698-
write_pipe("git commit -a -F -", submitTemplate)
699-
os.chdir(self.clientPath)
700-
701681
write_pipe("p4 submit -i", submitTemplate)
702682
else:
703683
fileName = "submit.txt"
@@ -739,17 +719,6 @@ class P4Submit(Command):
739719
print "Perforce checkout for depot path %s located at %s" % (self.depotPath, self.clientPath)
740720
self.oldWorkingDirectory = os.getcwd()
741721

742-
if self.directSubmit:
743-
self.diffStatus = read_pipe_lines("git diff -r --name-status HEAD")
744-
if len(self.diffStatus) == 0:
745-
print "No changes in working directory to submit."
746-
return True
747-
patch = read_pipe("git diff -p --binary --diff-filter=ACMRTUXB HEAD")
748-
self.diffFile = self.gitdir + "/p4-git-diff"
749-
f = open(self.diffFile, "wb")
750-
f.write(patch)
751-
f.close();
752-
753722
os.chdir(self.clientPath)
754723
print "Syncronizing p4 checkout..."
755724
system("p4 sync ...")
@@ -777,9 +746,6 @@ class P4Submit(Command):
777746

778747
self.config.close()
779748

780-
if self.directSubmit:
781-
os.remove(self.diffFile)
782-
783749
if len(commits) == 0:
784750
if self.firstTime:
785751
print "No changes found to apply between %s and current HEAD" % self.origin

0 commit comments

Comments
 (0)