gitk: What is the difference between "adding/removing string" and "changing lines matching"?

StackOverflow https://stackoverflow.com/questions/21190953

  •  29-09-2022
  •  | 
  •  

Question

In gitk, when searching the commits, there are two options which sound like the same to me - "adding/removing string" and "changing lines matching".

I assume there is still some difference between them?

enter image description here

Was it helpful?

Solution

“Adding/removing string” simply checks if a change contains the string verbatim. “Changing lines matching” on the other hand applies the given pattern as a regular expression and finds changes which match the provided regex pattern.

The corresponding command line options are -S (adding/removing string) and -G (changing lines matching). On the command line, you also have the possibility of -Sstring --pickaxe-regex which will treat the pickaxe string as a regular expression, but only match it, if it is either deleted or added in a commit (but not if it's only part of a changed line).

OTHER TIPS

Well, "adding/removing string" would be the case where the old file has the a particular occurrence of the target string and the new file doesn't, or the old file did not have it, and the new file does. In other words, adding or removing the string without modifying the surrounding context (e.g. "abc xyz def" -> "abc def", or "abc def" -> "abc xyzdef", if your target string is "xyz"). The string may or may not be an entire line.

In contrast, "changing lines matching" would be any change on a line that matches that string, even if the change doesn't affect the string. For example "abc xyz def" -> "abc xyz def foo".

There is likely much overlap between the two, but they're different enough to be useful in different situations.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top