{"thread":{"id":"50168","subject":"git-p4: default behavior for handling moves?","startedAt":"2019-01-07T12:50:59Z","lastAt":"2019-01-09T22:42:23Z","messageCount":3,"participants":["Luke Diamand","Mazo, Andrey","Vitor Antunes"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"366251","messageId":"CAE5ih7987J2WXdCJvs2e3hOn3zucpE6gsr4JJtxO+XE5=K2G_Q@mail.gmail.com","threadId":"50168","inReplyTo":null,"subject":"git-p4: default behavior for handling moves?","fromName":"Luke Diamand","fromEmail":"luke@diamand.org","sentAt":"2019-01-07T12:50:43Z","receivedAt":"2019-01-07T12:50:59Z","isPatch":false,"sender":{"key":"luke@diamand.org","avatar":"https://avatars.githubusercontent.com/u/5330967?v=4"},"body":"git-p4 can map a \"git move\" operation to a Perforce \"move\" operation.\nBut by default this is disabled. You then end up with a P4 commit\nwhere the file is deleted, and a fresh file is created with the same\ncontents at the new location at revision #1.\n\nRename detection gets enabled either with the \"-M\" option, or with\nsome config variables, git-p4.detectCopies and git-p4.detectRenames.\n\nI've been tripped up by this, and I actually know about it, and I know\nother people have been as well.\n\nShould we switch the default over so that it's enabled by default? I\ncan't think of any reason why you wouldn't want it enabled.\n\nI think the rename code was first introduced around 2011 by Vitor.\n\nAnother option is to add a warning, but people just ignore warnings!\n\nThanks!\nLuke\n"},{"id":"366306","messageId":"20190108005634.1647-1-amazo@checkvideo.com","threadId":"50168","inReplyTo":"CAE5ih7987J2WXdCJvs2e3hOn3zucpE6gsr4JJtxO+XE5=K2G_Q@mail.gmail.com","subject":"Re: git-p4: default behavior for handling moves?","fromName":"Mazo, Andrey","fromEmail":"amazo@checkvideo.com","sentAt":"2019-01-08T00:56:51Z","receivedAt":"2019-01-08T00:56:56Z","isPatch":false,"sender":{"key":"amazo@checkvideo.com","avatar":null},"body":"> git-p4 can map a \"git move\" operation to a Perforce \"move\" operation.\n> But by default this is disabled. You then end up with a P4 commit\n> where the file is deleted, and a fresh file is created with the same\n> contents at the new location at revision #1.\n> \n> Rename detection gets enabled either with the \"-M\" option, or with\n> some config variables, git-p4.detectCopies and git-p4.detectRenames.\n> \n> I've been tripped up by this, and I actually know about it, and I know\n> other people have been as well.\n> \n> Should we switch the default over so that it's enabled by default? I\n> can't think of any reason why you wouldn't want it enabled.\n\nI have it enabled in my ~/.gitconfig,\nso enabling it by default makes total sense to me.\n\nRegarding potential problems,\nI occasionally get a wrong \"source\" file detection.\n(e.g. there was `cp a b ; git add b`, but some other file \"c\" is selected as the source instead)\nOr there is a \"copy/move\" detected, when there was actually none.\nBut I've only seen this with quite small files (like a trivial one line shell script) or binaries,\nand mostly because I have git-p4.detectCopiesHarder set as well as a pretty aggressive git-p4.detectCopies threshold.\n(normally 30%, but down to 10% at times to make sure a copy/move is really detected)\n\nBut anyway, enabling both git-p4.detect{Copies,Renames}\nwith default 50% similarity index makes sense to me.\n\nIt's probably worth adding command-line options to override the new to-be defaults though.\n\n\nA more conservative approach like only enabling git-p4.detectRenames = 70% is an option too.\n\n> \n> I think the rename code was first introduced around 2011 by Vitor.\n> \n> Another option is to add a warning, but people just ignore warnings!\n\nWhen such a warning would be shown?\nJust before `p4 submit`?\nI think, It might be hard to notice for large changesets.\n\nThank you,\nAndrey\n"},{"id":"366456","messageId":"CAOpHH-V8XJECpekPNvS3vymGBtzfrCTZAx=U5HALUTou+cAYfg@mail.gmail.com","threadId":"50168","inReplyTo":"20190108005634.1647-1-amazo@checkvideo.com","subject":"Re: git-p4: default behavior for handling moves?","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2019-01-09T22:41:54Z","receivedAt":"2019-01-09T22:42:23Z","isPatch":false,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"Hi everyone,\n\nOn Tue, 8 Jan 2019 at 00:56, Mazo, Andrey <amazo@checkvideo.com> wrote:\n>\n> > git-p4 can map a \"git move\" operation to a Perforce \"move\" operation.\n> > But by default this is disabled. You then end up with a P4 commit\n> > where the file is deleted, and a fresh file is created with the same\n> > contents at the new location at revision #1.\n> >\n> > Rename detection gets enabled either with the \"-M\" option, or with\n> > some config variables, git-p4.detectCopies and git-p4.detectRenames.\n> >\n> > I've been tripped up by this, and I actually know about it, and I know\n> > other people have been as well.\n> >\n> > Should we switch the default over so that it's enabled by default? I\n> > can't think of any reason why you wouldn't want it enabled.\n\nThe copy/rename detection in git is not so obvious, nor easy to understand.\nAlso, when you have many similar files it is possible that the source that git\ndetects is not the real source of the file.\nAnother thing is that copies are only detected if the source file was modified,\nwhich means that detectCopies without detectCopiesHarder does not make\nmuch sense..\n\nThose were the reasons that I recall at the moment for not having enabled\nthese settings by default. But that said, I do not oppose in having them\nenabled by default.\n\n> I have it enabled in my ~/.gitconfig,\n> so enabling it by default makes total sense to me.\n>\n> Regarding potential problems,\n> I occasionally get a wrong \"source\" file detection.\n> (e.g. there was `cp a b ; git add b`, but some other file \"c\" is selected as the source instead)\n> Or there is a \"copy/move\" detected, when there was actually none.\n> But I've only seen this with quite small files (like a trivial one line shell script) or binaries,\n> and mostly because I have git-p4.detectCopiesHarder set as well as a pretty aggressive git-p4.detectCopies threshold.\n> (normally 30%, but down to 10% at times to make sure a copy/move is really detected)\n>\n> But anyway, enabling both git-p4.detect{Copies,Renames}\n> with default 50% similarity index makes sense to me.\n>\n> It's probably worth adding command-line options to override the new to-be defaults though.\n>\n>\n> A more conservative approach like only enabling git-p4.detectRenames = 70% is an option too.\n\nI'm using detectCopies=89% because copied/moved files, in general,\nwill have a very high similarity\nlevel and I don't want to have new files with similar contents\n(imagine test cases, for example) to be\nautomatically detected as copies.\n\n> > I think the rename code was first introduced around 2011 by Vitor.\n\nTime flies!\nI was using a much more complex P4 setup at the time that relied a lot\non renames and copies, as\nwell as branches. I have a much more linear setup now.\n\nBest regards,\nVitor\n"}]}