{"thread":{"id":"41559","subject":"[PATCH v1] git-p4: map a P4 user to Git author name and email address","startedAt":"2016-02-28T10:25:25Z","lastAt":"2016-02-29T05:31:03Z","messageCount":6,"participants":["larsxschneider@gmail.com","Eric Sunshine","Lars Schneider","Luke Diamand","Torsten Bögershausen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"279705","messageId":"1456655125-17829-1-git-send-email-larsxschneider@gmail.com","threadId":"41559","inReplyTo":null,"subject":"[PATCH v1] git-p4: map a P4 user to Git author name and email address","fromName":"","fromEmail":"larsxschneider@gmail.com","sentAt":"2016-02-28T10:25:25Z","receivedAt":"2016-02-28T10:25:25Z","isPatch":true,"sender":{"key":"larsxschneider@gmail.com","avatar":"https://avatars.githubusercontent.com/u/477434?v=4"},"body":"From: Lars Schneider <lars.schneider@autodesk.com>\n\nMap a P4 user to a specific name and email address in Git with the\n\"git-p4.mapUser\" config. The config value must be a string adhering\nto the format \"p4user -> First Lastname <email@address.com>\".\n\nSigned-off-by: Lars Schneider <larsxschneider@gmail.com>\n---\n Documentation/git-p4.txt   | 11 +++++++++\n git-p4.py                  |  9 +++++++\n t/t9828-git-p4-map-user.sh | 61 ++++++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 81 insertions(+)\n create mode 100755 t/t9828-git-p4-map-user.sh\n\ndiff --git a/Documentation/git-p4.txt b/Documentation/git-p4.txt\nindex 738cfde..b453e79 100644\n--- a/Documentation/git-p4.txt\n+++ b/Documentation/git-p4.txt\n@@ -553,6 +553,17 @@ git-p4.keepEmptyCommits::\n \tA changelist that contains only excluded files will be imported\n \tas an empty commit if this boolean option is set to true.\n \n+git-p4.mapUser::\n+\tMap a P4 user to a name and email address in Git. Use a string\n+\twith the following format to create a mapping:\n++\n+-------------\n+git config --add git-p4.mapUser \"p4user -> First Last <mail@address.com>\"\n+-------------\n++\n+\tA mapping will override any user information from P4. Mappings for\n+\tmultiple P4 user can be defined.\n+\n Submit variables\n ~~~~~~~~~~~~~~~~\n git-p4.detectRenames::\ndiff --git a/git-p4.py b/git-p4.py\nindex c33dece..97e4334 100755\n--- a/git-p4.py\n+++ b/git-p4.py\n@@ -1160,6 +1160,15 @@ class P4UserMap:\n             self.users[output[\"User\"]] = output[\"FullName\"] + \" <\" + output[\"Email\"] + \">\"\n             self.emails[output[\"Email\"]] = output[\"User\"]\n \n+        mapUserConfigRegex = re.compile(r\"^(\\S+)\\s->\\s(.+)\\s<(\\S+)>$\", re.VERBOSE)\n+        for mapUserConfig in gitConfigList(\"git-p4.mapUser\"):\n+            mapUser = mapUserConfigRegex.findall(mapUserConfig)\n+            if mapUser and len(mapUser[0]) == 3:\n+                user = mapUser[0][0]\n+                fullname = mapUser[0][1]\n+                email = mapUser[0][2]\n+                self.users[user] = fullname + \" <\" + email + \">\"\n+                self.emails[email] = user\n \n         s = ''\n         for (key, val) in self.users.items():\ndiff --git a/t/t9828-git-p4-map-user.sh b/t/t9828-git-p4-map-user.sh\nnew file mode 100755\nindex 0000000..daf2567\n--- /dev/null\n+++ b/t/t9828-git-p4-map-user.sh\n@@ -0,0 +1,61 @@\n+#!/bin/sh\n+\n+test_description='Clone repositories and map users'\n+\n+. ./lib-git-p4.sh\n+\n+test_expect_success 'start p4d' '\n+\tstart_p4d\n+'\n+\n+test_expect_success 'Create a repo with different users' '\n+\tclient_view \"//depot/... //client/...\" &&\n+\t(\n+\t\tcd \"$cli\" &&\n+\n+\t\t>author.txt &&\n+\t\tp4 add author.txt &&\n+\t\tp4 submit -d \"Add file author\\\\n\"\n+\n+\t\tP4USER=mmax\n+\t\t>max.txt &&\n+\t\tp4 add max.txt &&\n+\t\tp4 submit -d \"Add file max\"\n+\n+\t\tP4USER=mo\n+\t\t>moritz.txt &&\n+\t\tp4 add moritz.txt &&\n+\t\tp4 submit -d \"Add file moritz\"\n+\n+\t\tP4USER=no\n+\t\t>nobody.txt &&\n+\t\tp4 add nobody.txt &&\n+\t\tp4 submit -d \"Add file nobody\"\n+\t)\n+'\n+\n+test_expect_success 'Clone repo root path with all history' '\n+\tclient_view \"//depot/... //client/...\" &&\n+\ttest_when_finished cleanup_git &&\n+\t(\n+\t\tcd \"$git\" &&\n+\t\tgit init . &&\n+\t\tgit config --add git-p4.mapUser \"mmax -> Max Mustermann <max@muster.com>\"  &&\n+\t\tgit config --add git-p4.mapUser \"mo -> Moritz Untreu <moritz@untreu.com>\" &&\n+\t\tgit p4 clone --use-client-spec --destination=\"$git\" //depot@all &&\n+\t\tcat >expect <<-\\EOF &&\n+\t\t\tno <no@client>\n+\t\t\tMoritz Untreu <moritz@untreu.com>\n+\t\t\tMax Mustermann <max@muster.com>\n+\t\t\tDr. author <author@example.com>\n+\t\tEOF\n+\t\tgit log --format=\"%an <%ae>\" >actual &&\n+\t\ttest_cmp expect actual\n+\t)\n+'\n+\n+test_expect_success 'kill p4d' '\n+\tkill_p4d\n+'\n+\n+test_done\n-- \n2.5.1\n"},{"id":"279717","messageId":"CAPig+cTCZ_diLH+tge6bis6gjq0Qvk05zD7zqf1PBJxNTJu9bw@mail.gmail.com","threadId":"41559","inReplyTo":"1456655125-17829-1-git-send-email-larsxschneider@gmail.com","subject":"Re: [PATCH v1] git-p4: map a P4 user to Git author name and email address","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2016-02-28T16:19:59Z","receivedAt":"2016-02-28T16:19:59Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sun, Feb 28, 2016 at 5:25 AM,  <larsxschneider@gmail.com> wrote:\n> Map a P4 user to a specific name and email address in Git with the\n> \"git-p4.mapUser\" config. The config value must be a string adhering\n> to the format \"p4user -> First Lastname <email@address.com>\".\n\nWith the caveat that I'm not a Perforce user, is this arrow \"->\"\nthingy common in the Perforce world, or was it invented with this\npatch? If it was invented here, then would it make sense to instead\nuse a more established format, such as the \"authors\" mapping file from\ngit-svn?\n\n    p4user = Joe User <user@example.com>\n\nMore below...\n\n> Signed-off-by: Lars Schneider <larsxschneider@gmail.com>\n> ---\n> diff --git a/Documentation/git-p4.txt b/Documentation/git-p4.txt\n> @@ -553,6 +553,17 @@ git-p4.keepEmptyCommits::\n> +git-p4.mapUser::\n> +       Map a P4 user to a name and email address in Git. Use a string\n> +       with the following format to create a mapping:\n> ++\n> +-------------\n> +git config --add git-p4.mapUser \"p4user -> First Last <mail@address.com>\"\n> +-------------\n> ++\n> +       A mapping will override any user information from P4. Mappings for\n> +       multiple P4 user can be defined.\n\nDoes this format correctly with Asciidoc, or does the pargraph need to\nbe left-justified? (I haven't tested it myself.)\n\n> diff --git a/t/t9828-git-p4-map-user.sh b/t/t9828-git-p4-map-user.sh\n> @@ -0,0 +1,61 @@\n> +#!/bin/sh\n> +\n> +test_description='Clone repositories and map users'\n> +\n> +. ./lib-git-p4.sh\n> +\n> +test_expect_success 'start p4d' '\n> +       start_p4d\n> +'\n> +\n> +test_expect_success 'Create a repo with different users' '\n> +       client_view \"//depot/... //client/...\" &&\n> +       (\n> +               cd \"$cli\" &&\n> +\n> +               >author.txt &&\n> +               p4 add author.txt &&\n> +               p4 submit -d \"Add file author\\\\n\"\n\nBroken &&-chain.\n\n> +               P4USER=mmax\n\nDitto.\n\n> +               >max.txt &&\n> +               p4 add max.txt &&\n> +               p4 submit -d \"Add file max\"\n\nDitto.\n\n> +               P4USER=mo\n\nDitto.\n\n> +               >moritz.txt &&\n> +               p4 add moritz.txt &&\n> +               p4 submit -d \"Add file moritz\"\n\n...\n\n> +               P4USER=no\n\n...\n\n> +               >nobody.txt &&\n> +               p4 add nobody.txt &&\n> +               p4 submit -d \"Add file nobody\"\n> +       )\n> +'\n> +\n> +test_expect_success 'Clone repo root path with all history' '\n> +       client_view \"//depot/... //client/...\" &&\n> +       test_when_finished cleanup_git &&\n> +       (\n> +               cd \"$git\" &&\n> +               git init . &&\n> +               git config --add git-p4.mapUser \"mmax -> Max Mustermann <max@muster.com>\"  &&\n> +               git config --add git-p4.mapUser \"mo -> Moritz Untreu <moritz@untreu.com>\" &&\n> +               git p4 clone --use-client-spec --destination=\"$git\" //depot@all &&\n> +               cat >expect <<-\\EOF &&\n> +                       no <no@client>\n> +                       Moritz Untreu <moritz@untreu.com>\n> +                       Max Mustermann <max@muster.com>\n> +                       Dr. author <author@example.com>\n> +               EOF\n> +               git log --format=\"%an <%ae>\" >actual &&\n> +               test_cmp expect actual\n> +       )\n> +'\n> +\n> +test_expect_success 'kill p4d' '\n> +       kill_p4d\n> +'\n> +\n> +test_done\n> --\n> 2.5.1\n"},{"id":"279718","messageId":"F97BFD52-C258-4B8C-A380-6F0240FDE7F8@gmail.com","threadId":"41559","inReplyTo":"CAPig+cTCZ_diLH+tge6bis6gjq0Qvk05zD7zqf1PBJxNTJu9bw@mail.gmail.com","subject":"Re: [PATCH v1] git-p4: map a P4 user to Git author name and email address","fromName":"Lars Schneider","fromEmail":"larsxschneider@gmail.com","sentAt":"2016-02-28T17:05:54Z","receivedAt":"2016-02-28T17:05:54Z","isPatch":true,"sender":{"key":"larsxschneider@gmail.com","avatar":"https://avatars.githubusercontent.com/u/477434?v=4"},"body":"\nOn 28 Feb 2016, at 17:19, Eric Sunshine <sunshine@sunshineco.com> wrote:\n\n> On Sun, Feb 28, 2016 at 5:25 AM,  <larsxschneider@gmail.com> wrote:\n>> Map a P4 user to a specific name and email address in Git with the\n>> \"git-p4.mapUser\" config. The config value must be a string adhering\n>> to the format \"p4user -> First Lastname <email@address.com>\".\n> \n> With the caveat that I'm not a Perforce user, is this arrow \"->\"\n> thingy common in the Perforce world, or was it invented with this\n> patch? If it was invented here, then would it make sense to instead\n> use a more established format, such as the \"authors\" mapping file from\n> git-svn?\n> \n>    p4user = Joe User <user@example.com>\nI invented \"the arrow\" here :-)\nI didn't know about the SVN format and I agree it makes sense to reuse\nan established format. I will fix this in a reroll.\n\n\n> \n> More below...\n> \n>> Signed-off-by: Lars Schneider <larsxschneider@gmail.com>\n>> ---\n>> diff --git a/Documentation/git-p4.txt b/Documentation/git-p4.txt\n>> @@ -553,6 +553,17 @@ git-p4.keepEmptyCommits::\n>> +git-p4.mapUser::\n>> +       Map a P4 user to a name and email address in Git. Use a string\n>> +       with the following format to create a mapping:\n>> ++\n>> +-------------\n>> +git config --add git-p4.mapUser \"p4user -> First Last <mail@address.com>\"\n>> +-------------\n>> ++\n>> +       A mapping will override any user information from P4. Mappings for\n>> +       multiple P4 user can be defined.\n> \n> Does this format correctly with Asciidoc, or does the pargraph need to\n> be left-justified? (I haven't tested it myself.)\nI am not exactly sure what you mean. The last paragraph is already left\njustified, no? Do you know a good tutorial for Asciidoc? How can I/should\nI check these things?\n\n\n> \n>> diff --git a/t/t9828-git-p4-map-user.sh b/t/t9828-git-p4-map-user.sh\n>> @@ -0,0 +1,61 @@\n>> +#!/bin/sh\n>> +\n>> +test_description='Clone repositories and map users'\n>> +\n>> +. ./lib-git-p4.sh\n>> +\n>> +test_expect_success 'start p4d' '\n>> +       start_p4d\n>> +'\n>> +\n>> +test_expect_success 'Create a repo with different users' '\n>> +       client_view \"//depot/... //client/...\" &&\n>> +       (\n>> +               cd \"$cli\" &&\n>> +\n>> +               >author.txt &&\n>> +               p4 add author.txt &&\n>> +               p4 submit -d \"Add file author\\\\n\"\n> \n> Broken &&-chain.\nOh. You're right. Will fix!\n\nThanks for the review,\nLars\n"},{"id":"279738","messageId":"CAPig+cQEzsJT+06bam2o+B1YTOrviHVtzE2LWsrF_bVCWy7+Bw@mail.gmail.com","threadId":"41559","inReplyTo":"F97BFD52-C258-4B8C-A380-6F0240FDE7F8@gmail.com","subject":"Re: [PATCH v1] git-p4: map a P4 user to Git author name and email address","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2016-02-29T03:53:58Z","receivedAt":"2016-02-29T03:53:58Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sun, Feb 28, 2016 at 12:05 PM, Lars Schneider\n<larsxschneider@gmail.com> wrote:\n> On 28 Feb 2016, at 17:19, Eric Sunshine <sunshine@sunshineco.com> wrote:\n>> On Sun, Feb 28, 2016 at 5:25 AM,  <larsxschneider@gmail.com> wrote:\n>>> +git-p4.mapUser::\n>>> +       Map a P4 user to a name and email address in Git. Use a string\n>>> +       with the following format to create a mapping:\n>>> ++\n>>> +-------------\n>>> +git config --add git-p4.mapUser \"p4user -> First Last <mail@address.com>\"\n>>> +-------------\n>>> ++\n>>> +       A mapping will override any user information from P4. Mappings for\n>>> +       multiple P4 user can be defined.\n>>\n>> Does this format correctly with Asciidoc, or does the pargraph need to\n>> be left-justified? (I haven't tested it myself.)\n> I am not exactly sure what you mean. The last paragraph is already left\n> justified, no?\n\nSorry, I meant \"does it need to be flush against the left margin (that\nis column 0)?\" Just picking a file at random, (say\nDocumentation/blame-options.txt), you see quickly that while the first\nparagraph of an entry is indented, subsequent paragraphs belonging to\nthat entry are not.\n\n> Do you know a good tutorial for Asciidoc? How can I/should\n> I check these things?\n\nI haven't looked at tutorial; I've merely consult the Asciidoc\ndocumentation when needed. Assuming you have the Asciidoc toolchain\ninstalled, the easiest way to check if it formats correctly is to run\n\"make html\" and then look at the built Documentation/git-p4.html in a\nbrowser.\n"},{"id":"279740","messageId":"CAE5ih7-oPE1RYrO78TAnkNSi03qtcUK_iiLywoyRC_FAgdwTAg@mail.gmail.com","threadId":"41559","inReplyTo":"1456655125-17829-1-git-send-email-larsxschneider@gmail.com","subject":"Re: [PATCH v1] git-p4: map a P4 user to Git author name and email address","fromName":"Luke Diamand","fromEmail":"luke@diamand.org","sentAt":"2016-02-29T05:12:22Z","receivedAt":"2016-02-29T05:12:22Z","isPatch":true,"sender":{"key":"luke@diamand.org","avatar":"https://avatars.githubusercontent.com/u/5330967?v=4"},"body":"On 28 February 2016 at 10:25,  <larsxschneider@gmail.com> wrote:\n> From: Lars Schneider <lars.schneider@autodesk.com>\n>\n> Map a P4 user to a specific name and email address in Git with the\n> \"git-p4.mapUser\" config. The config value must be a string adhering\n> to the format \"p4user -> First Lastname <email@address.com>\".\n\nSeems generally fine. I agree with Eric's comments about the \"->\"\nformat. One comment below:\n\n> +test_expect_success 'Clone repo root path with all history' '\n> +       client_view \"//depot/... //client/...\" &&\n> +       test_when_finished cleanup_git &&\n> +       (\n> +               cd \"$git\" &&\n> +               git init . &&\n> +               git config --add git-p4.mapUser \"mmax -> Max Mustermann <max@muster.com>\"  &&\n> +               git config --add git-p4.mapUser \"mo -> Moritz Untreu <moritz@untreu.com>\" &&\n\nProbably better to use more innocuous names. I'm not sure who these\npeople are, but they might not appreciate being recorded forver in a\ngit-p4 test script.\n\nLuke\n"},{"id":"279741","messageId":"56D3D797.2040401@web.de","threadId":"41559","inReplyTo":"CAE5ih7-oPE1RYrO78TAnkNSi03qtcUK_iiLywoyRC_FAgdwTAg@mail.gmail.com","subject":"Re: [PATCH v1] git-p4: map a P4 user to Git author name and email address","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2016-02-29T05:31:03Z","receivedAt":"2016-02-29T05:31:03Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"\n+       (\n+               cd \"$git\" &&\n+               git init . &&\n+               git config --add git-p4.mapUser \"mmax -> Max Mustermann <max@muster.com>\"  &&\n+               git config --add git-p4.mapUser \"mo -> Moritz Untreu <moritz@untreu.com>\" &&\n\n> Probably better to use more innocuous names. I'm not sure who these\n> people are, but they might not appreciate being recorded forver in a\n> git-p4 test script.\n>\n>\nA better name could be\nMax Musterman <max@example.com>\nErika Musterman <erika@example.com>\n"}]}