{"thread":{"id":"3099","subject":"Something wrong with pickaxe?","startedAt":"2006-01-18T23:23:37Z","lastAt":"2006-01-19T19:10:42Z","messageCount":9,"participants":["Johannes Schindelin","Linus Torvalds","Junio C Hamano","Andreas Ericsson"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"14855","messageId":"Pine.LNX.4.63.0601190004130.15298@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"3099","inReplyTo":null,"subject":"Something wrong with pickaxe?","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-01-18T23:23:37Z","receivedAt":"2006-01-18T23:23:37Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nit is a fact that I'm stupid, but in this case it might be a bug, too. \nWhen I call\n\n\tgit-whatchanged -Sget_remote_heads 1baaae5e fetch-pack.c\n\nthe first shown commit is d1c133f5. However, if I substitute the \n\"-Sget_remote_heads\" by \"-p\" I see that the diff of commit 1baaae5e *does* \nchange a line containing that text.\n\nWhat am I doing wrong?\n\nCiao,\nDscho\n"},{"id":"14857","messageId":"Pine.LNX.4.64.0601181541150.3240@g5.osdl.org","threadId":"3099","inReplyTo":"Pine.LNX.4.63.0601190004130.15298@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: Something wrong with pickaxe?","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2006-01-18T23:55:13Z","receivedAt":"2006-01-18T23:55:13Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\nOn Thu, 19 Jan 2006, Johannes Schindelin wrote:\n> \n> it is a fact that I'm stupid, but in this case it might be a bug, too. \n> When I call\n> \n> \tgit-whatchanged -Sget_remote_heads 1baaae5e fetch-pack.c\n> \n> the first shown commit is d1c133f5. However, if I substitute the \n> \"-Sget_remote_heads\" by \"-p\" I see that the diff of commit 1baaae5e *does* \n> change a line containing that text.\n> \n> What am I doing wrong?\n\nNothing. But pickaxe really has very strange semantics, which imho makes \nit much less useful than it could be.\n\nWhat pickaxe ends up doing is to literally see if the original has that \nstring, and the result does not. I think it _counts_ the number of \noccurrences of a string in the before/after situation, and if the count \ndiffers, it's considered interesting.\n\nSo yes, there's a commit that has \"get_remote_heads\" as part of the \nchange, but that particular string did not actually change in that commit: \n_other_ stuff on the same line did change. That particular string existed \nboth before and after.\n\nSo when you use pickaxe, you really want to match the whole line you're \nlooking for - otherwise you'll only see when people add or remove a \nparticular string, not when they change things around it. Even then, if \nthat particular line gets _moved_ (but otherwise is unchanged) pickaxe \nwon't pick it up.\n\nSo you could have done a more exact search:\n\n    git-whatchanged -p \\\n\t-S\"get_remote_heads(fd[0], &ref, nr_match, match, 1);\" \\\n\t1baaae5e fetch-pack.c\n\nwould have found where that particular line was introduced (and deleted).\n\nMe, I find the pickaxe semantics so non-intuitive that I never use it \n(that said, the counting begaviour is better than what it _used_ to be, \nwhich, if I recall correctly, was just \"it existed before, doesn't exist \nnow\").\n\nI at one point suggested to Junio that the semantics be something else \n(\"mark the source and destination within 'x' characters of an occurrence \nof that string, and then if the _delta_ touches any of the marked areas, \nconsider it to be a hit\") but I think the problem was simply that it's \nmore complex. You have to look at the ranges that the delta actually \ntouches, which is more work than just looking at the original and final \nfile contents themselves.\n\nI suspect (but can't speak for him, obviously) that Junio would be open to \nmore friendly pickaxe semantics if the suggested semantics change was \naccompanied by an actual diff to implement them.\n\nIn the meantime, you really need to think carefully about what you're \ndoing when you use \"-S\". \n\n\t\tLinus\n"},{"id":"14858","messageId":"7v3bjlt66q.fsf@assigned-by-dhcp.cox.net","threadId":"3099","inReplyTo":"Pine.LNX.4.64.0601181541150.3240@g5.osdl.org","subject":"Re: Something wrong with pickaxe?","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-01-19T00:25:17Z","receivedAt":"2006-01-19T00:25:17Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Linus Torvalds <torvalds@osdl.org> writes:\n\n> So when you use pickaxe, you really want to match the whole line you're \n> looking for - otherwise you'll only see when people add or remove a \n> particular string, not when they change things around it. Even then, if \n> that particular line gets _moved_ (but otherwise is unchanged) pickaxe \n> won't pick it up.\n\nTrue.  I always feed at least couple of lines to it.\n\n> ... Junio would be open to \n> more friendly pickaxe semantics if the suggested semantics change was \n> accompanied by an actual diff to implement them.\n\nTrue again.  It is hard to be \"more friendly\" without actually\ngenerating a diff ;-).\n"},{"id":"14864","messageId":"7vwtgxlysf.fsf@assigned-by-dhcp.cox.net","threadId":"3099","inReplyTo":"Pine.LNX.4.64.0601181541150.3240@g5.osdl.org","subject":"Re: Something wrong with pickaxe?","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-01-19T02:46:56Z","receivedAt":"2006-01-19T02:46:56Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Linus Torvalds <torvalds@osdl.org> writes:\n\n> Me, I find the pickaxe semantics so non-intuitive that I never use it \n> (that said, the counting begaviour is better than what it _used_ to be, \n> which, if I recall correctly, was just \"it existed before, doesn't exist \n> now\").\n\nYou are so polite to say \"non-intuitive\" when you mean\n\"useless\".\n\nI use pickaxe primarily when I want to find out what commit made\nthe code into the current shape.\n\nFor example, after I start debugging or code change, if I\nsuspect the first \"if (!nr_match) return;\" is bogus in\nfilter_refs() of fetch-pack.c, before declaring that code is\nbogus and start butchering it, I run something like this:\n\n$ git whatchanged -p -S'static void filter_refs(struct ref **refs, int nr_match, char **match)\n{\n\tstruct ref *prev, *current, *next;\n\n\tif (!nr_match)\n\t\treturn;\n' master -- fetch-pack.c\n\nto find the commit that made the function to look like so,\nhoping to find the reason _why_ it is that way is explained in\nthe log message for that commit.  If the commit log is not\nenough, then next thing I do is to see its commit/author date\nand go back to the mailing list logs to see discussion around\nthat timeframe.\n\nFor this use pattern, even counting behaviour we added later is\nredundant, since \"did not have it that way but now it does\" is\nthe only thing that matters.\n\n\"What commits changed the lines that use this symbol over time\"\nis not a question I ask pickaxe.  When I ask a question about an\nindividual symbol, such as \"get_remote_heads\", I often use \"git\ngrep\", to learn what other existing users of the function would\nbe affected in the current code if I changed that function, or\nto learn how other functions in the current code uses that\nsymbol, but for that kind of research, historical usage of that\nsymbol does not interest me.\n\nHaving said all of the above, I agree a different kind of\npickaxe that gives you \"if you were to run diff -u between these\ntwo blobs, the resulting patch would contain this text\" might\nalso be useful, and I am very open to have such an additional\ndiffcore module next to pickaxe (IOW, not a replacement).\n\nBut it might not be as easy to use as the current pickaxe if the\nquestion I want to ask is \"who made it into this shape\".\n"},{"id":"14865","messageId":"Pine.LNX.4.64.0601181855570.3240@g5.osdl.org","threadId":"3099","inReplyTo":"7vwtgxlysf.fsf@assigned-by-dhcp.cox.net","subject":"Re: Something wrong with pickaxe?","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2006-01-19T02:59:39Z","receivedAt":"2006-01-19T02:59:39Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Wed, 18 Jan 2006, Junio C Hamano wrote:\n> \n> You are so polite to say \"non-intuitive\" when you mean\n> \"useless\".\n\nNo, no. I could imagine that it's useful, but I end up always instead \ndoing \"git whatchanged | less\" and searching for it. \n\nSo I really mean that the semantics are so non-intuitive that I just can't \nuse it, rather than totally useless.\n\n> For example, after I start debugging or code change, if I\n> suspect the first \"if (!nr_match) return;\" is bogus in\n> filter_refs() of fetch-pack.c, before declaring that code is\n> bogus and start butchering it, I run something like this:\n> \n> $ git whatchanged -p -S'static void filter_refs(struct ref **refs, int nr_match, char **match)\n> {\n> \tstruct ref *prev, *current, *next;\n> \n> \tif (!nr_match)\n> \t\treturn;\n> ' master -- fetch-pack.c\n\nSee, this is what I mean - it looks useful, but it's just so subtle that I \ndon't ever use it.\n\nFor example, getting the tabs/spaces right is basically impossible with \nnormal cut-and-paste. I assume you do the above inside GNU emacs or some \nsimilar special-purpose setup, rather than anything generic.\n\n\t\tLinus\n"},{"id":"14866","messageId":"7v3bjknbe6.fsf@assigned-by-dhcp.cox.net","threadId":"3099","inReplyTo":"Pine.LNX.4.64.0601181855570.3240@g5.osdl.org","subject":"Re: Something wrong with pickaxe?","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-01-19T03:29:21Z","receivedAt":"2006-01-19T03:29:21Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Linus Torvalds <torvalds@osdl.org> writes:\n\n> For example, getting the tabs/spaces right is basically impossible with \n> normal cut-and-paste. I assume you do the above inside GNU emacs or some \n> similar special-purpose setup, rather than anything generic.\n\nAh, that is very very very true.  Sometimes I cut and paste\ninside screen and find it annoying to see pasted tabs do not\nwork properly, so I understand that issue very well.\n\nBut most of the time, I always work inside Emacs and rarely step\nout if ever.  Thanks for making me realize that.\n"},{"id":"14880","messageId":"43CF5816.1010004@op5.se","threadId":"3099","inReplyTo":"7v3bjlt66q.fsf@assigned-by-dhcp.cox.net","subject":"Re: Something wrong with pickaxe?","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2006-01-19T09:12:54Z","receivedAt":"2006-01-19T09:12:54Z","isPatch":false,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Junio C Hamano wrote:\n> Linus Torvalds <torvalds@osdl.org> writes:\n> \n>>... Junio would be open to \n>>more friendly pickaxe semantics if the suggested semantics change was \n>>accompanied by an actual diff to implement them.\n> \n> \n> True again.  It is hard to be \"more friendly\" without actually\n> generating a diff ;-).\n> \n\nI thought generating diffs was fairly cheap. I agree with Linus somewhat \nthough. I've been puzzled more than once with the pickaxe behaviour when \nI give it a function name to search for and want to know when the \ncalling semantics changed for that function. I usually also end up doing \na whatchanged -p and search it.\n\nIt would be neat if the current behaviour could be kept with \n--pickaxe-exact but all commits containing changes to lines matching the \nstring was returned by default. Or possibly --pickaxe-thourough to do \nthe other way around.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"},{"id":"14908","messageId":"7vfynkdqj1.fsf@assigned-by-dhcp.cox.net","threadId":"3099","inReplyTo":"43CF5816.1010004@op5.se","subject":"Re: Something wrong with pickaxe?","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-01-19T18:24:50Z","receivedAt":"2006-01-19T18:24:50Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Andreas Ericsson <ae@op5.se> writes:\n\n>> True again.  It is hard to be \"more friendly\" without actually\n>> generating a diff ;-).\n>\n> I thought generating diffs was fairly cheap...\n\nProbably.  But we currently do not do diff generation\ninternally, so the comparison is \"now doing diff with N lines of\ncode\" vs \"having 0 lines of code to do diff\".\n\n> ... I give it a function name to search for and want to\n> know when the calling semantics changed for that function.\n\n\"Calling semantics\" meaning \"function signature\"?\n"},{"id":"14915","messageId":"43CFE432.2030005@op5.se","threadId":"3099","inReplyTo":"7vfynkdqj1.fsf@assigned-by-dhcp.cox.net","subject":"Re: Something wrong with pickaxe?","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2006-01-19T19:10:42Z","receivedAt":"2006-01-19T19:10:42Z","isPatch":false,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Junio C Hamano wrote:\n> Andreas Ericsson <ae@op5.se> writes:\n> \n>>... I give it a function name to search for and want to\n>>know when the calling semantics changed for that function.\n> \n> \n> \"Calling semantics\" meaning \"function signature\"?\n> \n\nYes.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"}]}