{"thread":{"id":"58170","subject":"git: detect file creator","startedAt":"2022-07-15T12:39:32Z","lastAt":"2022-07-22T06:11:53Z","messageCount":6,"participants":["Sim Tov","Ævar Arnfjörð Bjarmason","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"459141","messageId":"CA+X_a+ycefqvz0LaO0KK1LuTqgE=iUhooPRXeo3mq-zXkp+nCA@mail.gmail.com","threadId":"58170","inReplyTo":null,"subject":"git: detect file creator","fromName":"Sim Tov","fromEmail":"smntov@gmail.com","sentAt":"2022-07-15T12:39:04Z","receivedAt":"2022-07-15T12:39:32Z","isPatch":false,"sender":{"key":"smntov@gmail.com","avatar":null},"body":"Hello,\n\nI run a book digitizing project and pay people certain rate per 10K\ncharacters for the text files they upload to a git repo. Till now I\nwas using following command to detect files authored by CertainEditor:\n\n    git log --use-mailmap --no-merges --author=\"CertainEditor\"\n--name-only --pretty=format:\"\"\n\nThen I would pipe this output in `wc -m` and get amount of characters\nauthored by CertainEditor and pay him accordingly. Usually editors do\nnot touch each other's files and everything worked well. However\nrecently one editor spotted a typo in somebody else's file and\ncorrected it. This behavior is actually good and I would like to\nencourage it. However, now the command above lists the corrected file\nalso as his, and so he gets paid for all the characters in the file\nwhile he changed only one of them. This, obviously, is not good.\n\n1. Do you have an idea how can I list all the files **created** (not\nauthored / committed) by a user, so I can implement a fair characters\ncounting?\n\n2. Maybe some commit hooks can be used that will check whether the\nAuthor of a new commit is different from the previous one and if true\n- override it to the previous Author?\n\n3. Those small changes by a non-creator may be left not paid for (as\nthis action is not so intensive and may be reciprocal), but if you\nhave a good idea how I can pay for the \"diff\" the non-creator provides\n- it would be nice! Do you think this \"diff\" should be deducted from\nthe creator? And if yes - how?\n\nThank you!\n"},{"id":"459146","messageId":"220715.86fsj2zeqn.gmgdl@evledraar.gmail.com","threadId":"58170","inReplyTo":"CA+X_a+ycefqvz0LaO0KK1LuTqgE=iUhooPRXeo3mq-zXkp+nCA@mail.gmail.com","subject":"Re: git: detect file creator","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-07-15T13:22:23Z","receivedAt":"2022-07-15T13:29:18Z","isPatch":false,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Fri, Jul 15 2022, Sim Tov wrote:\n\n> Hello,\n>\n> I run a book digitizing project and pay people certain rate per 10K\n> characters for the text files they upload to a git repo. Till now I\n\nIt's nice to see that someone still believes in The Mythical Man- Month\n:)\n\n> was using following command to detect files authored by CertainEditor:\n>\n>     git log --use-mailmap --no-merges --author=\"CertainEditor\"\n> --name-only --pretty=format:\"\"\n>\n> Then I would pipe this output in `wc -m` and get amount of characters\n> authored by CertainEditor and pay him accordingly. Usually editors do\n> not touch each other's files and everything worked well. However\n> recently one editor spotted a typo in somebody else's file and\n> corrected it. This behavior is actually good and I would like to\n> encourage it. However, now the command above lists the corrected file\n> also as his, and so he gets paid for all the characters in the file\n> while he changed only one of them. This, obviously, is not good.\n>\n> 1. Do you have an idea how can I list all the files **created** (not\n> authored / committed) by a user, so I can implement a fair characters\n> counting?\n\nIf you want to adapt your current script perhaps --diff-filter helps,\nbut...\n\n> 2. Maybe some commit hooks can be used that will check whether the\n> Author of a new commit is different from the previous one and if true\n> - override it to the previous Author?\n\n..it seems you should fundamentally stop using it, and instead iterate\nover the commits, and pay for a \"diff\". Then you'd get the original\nchange, as well as the change-on-top.\n\n> 3. Those small changes by a non-creator may be left not paid for (as\n> this action is not so intensive and may be reciprocal), but if you\n> have a good idea how I can pay for the \"diff\" the non-creator provides\n> - it would be nice!\n\nJust wc -l on the changed files(s) before & after, and pay the abs()\ndifference.\n\n> Do you think this \"diff\" should be deducted from the creator? And if\n> yes - how?\n\nYou could walk it back with \"git blame\" I guess.\n\nBut you might want to consider the economic & social mis-incentives of\nlifting money from your co-workers coffers by pointing out a mistake to\nthem...\n\n"},{"id":"459215","messageId":"CA+X_a+zbG_CDP6D0zxozRoUmBeWm4dVxQ=xYRqFeWrk+FR5p0g@mail.gmail.com","threadId":"58170","inReplyTo":"220715.86fsj2zeqn.gmgdl@evledraar.gmail.com","subject":"Re: git: detect file creator","fromName":"Sim Tov","fromEmail":"smntov@gmail.com","sentAt":"2022-07-16T21:38:23Z","receivedAt":"2022-07-16T21:38:37Z","isPatch":false,"sender":{"key":"smntov@gmail.com","avatar":null},"body":"Thank you very much, again, for the very useful suggestions!\n\n> > 1. Do you have an idea how can I list all the files **created** (not\n> > authored / committed) by a user, so I can implement a fair characters\n> > counting?\n>\n> If you want to adapt your current script perhaps --diff-filter helps,\n> but...\n\nI added `--diff-filter=AR` to my original command like this:\n\ngit log --use-mailmap --no-merges --diff-filter=AR\n--author=\"CertainEditor\" --name-only --pretty=format:\"\"\n\nand it seems to do the job! May I have missed/messed something here?\n\n> > 2. Maybe some commit hooks can be used that will check whether the\n> > Author of a new commit is different from the previous one and if true\n> > - override it to the previous Author?\n>\n> ..it seems you should fundamentally stop using it, and instead iterate\n> over the commits, and pay for a \"diff\". Then you'd get the original\n> change, as well as the change-on-top.\n\n2.1. Will such iteration over history not more time consuming compared\nto my command?\n2.2. Will it not account for useless \"diff\"s, like add some rubbish,\ndelete that rubbish - and I'll have to pay for it...\n\n> > 3. Those small changes by a non-creator may be left not paid for (as\n> > this action is not so intensive and may be reciprocal), but if you\n> > have a good idea how I can pay for the \"diff\" the non-creator provides\n> > - it would be nice!\n>\n> Just wc -l on the changed files(s) before & after, and pay the abs()\n> difference.\n\nI pay per character, so you probably mean `wc -m`... but what do you\nmean by changed files? The command above\nis part of a script I run all the time I want to measure each editors'\nchar count... it might be even without any specific\nrecent changes...\n\n> > Do you think this \"diff\" should be deducted from the creator? And if\n> > yes - how?\n>\n> You could walk it back with \"git blame\" I guess.\n>\n> But you might want to consider the economic & social mis-incentives of\n> lifting money from your co-workers coffers by pointing out a mistake to\n> them...\n\nGood point :-) I will not do it.\n"},{"id":"459324","messageId":"CA+X_a+w-tDv+Qq7dnjSaFrFpYanwBbx77UGFpDinyeWUYQaB2w@mail.gmail.com","threadId":"58170","inReplyTo":"CA+X_a+zbG_CDP6D0zxozRoUmBeWm4dVxQ=xYRqFeWrk+FR5p0g@mail.gmail.com","subject":"Re: git: detect file creator","fromName":"Sim Tov","fromEmail":"smntov@gmail.com","sentAt":"2022-07-18T20:12:35Z","receivedAt":"2022-07-18T20:12:53Z","isPatch":false,"sender":{"key":"smntov@gmail.com","avatar":null},"body":"> Thank you very much, again, for the very useful suggestions!\n>\n> > > 1. Do you have an idea how can I list all the files **created** (not\n> > > authored / committed) by a user, so I can implement a fair characters\n> > > counting?\n> >\n> > If you want to adapt your current script perhaps --diff-filter helps,\n> > but...\n>\n> I added `--diff-filter=AR` to my original command like this:\n>\n> git log --use-mailmap --no-merges --diff-filter=AR\n> --author=\"CertainEditor\" --name-only --pretty=format:\"\"\n>\n> and it seems to do the job! May I have missed/messed something here?\n\nNow I see that if one editor renames(/moves) the files created by\nanother editor - the former gets credits on all the characters inside\nthose renamed files.\nThis is bad. And it seemingly stems from the fact that in\n`--diff-filter=AR` means `A` OR `R`. Is there a way to do `A` OR (`A`\nAND `R`), meaning if a file was\nrenamed then list it only if he also was created by that same author...\n"},{"id":"459330","messageId":"CA+X_a+zd52cB2h9txxxUeNV0t5s4-ARj+ApDb2+q=MYrY4-dwg@mail.gmail.com","threadId":"58170","inReplyTo":"CA+X_a+w-tDv+Qq7dnjSaFrFpYanwBbx77UGFpDinyeWUYQaB2w@mail.gmail.com","subject":"Re: git: detect file creator","fromName":"Sim Tov","fromEmail":"smntov@gmail.com","sentAt":"2022-07-18T20:40:04Z","receivedAt":"2022-07-18T20:40:40Z","isPatch":false,"sender":{"key":"smntov@gmail.com","avatar":null},"body":"> > Thank you very much, again, for the very useful suggestions!\n> >\n> > > > 1. Do you have an idea how can I list all the files **created** (not\n> > > > authored / committed) by a user, so I can implement a fair characters\n> > > > counting?\n> > >\n> > > If you want to adapt your current script perhaps --diff-filter helps,\n> > > but...\n> >\n> > I added `--diff-filter=AR` to my original command like this:\n> >\n> > git log --use-mailmap --no-merges --diff-filter=AR\n> > --author=\"CertainEditor\" --name-only --pretty=format:\"\"\n> >\n> > and it seems to do the job! May I have missed/messed something here?\n>\n> Now I see that if one editor renames(/moves) the files created by\n> another editor - the former gets credits on all the characters inside\n> those renamed files.\n> This is bad. And it seemingly stems from the fact that in\n> `--diff-filter=AR` means `A` OR `R`. Is there a way to do `A` OR (`A`\n> AND `R`), meaning if a file was\n> renamed then list it only if he also was created by that same author...\n\nPS: the only way I see to approach it is to create a mechanism that\nwill prevent renaming\nfiles by anyone except for the file creator (the one who Added file).\nCan such a commit hook be created? If yes - how?\n"},{"id":"459753","messageId":"xmqqpmhxd6cf.fsf@gitster.g","threadId":"58170","inReplyTo":"CA+X_a+zd52cB2h9txxxUeNV0t5s4-ARj+ApDb2+q=MYrY4-dwg@mail.gmail.com","subject":"Re: git: detect file creator","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-07-22T06:11:44Z","receivedAt":"2022-07-22T06:11:53Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sim Tov <smntov@gmail.com> writes:\n\n> PS: the only way I see to approach it is to create a mechanism that\n> will prevent renaming\n> files by anyone except for the file creator (the one who Added file).\n> Can such a commit hook be created? If yes - how?\n\nAs Git is distributed, local hooks cannot fundamentally be used as\nan enforcement mechanism.\n\nHow about running \"git blame\" on the end-result, with -C/-M turned\non, instead of paying too much attention to file creation?  That\nway, at least you can trace who contributed the words on each line.\n"}]}