[PATCH] git p4 submit: Add --{skip-,}edit-submit option

2014-02-26 Thread Crestez Dan Leonard

This allows skipping interactively editting the p4 changelist before
submit. This is useful for pushing series of patches to p4 quickly.

This was already possible through a config option.

Signed-off-by: Crestez Dan Leonard cdleon...@gmail.com
---
 Documentation/git-p4.txt |  4 
 git-p4.py| 11 ++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/Documentation/git-p4.txt b/Documentation/git-p4.txt
index 6ab5f94..619f45f 100644
--- a/Documentation/git-p4.txt
+++ b/Documentation/git-p4.txt
@@ -299,6 +299,10 @@ These options can be used to modify 'git p4 submit' behavior.
 	to bypass the prompt, causing conflicting commits to be automatically
 	skipped, or to quit trying to apply commits, without prompting.
 
+--skip-submit-edit --edit-submit::
+	Edit the changelist before template or not. This defaults to true,
+	unless overridden by the git-p4.skipSubmitEdit config option.
+
 --branch branch::
 	After submitting, sync this named branch instead of the default
 	p4/master.  See the Sync options section above for more
diff --git a/git-p4.py b/git-p4.py
index cdfa2df..cafd997 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -998,6 +998,10 @@ class P4Submit(Command, P4UserMap):
 optparse.make_option(--prepare-p4-only, dest=prepare_p4_only, action=store_true),
 optparse.make_option(--conflict, dest=conflict_behavior,
  choices=self.conflict_behavior_choices),
+optparse.make_option(--skip-edit-submit, dest=edit_submit, action=store_true,
+help=Skip editting the changelist before submit),
+optparse.make_option(--edit-submit, dest=edit_submit, action=store_false,
+help=Edit the changelist before submit (default)),
 optparse.make_option(--branch, dest=branch),
 ]
 self.description = Submit changes from git to the perforce depot.
@@ -1203,12 +1207,17 @@ class P4Submit(Command, P4UserMap):
 
 return template
 
+def get_edit_submit_value(self):
+if hasattr(self, 'edit_submit'):
+return self.edit_submit
+return gitConfigBool('git-p4.skipSubmitEdit')
+
 def edit_template(self, template_file):
 Invoke the editor to let the user change the submission
message.  Return true if okay to continue with the submit.
 
 # if configured to skip the editing part, just submit
-if gitConfigBool(git-p4.skipSubmitEdit):
+if self.get_edit_submit_value():
 return True
 
 # look at the modification time, to check later if the user saved


[PATCH] git p4: Use git diff-tree instead of format-patch

2013-11-21 Thread Crestez Dan Leonard


The output of git format-patch can vary with user preferences. In
particular setting diff.noprefix will break the git apply that
is done as part of git p4 submit.

Signed-off-by: Crestez Dan Leonard cdleon...@gmail.com
---
 git-p4.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


diff --git a/git-p4.py b/git-p4.py
index 31e71ff..fe988ce 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -1308,7 +1308,7 @@ class P4Submit(Command, P4UserMap):
 else:
 die(unknown modifier %s for %s % (modifier, path))
 
-diffcmd = git format-patch -k --stdout \%s^\..\%s\ % (id, id)
+diffcmd = git diff-tree -p \%s\ % (id)
 patchcmd = diffcmd +  | git apply 
 tryPatchCmd = patchcmd + --check -
 applyPatchCmd = patchcmd + --check --apply -