Git Mailing List Archive mirror
 help / color / mirror / Atom feed
From: Taylor Blau <me@ttaylorr.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Christian Hesse <list@eworm.de>,
	git@vger.kernel.org, Elijah Newren <newren@gmail.com>
Subject: Re: [PATCH 1/1] imap-send: include strbuf.h
Date: Wed, 17 May 2023 12:31:50 -0400	[thread overview]
Message-ID: <ZGUBdoLeiqTQYQ9Z@nand.local> (raw)
In-Reply-To: <xmqqilcrq6a9.fsf@gitster.g>

On Wed, May 17, 2023 at 09:19:58AM -0700, Junio C Hamano wrote:
> OK, so the fix seems to make sense, but the justification for the
> change needs to be rewritten, I think.
>
>     We make liberal use of the strbuf API functions and types, but
>     the inclusion of <strbuf.h> comes indirectly by including
>     <http.h>, which does not happen if you build with NO_CURL.
>
> or something like that?

Agreed. Here's a patch that summarizes my investigation. Thanks again,
Christian, for reporting!

--- 8< ---

Subject: [PATCH] imap-send.c: fix compilation under NO_CURL and ancient
 versions

When building imap-send.c with an ancient (pre-7.34.0, which was
released in 2013) version of curl, or with `NO_CURL` defined, Git
2.41.0-rc0 fails to compile imap-send.c, i.e.

    $ make NO_CURL=1 imap-send.o

This is similar to 52c0f3318d (run-command.c: fix missing include under
`NO_PTHREADS`, 2023-05-16), but the bisection points at ba3d1c73da
(treewide: remove unnecessary cache.h includes, 2023-02-24) instead.

The trivial fix is to include "strbuf.h" unconditionally, which is a
noop for most builds, and saves us otherwise.

To check for other *.c files that might suffer from the same issue, we
can run:

    git grep -l -e '[^_]xstrdup(' -e 'strbuf_[a-z0-9A-Z_]*(' \*.c |
    while read f
    do
        if ! gcc -I $(pwd) -E $f | grep -q 'struct strbuf {'
        then
            echo "==> $f NOT OK";
        fi
    done

...which runs the preprocessor on (roughly) all C source files that call
`xstrdup()` or use the strbuf API. The resulting list looks (on my
machine) lile:

    ==> compat/fsmonitor/fsm-listen-darwin.c NOT OK
    ==> compat/mingw.c NOT OK
    ==> contrib/credential/osxkeychain/git-credential-osxkeychain.c NOT OK
    ==> pager.c NOT OK
    ==> refs/iterator.c NOT OK
    ==> refs/ref-cache.c NOT OK
    ==> string-list.c NOT OK
    ==> t/helper/test-mktemp.c NOT OK

The ones in compat are OK to ignore since they both fail to compile on
my non-Windows machine (I am missing the `<dispatch/dispatch.h>` and
`<windows.h>` headers, respectively).

The one in contrib is fine to ignore, since it has its own definition of
xstrdup().

pager.c is OK, since it only needs xstrdup(), not any other parts of the
strbuf API. It gets a declaration of xstrdup() from git-compat-util.h
refs/iterator.c, refs/ref-cache.c, string-list.c, and
t/helper/test-mktemp.c are all OK for the same reason.

So this is the only spot that needs fixing.

Reported-by: Christian Hesse <mail@eworm.de>
Original-fix-by: Christian Hesse <mail@eworm.de>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
---
 imap-send.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/imap-send.c b/imap-send.c
index a62424e90a..7f5426177a 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -29,6 +29,7 @@
 #include "run-command.h"
 #include "parse-options.h"
 #include "setup.h"
+#include "strbuf.h"
 #include "wrapper.h"
 #if defined(NO_OPENSSL) && !defined(HAVE_OPENSSL_CSPRNG)
 typedef void *SSL;
--
2.41.0.rc0.1.g01bd045298


  reply	other threads:[~2023-05-17 16:31 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-17  7:06 [PATCH 1/1] imap-send: include strbuf.h Christian Hesse
2023-05-17 15:49 ` Junio C Hamano
2023-05-17 16:02   ` Taylor Blau
2023-05-17 16:19     ` Junio C Hamano
2023-05-17 16:31       ` Taylor Blau [this message]
2023-05-17 20:12       ` Christian Hesse
2023-05-17 20:18         ` Christian Hesse
2023-05-18 15:56           ` Junio C Hamano
2023-05-17 16:23     ` Taylor Blau
2023-05-17 16:53       ` Junio C Hamano
2023-05-17 17:01         ` Junio C Hamano
2023-05-17 17:58           ` Taylor Blau
2023-05-17 18:06             ` rsbecker
2023-05-17 18:12               ` Junio C Hamano
2023-05-17 19:30                 ` rsbecker
2023-05-17 18:09             ` Junio C Hamano
2023-05-17 21:38               ` Taylor Blau
2023-05-18 16:01                 ` Junio C Hamano
2023-05-18 18:25                   ` Jeff King
2023-05-18 20:49                     ` Junio C Hamano
  -- strict thread matches above, loose matches on Subject: below --
2024-02-09 22:26 Christian Hesse
2024-02-09 22:42 ` Junio C Hamano
2024-02-09 22:54   ` Junio C Hamano
2024-02-10 20:01     ` Christian Hesse
2024-02-11  2:42       ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZGUBdoLeiqTQYQ9Z@nand.local \
    --to=me@ttaylorr.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=list@eworm.de \
    --cc=newren@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).