diff --git a/git-p4 b/git-p4 index 29cba05..e9ea721 100755 --- a/git-p4 +++ b/git-p4 @@ -811,6 +811,8 @@ class P4Submit(Command): Command.__init__(self) self.options = [ optparse.make_option("--verbose", dest="verbose", action="store_true"), + optparse.make_option("--dry-run", dest="dryRun", action="store_true"), + optparse.make_option("--no-squash", dest="noSquash", action="store_true"), optparse.make_option("--origin", dest="origin"), optparse.make_option("--auto", dest="interactive", action="store_false", help="Automatically submit changelists without requiring editing"), optparse.make_option("-M", dest="detectRename", action="store_true", help="detect renames"), @@ -829,6 +831,8 @@ class P4Submit(Command): if gitConfig("git-p4.detectCopy") == "true": self.detectCopy = True self.verbose = False + self.dryRun = False + self.noSquash = False self.isWindows = (platform.system() == "Windows") self.importIntoRemotes = True if gitConfig("git-p4.importIntoRemotes") == "false": @@ -1152,13 +1156,20 @@ class P4Submit(Command): self.check() self.commits = [] - for line in read_pipe_lines("git rev-list --no-merges %s..%s" % (self.origin, self.master)): + revListOption = "--no-merges" if self.noSquash else "--first-parent" + for line in read_pipe_lines("git rev-list %s %s..%s" % (revListOption, self.origin, self.master)): self.commits.append(line.strip()) self.commits.reverse() if self.verbose: print "Commits to apply: %s" % self.commits + if self.dryRun: + print "Would submit" + for commit in self.commits: + print (read_pipe("git log --max-count=1 --pretty=oneline %s" % commit)) + return True + self.applyCommits() if self.abort == False: