]> git.ipfire.org Git - thirdparty/git.git/commit
grep: copy struct in one fell swoop
authorMartin Ågren <martin.agren@gmail.com>
Sun, 29 Nov 2020 19:52:21 +0000 (20:52 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 30 Nov 2020 21:55:54 +0000 (13:55 -0800)
commit6ba9bb76e0279bce9f614cb7f4ee28d8a601e79e
treec7c287563a004035efd7ddfa6298a60d2b3cc5ea
parent96313423a75fa8d88b6ecd5a15c21a7fbaf9e9be
grep: copy struct in one fell swoop

We have a `struct grep_opt` with our defaults which we then copy into
the caller's struct. Rather than zeroing the target struct and copying
each element one by one, just copy everything at once. This leaves the
code simpler and more maintainable.

We don't have any ownership issues with what we're copying now and can
just greedily copy the whole thing. If and when we do need to handle
such elements (`char *`?), we must and can handle it appropriately. Make
sure to leave a comment to our future selves.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
grep.c