On Mon, Aug 16, 2021 at 07:05:11AM +0200, Tassilo Horn wrote: >>> I am trying to figure a way to find the newly added *strings* in the >>> commit diff,. >>> >>> If I do a "git diff" I get all the changes which included newly added >>> strings, modified strings as-well made in the commit, I only want the >>> newly added strings(not files) in that commit,is there a way this can >>> be achieved? > > > > I doubt it's possible simply because the very question - which strings > > are new as opposed to changed - is unanswerable in general; at least > > not without specifying a very narrow (and, I think, quite arbitrary) > > set of restrictions to do such classification. > > There is the git pickaxe, i.e., > > git log -S FOOBAR > > shows only those commits where the number of FOOBAR occurrences changed. > That will include additions of FOOBAR, where the first found commit will > probably be the initial introduction of FOOBAR.
A very interesting observation, indeed. I use it all the time, but for its intended purpose - to search past existing commits for those in which a particular string appeaed or disappeared. Here, I have interpreted the OP's question as specifically asking about what `git diff` outputs, and it generates the set of differences between the index and the work tree - there is no commit at that stage. Another thing to consider is that the pickaxe looks for a _particular_ string: that is, the user knows what they're looking for up front, and IIUC the OP's question was specifically about _detecting_ the set of strings which were added in the work tree - compared to the state in the index. Hence pickaxe looks quite similar in spirit but I'm not sure its machinery can be employed to do what the OP needs. -- You received this message because you are subscribed to the Google Groups "Git for human beings" group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/git-users/20210816115635.azz7qnhklcv4als2%40carbon.