]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'ls/p4-map-user'
authorJunio C Hamano <gitster@pobox.com>
Wed, 6 Apr 2016 18:39:05 +0000 (11:39 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 6 Apr 2016 18:39:05 +0000 (11:39 -0700)
"git p4" now allows P4 author names to be mapped to Git author
names.

* ls/p4-map-user:
  git-p4: map a P4 user to Git author name and email address

1  2 
Documentation/git-p4.txt
git-p4.py

diff --combined Documentation/git-p4.txt
index 35e31709181d42f2e20bb2e818601628c03b7168,9f077fd6f4866eccbb678fdc805aca02ba293d7f..88ba42b4550a1ac7b579c48445f5933aaf13a20a
@@@ -515,18 -515,20 +515,18 @@@ git-p4.pathEncoding:
        Git expects paths encoded as UTF-8. Use this config to tell git-p4
        what encoding Perforce had used for the paths. This encoding is used
        to transcode the paths to UTF-8. As an example, Perforce on Windows
 -      often uses “cp1252” to encode path names.
 +      often uses "cp1252" to encode path names.
  
  git-p4.largeFileSystem::
        Specify the system that is used for large (binary) files. Please note
        that large file systems do not support the 'git p4 submit' command.
 -      Only Git LFS [1] is implemented right now. Download
 -      and install the Git LFS command line extension to use this option
 -      and configure it like this:
 +      Only Git LFS is implemented right now (see https://git-lfs.github.com/
 +      for more information). Download and install the Git LFS command line
 +      extension to use this option and configure it like this:
  +
  -------------
  git config       git-p4.largeFileSystem GitLFS
  -------------
 -+
 -      [1] https://git-lfs.github.com/
  
  git-p4.largeFileExtensions::
        All files matching a file extension in the list will be processed
@@@ -551,6 -553,17 +551,17 @@@ git-p4.keepEmptyCommits:
        A changelist that contains only excluded files will be imported
        as an empty commit if this boolean option is set to true.
  
+ git-p4.mapUser::
+       Map a P4 user to a name and email address in Git. Use a string
+       with the following format to create a mapping:
+ +
+ -------------
+ git config --add git-p4.mapUser "p4user = First Last <mail@address.com>"
+ -------------
+ +
+ A mapping will override any user information from P4. Mappings for
+ multiple P4 user can be defined.
  Submit variables
  ~~~~~~~~~~~~~~~~
  git-p4.detectRenames::
diff --combined git-p4.py
index 825b9f32d5540ab1f8d373fff2d3bf79caabee00,bac341d04c456ba17474592f51baa8161c435542..527d44bd202745d29680fe74833c29cc7fb122c1
+++ b/git-p4.py
@@@ -253,8 -253,8 +253,8 @@@ def p4_add(f)
  def p4_delete(f):
      p4_system(["delete", wildcard_encode(f)])
  
 -def p4_edit(f):
 -    p4_system(["edit"wildcard_encode(f)])
 +def p4_edit(f, *options):
 +    p4_system(["edit"] + list(options) + [wildcard_encode(f)])
  
  def p4_revert(f):
      p4_system(["revert", wildcard_encode(f)])
@@@ -1160,6 -1160,15 +1160,15 @@@ class P4UserMap
              self.users[output["User"]] = output["FullName"] + " <" + output["Email"] + ">"
              self.emails[output["Email"]] = output["User"]
  
+         mapUserConfigRegex = re.compile(r"^\s*(\S+)\s*=\s*(.+)\s*<(\S+)>\s*$", re.VERBOSE)
+         for mapUserConfig in gitConfigList("git-p4.mapUser"):
+             mapUser = mapUserConfigRegex.findall(mapUserConfig)
+             if mapUser and len(mapUser[0]) == 3:
+                 user = mapUser[0][0]
+                 fullname = mapUser[0][1]
+                 email = mapUser[0][2]
+                 self.users[user] = fullname + " <" + email + ">"
+                 self.emails[email] = user
  
          s = ''
          for (key, val) in self.users.items():
@@@ -1554,7 -1563,6 +1563,7 @@@ class P4Submit(Command, P4UserMap)
  
          diff = read_pipe_lines("git diff-tree -r %s \"%s^\" \"%s\"" % (self.diffOpts, id, id))
          filesToAdd = set()
 +        filesToChangeType = set()
          filesToDelete = set()
          editedFiles = set()
          pureRenameCopy = set()
                      os.unlink(dest)
                      filesToDelete.add(src)
                  editedFiles.add(dest)
 +            elif modifier == "T":
 +                filesToChangeType.add(path)
              else:
                  die("unknown modifier %s for %s" % (modifier, path))
  
          #
          system(applyPatchCmd)
  
 +        for f in filesToChangeType:
 +            p4_edit(f, "-t", "auto")
          for f in filesToAdd:
              p4_add(f)
          for f in filesToDelete: