git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Luke Diamand <luke@diamand.org>
To: Romain Merland <merlorom@yahoo.fr>
Cc: Junio C Hamano <gitster@pobox.com>,
	Git Users <git@vger.kernel.org>,
	Matthieu Moy <Matthieu.Moy@imag.fr>,
	Vinicius Kursancew <viniciusalexandre@gmail.com>,
	Jeff King <peff@peff.net>,
	Cedric Borgese <cedric.borgese@gmail.com>,
	Fabien Boutantin <fabien.boutantin@pdgm.com>
Subject: Re: [PATCH] git-p4: add options --commit and --disable-rebase
Date: Fri, 18 May 2018 12:54:22 +0100	[thread overview]
Message-ID: <CAE5ih7_U_8TqsWQbCBrATkrOpyAkE2sdgj3KXdovLw7rsXtt6A@mail.gmail.com> (raw)
In-Reply-To: <20180509153212.2681-1-merlorom@yahoo.fr>

On 9 May 2018 at 16:32, Romain Merland <merlorom@yahoo.fr> wrote:
> On a daily work with multiple local git branches, the usual way to submit only a
> specified commit was to cherry-pick the commit on master then run git-p4 submit.
> It can be very annoying to switch between local branches and master, only to
> submit one commit.
> The proposed new way is to select directly the commit you want to submit.
>
> add option --commit to command 'git-p4 submit' in order to submit only specified commit(s) in p4.
>
> On a daily work developping software with big compilation time, one may not want
> to rebase on his local git tree, in order to avoid long recompilation.
>
> add option --disable-rebase to command 'git-p4 submit' in order to disable rebase after submission.

I've been using this for real and it works well for me. Ack.

Because of the way I'm using git-p4, the --disable-rebase option
doesn't really help me - I really need a --disable-sync option but
that's a different feature.

Thanks
Luke



