Reputation: 27796
I have a directory containing many git repos.
I want to search for commits containing "foo" in the git repos with git log -G foo
.
This does not work:
for repo in *; do (cd $repo; git log -G request --pretty=format:"%ad %h in $repo by %an, %s" --date=iso --since=2022-05-01) ; done | sort -r
For some reason some lines are glued together ("xyz2022-06-30")
2022-04-29 17:02:03 +0200 b0b9b30b in bar by Thomas, xyz2022-06-30 14:25:09 +0200 47dbcb3 in applicant_management by dennis, Implement renames and relocations of columns in InstitutionSlotAdmin
The output of git log
seems to be missing a newline at the end.
How to fix this one-liner?
Upvotes: 0
Views: 92
Reputation: 27796
Based on the answer of LeGEC:
for repo in *; do (cd $repo; \
git log -G request --pretty="%ad %h in $repo by %an, %s" \
--date=iso --since=2022-05-01); done | sort -r
Upvotes: 0
Reputation: 51780
tested on my machine (bash on Ubuntu, using git 2.35.0
) I see the same issue :
when the output of git log ...
is piped, there is no trailing \n
(seen using git log ... | hd
)
A quick (and hacky) fix : add an empty echo
at the end of your loop :
for repo in *; do (cd $repo; \
git log -G request --pretty=format:"%ad %h in $repo by %an, %s" \
--date=iso --since=2022-05-01; \
echo); done | sort -r
# ^
# here
Upvotes: 1