git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* 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@vger.kernel.org, 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

* Re: [PATCH] git-p4 - Add option --sha1 to submit in p4
       [not found]     ` <1093388937.5389750.1525276285911@mail.yahoo.com>
@ 2018-05-02 18:53       ` Luke Diamand
  0 siblings, 0 replies; 2+ messages in thread
From: Luke Diamand @ 2018-05-02 18:53 UTC (permalink / raw)
  To: Merland Romain
  Cc: git@vger.kernel.org, Junio C Hamano, Jeff King,
	Vinicius Kursancew

On 2 May 2018 at 16:51, Merland Romain <merlorom@yahoo.fr> wrote:
> Thanks Luke,
>
> Following your comments, I will:
> - change the option name to --commit if it suits you

Seems like a good name.

> - add an option --force-rebase which defaults to false. Setting it to true
> will rebase even with --commit option used.

Or "--disable-rebase" ?  I think there's no reason you couldn't rebase
after doing a commit like this is there?

And "--disable-rebase" would be useful generally, not just with the
--commit option, but also with the regular options.

"--force-rebase" is a bit confusing since for the normal flow, it
always rebases anyway, and there's no need to force!

But you're the one who is using this in anger, so your opinion likely
counts for more than mine!

> it can be useful too if some commits have been skipped and user wants to
> rebase anyway
> - add an entry in the documentation
> - (learn how to create a test and) add tests for these specific cases

To create a test just look in t/ for the t98*.sh files. Cut-n-paste
one or add to an existing one. Send an email here if you get stuck
(but it's pretty straightforward).

You can run only the git-p4 tests with:

$ (cd t && make T=t98* -j)

>
> What is the best practice ? to send a new email with the new diff ? to
> continue this discussion ?

I think either, probably a new email is easiest. See
Documentation/SubmittingPatches for the general process.


Regards!
Luke

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-05-02 18:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1943804476.5328267.1525271559834.ref@mail.yahoo.com>
     [not found] ` <1943804476.5328267.1525271559834@mail.yahoo.com>
2018-05-02 14:55   ` [PATCH] git-p4 - Add option --sha1 to submit in p4 Luke Diamand
     [not found]     ` <1093388937.5389750.1525276285911@mail.yahoo.com>
2018-05-02 18:53       ` Luke Diamand

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).