Reputation: 299
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;
old_release
and new_release
.cook
is found in the version from old_release
.cook
is not found in the version from new_release
. I need this condition because most of the code is not updated and will contain defunct references to cook
.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?
Upvotes: 1
Views: 44
Reputation: 3950
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
Upvotes: 1