* Re: [PATCH] git-p4 - Add option --sha1 to submit in p4
[not found] ` <1943804476.5328267.1525271559834@mail.yahoo.com>
@ 2018-05-02 14:55 ` Luke Diamand
[not found] ` <1093388937.5389750.1525276285911@mail.yahoo.com>
0 siblings, 1 reply; 2+ messages in thread
From: Luke Diamand @ 2018-05-02 14:55 UTC (permalink / raw)
To: Merland Romain; +Cc: git, Junio C Hamano, Jeff King, Vinicius Kursancew
On 2 May 2018 at 15:32, Merland Romain <merlorom@yahoo.fr> wrote:
> From 4867808cad2b759ebf31c275356e602b72c5659f Mon Sep 17 00:00:00 2001
> From: Romain Merland <merlorom@yahoo.fr>
> To: git@vger.kernel.org
> Cc: Junio C Hamano <gitster@pobox.com>, Jeff King <peff@peff.net>, Luke
> Diamand <luke@diamand.org>, Vinicius Kursancew <viniciusalexandre@gmail.com>
> Date: Wed, 2 May 2018 15:02:11 +0200
> Subject: [PATCH] git-p4 - Add option --sha1 to submit in p4
>
> Add option --sha1 to command 'git-p4 submit' in order to submit in p4 a
> commit
> that is not necessarily on master.
> In that case, don't rebase the submitted changes.
That could be very useful, I often find the commit I want to submit is
half-way down a long list of other commits.
Currently I end up cherry-picking the one I want into a clean repo,
but that's much more awkward than your --sha1 change.
A few comments inline:
> Signed-off-by: Romain Merland <merlorom@yahoo.fr>
> ---
> git-p4.py | 21 +++++++++++++++------
> 1 file changed, 15 insertions(+), 6 deletions(-)
>
> diff --git a/git-p4.py b/git-p4.py
> index 7bb9cadc6..d64ff79dd 100755
> --- a/git-p4.py
> +++ b/git-p4.py
> @@ -1352,7 +1352,9 @@ class P4Submit(Command, P4UserMap):
> optparse.make_option("--update-shelve",
> dest="update_shelve", action="append", type="int",
> metavar="CHANGELIST",
> help="update an existing shelved
> changelist, implies --shelve, "
> - "repeat in-order for multiple
> shelved changelists")
> + "repeat in-order for multiple
> shelved changelists"),
> + optparse.make_option("--sha1", dest="sha1", metavar="SHA1",
> + help="submit only the specified
> commit, don't rebase afterwards")
Is there a better name than "sha1" ? If git ever changes its hash to
something else will this still make sense?
I wonder why you wouldn't rebase afterwards?
Perhaps an additional option to skip the rebase?
> ]
> self.description = "Submit changes from git to the perforce depot."
> self.usage += " [name of git branch to submit into perforce depot]"
> @@ -1362,6 +1364,7 @@ class P4Submit(Command, P4UserMap):
> self.dry_run = False
> self.shelve = False
> self.update_shelve = list()
> + self.sha1 = ""
> self.prepare_p4_only = False
> self.conflict_behavior = None
> self.isWindows = (platform.system() == "Windows")
> @@ -2103,9 +2106,12 @@ class P4Submit(Command, P4UserMap):
> else:
> commitish = 'HEAD'
>
> - for line in read_pipe_lines(["git", "rev-list", "--no-merges",
> "%s..%s" % (self.origin, commitish)]):
> - commits.append(line.strip())
> - commits.reverse()
> + if self.sha1 != "":
> + commits.append(self.sha1)
> + else:
> + for line in read_pipe_lines(["git", "rev-list", "--no-merges",
> "%s..%s" % (self.origin, commitish)]):
> + commits.append(line.strip())
> + commits.reverse()
>
> if self.preserveUser or gitConfigBool("git-p4.skipUserNameCheck"):
> self.checkAuthorship = False
> @@ -2215,8 +2221,11 @@ class P4Submit(Command, P4UserMap):
> sync.branch = self.branch
> sync.run([])
>
> - rebase = P4Rebase()
> - rebase.rebase()
> + if self.sha1 == "":
if not self.skip_rebase:
> + rebase = P4Rebase()
> + rebase.rebase()
> + else:
> + print "You will have to do 'git p4 sync' and rebase."
>
> else:
> if len(applied) == 0:
> --
> 2.17.0
>
>
This would be better with some documentation in git-p4.txt and a test case!
Regards!
Luke
^ permalink raw reply [flat|nested] 2+ messages in thread