From: Pete Wyckoff <pw@padd.com>
To: git@vger.kernel.org
Subject: [PATCH 11/11] git-p4: document and test submit options
Date: Sat, 17 Dec 2011 13:52:22 -0500 [thread overview]
Message-ID: <1324147942-21558-12-git-send-email-pw@padd.com> (raw)
In-Reply-To: <1324147942-21558-1-git-send-email-pw@padd.com>
Clarify there is a -M option, but no -C. These are both
configurable through variables.
Explain that the allowSubmit variable takes a comma-separated
list of branch names.
Catch earlier an invalid branch name given as an argument to
"git p4 clone".
Test option --origin, variable allowSubmit, and explicit master
branch name.
Signed-off-by: Pete Wyckoff <pw@padd.com>
---
Documentation/git-p4.txt | 8 +++++-
contrib/fast-import/git-p4 | 7 +++++
t/t9807-submit.sh | 54 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 67 insertions(+), 2 deletions(-)
diff --git a/Documentation/git-p4.txt b/Documentation/git-p4.txt
index 3092571..f97b1c5 100644
--- a/Documentation/git-p4.txt
+++ b/Documentation/git-p4.txt
@@ -267,7 +267,9 @@ These options can be used to modify 'git p4 submit' behavior.
-M[<n>]::
Detect renames. See linkgit:git-diff[1]. Renames will be
- represented in p4 using explicit 'move' operations.
+ represented in p4 using explicit 'move' operations. There
+ is no corresponding option to detect copies, but there are
+ variables for both moves and copies.
--preserve-user::
Re-author p4 changes before submitting to p4. This option
@@ -453,7 +455,9 @@ git-p4.skipSubmitEditCheck::
git-p4.allowSubmit::
By default, any branch can be used as the source for a 'git p4
submit' operation. This configuration variable, if set, permits only
- the named branches to be used as submit sources.
+ the named branches to be used as submit sources. Branch names
+ must be the short names (no "refs/heads/"), and should be
+ separated by commas (","), with no spaces.
git-p4.skipUserNameCheck::
If the user running 'git p4 submit' does not exist in the p4
diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index 2d07e93..883d0b5 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -362,6 +362,11 @@ def isValidGitDir(path):
def parseRevision(ref):
return read_pipe("git rev-parse %s" % ref).strip()
+def branchExists(ref):
+ rev = read_pipe(["git", "rev-parse", "-q", "--verify", ref],
+ ignore_error=True)
+ return len(rev) > 0
+
def extractLogMessageFromGitCommit(commit):
logMessage = ""
@@ -1085,6 +1090,8 @@ class P4Submit(Command, P4UserMap):
die("Detecting current git branch failed!")
elif len(args) == 1:
self.master = args[0]
+ if not branchExists(self.master):
+ die("Branch %s does not exist" % self.master)
else:
return False
diff --git a/t/t9807-submit.sh b/t/t9807-submit.sh
index 2cb724e..b1f61e3 100755
--- a/t/t9807-submit.sh
+++ b/t/t9807-submit.sh
@@ -31,6 +31,60 @@ test_expect_success 'submit with no client dir' '
)
'
+# make two commits, but tell it to apply only from HEAD^
+test_expect_success 'submit --origin' '
+ test_when_finished cleanup_git &&
+ "$GITP4" clone --dest="$git" //depot &&
+ (
+ cd "$git" &&
+ test_commit "file3" &&
+ test_commit "file4" &&
+ git config git-p4.skipSubmitEdit true &&
+ "$GITP4" submit --origin=HEAD^
+ ) &&
+ (
+ cd "$cli" &&
+ p4 sync &&
+ test_path_is_missing "file3.t" &&
+ test_path_is_file "file4.t"
+ )
+'
+
+test_expect_success 'submit with allowSubmit' '
+ test_when_finished cleanup_git &&
+ "$GITP4" clone --dest="$git" //depot &&
+ (
+ cd "$git" &&
+ test_commit "file5" &&
+ git config git-p4.skipSubmitEdit true &&
+ git config git-p4.allowSubmit "nobranch" &&
+ test_must_fail "$GITP4" submit &&
+ git config git-p4.allowSubmit "nobranch,master" &&
+ "$GITP4" submit
+ )
+'
+
+test_expect_success 'submit with master branch name from argv' '
+ test_when_finished cleanup_git &&
+ "$GITP4" clone --dest="$git" //depot &&
+ (
+ cd "$git" &&
+ test_commit "file6" &&
+ git config git-p4.skipSubmitEdit true &&
+ test_must_fail "$GITP4" submit nobranch &&
+ git branch otherbranch &&
+ git reset --hard HEAD^ &&
+ test_commit "file7" &&
+ "$GITP4" submit otherbranch
+ ) &&
+ (
+ cd "$cli" &&
+ p4 sync &&
+ test_path_is_file "file6.t" &&
+ test_path_is_missing "file7.t"
+ )
+'
+
test_expect_success 'kill p4d' '
kill_p4d
'
--
1.7.8.258.g45cc3c
next prev parent reply other threads:[~2011-12-17 18:57 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-17 18:52 [PATCH 00/11] git-p4: asciidoc documentation and fixes Pete Wyckoff
2011-12-17 18:52 ` [PATCH 01/11] git-p4: introduce asciidoc documentation Pete Wyckoff
2011-12-17 18:52 ` [PATCH 02/11] git-p4: test debug macro Pete Wyckoff
2011-12-17 22:43 ` Luke Diamand
2011-12-18 1:36 ` [PATCHv2 " Pete Wyckoff
2011-12-18 3:26 ` Jonathan Nieder
2011-12-18 13:50 ` Pete Wyckoff
2011-12-18 14:06 ` [PATCHv3 " Pete Wyckoff
2011-12-18 17:10 ` Luke Diamand
2011-12-18 21:48 ` Junio C Hamano
2011-12-20 1:35 ` Pete Wyckoff
2011-12-17 18:52 ` [PATCH 03/11] git-p4: clone does not use --git-dir Pete Wyckoff
2011-12-17 18:52 ` [PATCH 04/11] git-p4: test cloning with two dirs, clarify doc Pete Wyckoff
2011-12-17 18:52 ` [PATCH 05/11] git-p4: document and test clone --branch Pete Wyckoff
2011-12-17 18:52 ` [PATCH 06/11] git-p4: honor --changesfile option and test Pete Wyckoff
2011-12-17 18:52 ` [PATCH 07/11] git-p4: document and test --import-local Pete Wyckoff
2011-12-17 18:52 ` [PATCH 08/11] git-p4: test --max-changes Pete Wyckoff
2011-12-17 18:52 ` [PATCH 09/11] git-p4: test --keep-path Pete Wyckoff
2011-12-17 18:52 ` [PATCH 10/11] git-p4: test and document --use-client-spec Pete Wyckoff
2011-12-17 18:52 ` Pete Wyckoff [this message]
-- strict thread matches above, loose matches on Subject: below --
2011-12-25 2:07 [PATCHv3 00/11] git-p4: asciidoc documentation and fixes Pete Wyckoff
2011-12-25 2:07 ` [PATCH 11/11] git-p4: document and test submit options Pete Wyckoff
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1324147942-21558-12-git-send-email-pw@padd.com \
--to=pw@padd.com \
--cc=git@vger.kernel.org \
/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.
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 NNTP newsgroup(s).