From: Jeff King <peff@peff.net>
To: Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>,
Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: Re: [PATCH 1/1] Makefile: fix the "built from commit" code
Date: Thu, 28 Jun 2018 09:23:14 -0400 [thread overview]
Message-ID: <20180628132314.GA14026@sigill.intra.peff.net> (raw)
In-Reply-To: <e0e41d0b88b4104737b9ee80710c1bec91c9d759.1530190395.git.gitgitgadget@gmail.com>
On Wed, Jun 27, 2018 at 09:35:23PM +0200, Johannes Schindelin via GitGitGadget wrote:
> To prevent erroneous commits from being reported (e.g. when unpacking
> Git's source code from a .tar.gz file into a subdirectory of a different
> Git project, as e.g. git_osx_installer does), we painstakingly set
> GIT_CEILING_DIRECTORIES when trying to determine the current commit.
>
> Except that we got the quoting wrong, and that variable therefore does
> not have the desired effect.
>
> Let's fix that quoting, and while at it, also suppress the unhelpful
> message
I had to stare at the code for a bit to figure out what was wrong:
> - '-DGIT_BUILT_FROM_COMMIT="$(shell GIT_CEILING_DIRECTORIES=\"$(CURDIR)/..\" \
> - git rev-parse -q --verify HEAD || :)"'
> + '-DGIT_BUILT_FROM_COMMIT="$(shell \
> + GIT_CEILING_DIRECTORIES="$(CURDIR)/.." \
> + git rev-parse -q --verify HEAD 2>/dev/null)"'
The issue is that the $(shell) is resolved before the output is stuffed
into the command-line with -DGIT_BUILT_FROM_COMMIT, and therefore is
_not_ inside quotes. And thus backslashing the quotes is wrong, as the
quote gets literally inserted into the CEILING_DIRECTORIES variable.
I thought at first we could not need the quotes in the post-image
either, because shell variable assignments do not do word-splitting.
I.e.:
FOO='with spaces'
BAR=$FOO sh -c 'echo $BAR'
works just fine. But $(CURDIR) here is not a shell variable, but rather
a Makefile variable, so it's expanded before we hit the shell. So we
need the quotes. And unfortunately it also breaks if $(CURDIR) contains
exotic metacharacters. If we cared we could use single quotes and
$(CURDIR_SQ), but I suspect it would be far from the first thing to
break in such a case.
Which is a long-winded way of saying the patch looks correct to me.
-Peff
next prev parent reply other threads:[~2018-06-28 13:23 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-28 12:53 [PATCH 0/1] Makefile: fix the "built from commit" code Johannes Schindelin via GitGitGadget
2018-06-27 19:35 ` [PATCH 1/1] " Johannes Schindelin via GitGitGadget
2018-06-28 13:23 ` Jeff King [this message]
2018-06-28 16:23 ` Johannes Schindelin
2018-06-28 17:27 ` Junio C Hamano
2018-06-28 17:47 ` Jeff King
2018-06-29 11:29 ` Johannes Schindelin
2018-06-28 17:49 ` Jeff King
2018-06-28 13:18 ` [PATCH 0/1] " Johannes Schindelin
2018-06-28 23:14 ` brian m. carlson
2018-06-29 12:16 ` [PATCH v2 0/1] Fix "built from commit" logic Johannes Schindelin via GitGitGadget
2018-06-27 19:35 ` [PATCH v2 1/1] Makefile: fix the "built from commit" code Johannes Schindelin via GitGitGadget
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=20180628132314.GA14026@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=gitster@pobox.com \
--cc=johannes.schindelin@gmx.de \
/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 NNTP newsgroup(s).