> ---
>  Documentation/git-p4.txt | 14 ++++++++++++++
>  git-p4.py                | 29 +++++++++++++++++++++++------
>  t/t9807-git-p4-submit.sh | 40 ++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 77 insertions(+), 6 deletions(-)
>
> diff --git a/Documentation/git-p4.txt b/Documentation/git-p4.txt
> index d8c8f11c9..88d109deb 100644
> --- a/Documentation/git-p4.txt
> +++ b/Documentation/git-p4.txt
> @@ -149,6 +149,12 @@ To specify a branch other than the current one, use:
>  $ git p4 submit topicbranch
>  ------------
>
> +To specify a single commit or a range of commits, use:
> +------------
> +$ git p4 submit --commit <sha1>
> +$ git p4 submit --commit <sha1..sha1>
> +------------
> +
>  The upstream reference is generally 'refs/remotes/p4/master', but can
>  be overridden using the `--origin=` command-line option.
>
> @@ -330,6 +336,14 @@ These options can be used to modify 'git p4 submit' behavior.
>         p4/master.  See the "Sync options" section above for more
>         information.
>
> +--commit <sha1>|<sha1..sha1>::
> +    Submit only the specified commit or range of commits, instead of the full
> +    list of changes that are in the current Git branch.
> +
> +--disable-rebase::
> +    Disable the automatic rebase after all commits have been successfully
> +    submitted.
> +
>  Rebase options
>  ~~~~~~~~~~~~~~
>  These options can be used to modify 'git p4 rebase' behavior.
> diff --git a/git-p4.py b/git-p4.py
> index 7bb9cadc6..f4a6f3b4c 100755
> --- a/git-p4.py
> +++ b/git-p4.py
> @@ -1352,7 +1352,12 @@ 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("--commit", dest="commit", metavar="COMMIT",
> +                                     help="submit only the specified commit(s), one commit or xxx..xxx"),
> +                optparse.make_option("--disable-rebase", dest="disable_rebase", action="store_true",
> +                                     help="Disable rebase after submit is completed. Can be useful if you "
> +                                     "work from a local git branch that is not master")
>          ]
>          self.description = "Submit changes from git to the perforce depot."
>          self.usage += " [name of git branch to submit into perforce depot]"
> @@ -1362,6 +1367,8 @@ class P4Submit(Command, P4UserMap):
>          self.dry_run = False
>          self.shelve = False
>          self.update_shelve = list()
> +        self.commit = ""
> +        self.disable_rebase = False
>          self.prepare_p4_only = False
>          self.conflict_behavior = None
>          self.isWindows = (platform.system() == "Windows")
> @@ -2103,9 +2110,18 @@ 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.commit != "":
> +            if self.commit.find("..") != -1:
> +                limits_ish = self.commit.split("..")
> +                for line in read_pipe_lines(["git", "rev-list", "--no-merges", "%s..%s" % (limits_ish[0], limits_ish[1])]):
> +                    commits.append(line.strip())
> +                commits.reverse()
> +            else:
> +                commits.append(self.commit)
> +        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 +2231,9 @@ class P4Submit(Command, P4UserMap):
>                  sync.branch = self.branch
>              sync.run([])
>
> -            rebase = P4Rebase()
> -            rebase.rebase()
> +            if self.disable_rebase is False:
> +                rebase = P4Rebase()
> +                rebase.rebase()
>
>          else:
>              if len(applied) == 0:
> diff --git a/t/t9807-git-p4-submit.sh b/t/t9807-git-p4-submit.sh
> index 71cae2874..2325599ee 100755
> --- a/t/t9807-git-p4-submit.sh
> +++ b/t/t9807-git-p4-submit.sh
> @@ -155,6 +155,46 @@ test_expect_success 'allow submit from branch with same revision but different n
>         )
>  '
>
> +# make two commits, but tell it to apply only one
> +
> +test_expect_success 'submit --commit one' '
> +       test_when_finished cleanup_git &&
> +       git p4 clone --dest="$git" //depot &&
> +       (
> +               cd "$git" &&
> +               test_commit "file9" &&
> +               test_commit "file10" &&
> +               git config git-p4.skipSubmitEdit true &&
> +               git p4 submit --commit HEAD
> +       ) &&
> +       (
> +               cd "$cli" &&
> +               test_path_is_missing "file9.t" &&
> +               test_path_is_file "file10.t"
> +       )
> +'
> +
> +# make three commits, but tell it to apply only range
> +
> +test_expect_success 'submit --commit range' '
> +       test_when_finished cleanup_git &&
> +       git p4 clone --dest="$git" //depot &&
> +       (
> +               cd "$git" &&
> +               test_commit "file11" &&
> +               test_commit "file12" &&
> +               test_commit "file13" &&
> +               git config git-p4.skipSubmitEdit true &&
> +               git p4 submit --commit HEAD~2..HEAD
> +       ) &&
> +       (
> +               cd "$cli" &&
> +               test_path_is_missing "file11.t" &&
> +               test_path_is_file "file12.t" &&
> +               test_path_is_file "file13.t"
> +       )
> +'
> +
>  #
>  # Basic submit tests, the five handled cases
>  #
> --
> 2.17.0
>

       reply	other threads:[~2018-05-18 11:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20180509153212.2681-1-merlorom@yahoo.fr>
2018-05-18 11:54 ` Luke Diamand [this message]
2018-05-21  7:01   ` [PATCH] git-p4: add options --commit and --disable-rebase Junio C Hamano
     [not found] <569077545.8373111.1525739857273.ref@mail.yahoo.com>
     [not found] ` <569077545.8373111.1525739857273@mail.yahoo.com>
2018-05-09  8:20   ` 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_U_8TqsWQbCBrATkrOpyAkE2sdgj3KXdovLw7rsXtt6A@mail.gmail.com \
    --to=luke@diamand.org \
    --cc=Matthieu.Moy@imag.fr \
    --cc=cedric.borgese@gmail.com \
    --cc=fabien.boutantin@pdgm.com \
    --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).