git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Add 'git-p4.allowSubmit' to git-p4

From
JXJing Xue <jingxue@digizenstudio.com>
Date
Jun 22, 2008, 18:12 UTC
Message-ID
<20080622181239.GA1855@jabba.hq.digizenstudio.com>

I'm working with a perforce repo using git-p4. There are some config files which I need to change locally according to my environment. I'm using a 'local' git branch to park these changes. And I want to avoid accidentally checking them into p4 just by doing "git p4 submit" mindlessly without realizing which branch I'm actually on.

This patch adds a new git config, 'git-p4.allowSubmit', which is a whitelist of branch names. "git p4 submit" will only allow submissions from local branches on the list. Useful for preventing inadvertently submitting from a strictly local branch.

For backward compatibility, if this config is not set at all, submissions from all branches are allowed.

Signed-off-by: Jing Xue <jingxue@digizenstudio.com>
---
 contrib/fast-import/git-p4 |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index d8de9f6..87ca51e 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -687,6 +687,10 @@ class P4Submit(Command):
         else:
             return False
 
+        allowSubmit = gitConfig("git-p4.allowSubmit")
+        if len(allowSubmit) > 0 and not self.master in allowSubmit.split(","):
+            die("%s is not in git-p4.allowSubmit" % self.master)
+
         [upstream, settings] = findUpstreamBranchPoint()
         self.depotPath = settings['depot-paths'][0]
         if len(self.origin) == 0:
-- 
1.5.6.13.g2ae4ef
Next: Simon Hausmann
Message 1 of 3 in “Add 'git-p4.allowSubmit' to git-p4”
  1. Add 'git-p4.allowSubmit' to git-p4Jing Xue, Jun 22, 2008
  2. Simon HausmannJun 26, 2008
  3. Junio C HamanoJun 26, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.