git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Luke Diamand <luke@diamand.org>
To: Merland Romain <merlorom@yahoo.fr>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>,
	Junio C Hamano <gitster@pobox.com>, Jeff King <peff@peff.net>,
	Vinicius Kursancew <viniciusalexandre@gmail.com>
Subject: Re: [PATCH] git-p4 - Add option --sha1 to submit in p4
Date: Wed, 2 May 2018 15:55:39 +0100	[thread overview]
Message-ID: <CAE5ih7-71WakVOYLhREchcnOP7HtYfMqPMKvp9r+TMdsTJJmPQ@mail.gmail.com> (raw)
In-Reply-To: <1943804476.5328267.1525271559834@mail.yahoo.com>

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

       reply	other threads:[~2018-05-02 14:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1943804476.5328267.1525271559834.ref@mail.yahoo.com>
     [not found] ` <1943804476.5328267.1525271559834@mail.yahoo.com>
2018-05-02 14:55   ` Luke Diamand [this message]
     [not found]     ` <1093388937.5389750.1525276285911@mail.yahoo.com>
2018-05-02 18:53       ` [PATCH] git-p4 - Add option --sha1 to submit in p4 Luke Diamand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAE5ih7-71WakVOYLhREchcnOP7HtYfMqPMKvp9r+TMdsTJJmPQ@mail.gmail.com \
    --to=luke@diamand.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=merlorom@yahoo.fr \
    --cc=peff@peff.net \
    --cc=viniciusalexandre@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).