'List files in which a word has disappeared
So, say I have two branches old_release (containing an old release) and new_release (containing a new release). In the old release there was a tool called cook, I think it's still in the new release, but it's been renamed. I need to work out what it's been renamed to.
I would like a list of files which must satisfy the criteria;
- File exists in both 
old_releaseandnew_release. - String 
cookis found in the version fromold_release. - String 
cookis not found in the version fromnew_release. I need this condition because most of the code is not updated and will contain defunct references tocook. - My repository is big, and checking out a branch takes a long time. I'd like a solution that avoids that.
 
My current solution looks like;
git checkout old_release
grep cook . -R -l -I > old_release_cooks.txt
sort -o old_release_cooks_sorted.txt old_release_cooks.txt
git checkout new_release
grep cook . -R -l -I > new_release_cooks.txt
sort -o new_release_cooks_sorted.txt new_release_cooks.txt
vim -d old_release_cooks_sorted.txt new_release_cooks_sorted.txt
This meets all my requirements apart from point 4. It requires I do at least one checkout. Strictly I guess it doesn't create a list of files that differ, but the diff is close enough.
Is there a way to get this list without checking out?
Solution 1:[1]
Checkout-free one-liner in bash that uses git grep and evaluates its results using comm:
word='cook' rel1='old_release' rel2='new_release'; comm -1 -2 <(git grep -l '\b'"$word"'\b' "$rel1" | sed 's/^[^:]*://' | sort;) <(git grep -L '\b'"$word"'\b' "$rel2" | sed 's/^[^:]*://' | sort;)
EDIT: adjustments so that also your condition 1. is satisfied (file must exist in both)
EDIT2: simplified expression
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source | 
|---|---|
| Solution 1 | 
