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

[PATCH v3] git-p4: add option to preserve user names

From
Luke Diamand <luke@diamand.org>
Date
May 5, 2011, 06:43 UTC
Message-ID
<1304577819-703-1-git-send-email-luke@diamand.org>

This is version 3 of my patch. It's almost the same as the previous one, except that:

 - it skips changing the user if the user field is already
   correct
 - it puts a comment into the submit template saying what
   the user will be changed to (so you know it hasn't
   forgotten).
 - fixes a bug in actually forming the changespec (I think
   it was relying on the way python orders dictionaries).
---

Patches from git passed into p4 end up with the committer being identified as the person who ran git-p4.

This patch adds an option --preserve-user. When enabled, git-p4 will modify the changelist after it has been submitted ("p4 change -f") and set the username to the one matching the git author.

If the person running git-p4 does not have sufficient permissions, git-p4 will refuse to run (detected using "p4 protects"). It's possible that complicated permissions setups might confuse git-p4 - it just looks to see if the user has admin or super on the repo. In theory they might have permissions in some parts and not in others.

If there are commits with authors who do not have p4 accounts, then git-p4 will refuse to run unless git-p4.allowMissingP4Users is true, in which case it falls back to the standard behaviour for those commits.

The code has to get the p4 changelist number. The way it does this is by simply doing 'p4 changes -c <client>', which means if someone else is using the same clientspec at the same time, there is a potential race hazard. The alternative is to rewrite the submit logic to submit a properly marshalled template, which felt a bit too intrusive.

I've hoisted the p4 user name cache to a separate class, since it gets used in a couple of different places now.

I've added an option git-p4.skipSubmitModTimeCheck so that I can write a test case without having to jump through hoops with the editor.

Luke Diamand (1):
  git-p4: add option to preserve user names
 contrib/fast-import/git-p4     |  188 ++++++++++++++++++++++++++++++++--------
 contrib/fast-import/git-p4.txt |   29 ++++++
 t/t9800-git-p4.sh              |   84 ++++++++++++++++++
 3 files changed, 263 insertions(+), 38 deletions(-)
Next: Luke Diamand
Message 1 of 9 in “git-p4: add option to preserve user names”
  1. git-p4: add option to preserve user namesLuke Diamand, May 5, 2011
  2. git-p4: add option to preserve user namesLuke Diamand, May 5, 2011
  3. Junio C HamanoMay 6, 2011
  4. Luke DiamandMay 6, 2011
  5. Pete WyckoffMay 6, 2011
  6. Junio C HamanoMay 7, 2011
  7. Luke DiamandMay 8, 2011
  8. Junio C HamanoMay 8, 2011
  9. Luke DiamandMay 8, 2011

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.