[PATCH] Keep git-external-diff usage text from executing
Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.
You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:
docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t254311psql -h localhost -U postgresBuilt from patchset v6 (message #6), October 24, 2026 at 09:05 PM.
Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:
git clone --branch t254311_6 https://github.com/hackorum-dev/postgres.gitIn a checkout you already have, add the fork once:
git remote add hackorum https://github.com/hackorum-dev/postgres.gitthen, for this patchset and every later one:
git fetch hackorum t254311_6 && git checkout t254311_6Patchset v6 (message #6) is on t254311_6
Hi,
src/tools/git-external-diff is a Bash script, but its usage text is enclosed
in the Perl POD markers =comment and =cut. Bash therefore tries to execute
the prose and the embedded git config/git diff examples on each invocation.
The attached patch changes only those two delimiters to a quoted no-op
here-document. This preserves the text literally, without executing it or
performing shell expansions, and leaves the actual diff code unchanged.
The patch was prepared against master at
3cde90ecc5f85e7c6cb9fba29d473b2f6dd40ee1.
Validation:
- bash -n and git diff --check pass.
- The attached standalone test passes all three cases with the patch;
all three fail against the unmodified master file. It records Git calls
rather than allowing the documentation examples to change configuration
or invoke another diff. It covers unchanged content, context diffs with
spaced paths, and custom DIFF_OPTS=-u.
- A separate integration check using real Git in an isolated temporary
repository produces the expected context diff and leaves configuration
unchanged.
Run the standalone test with an explicit path to the file under test:
python3 test_git_external_diff.py /path/to/postgres/src/tools/git-external-diff
This was originally proposed to IvorySQL; its maintainers asked that this
inherited tool change be sent upstream first:
https://github.com/IvorySQL/IvorySQL/pull/2510
AI assistance was used to prepare the patch, tests, and this message.
The reported validation results are from actual local runs.
Regards,
zmuxuny
Attachments:
t254311_1v1-0001-Make-git-external-diff-usage-text-a-shell-comment.patchtext/plain; charset=utf-8; name=v1-0001-Make-git-external-diff-usage-text-a-shell-comment.patchDownload+2-3
test_git_external_diff.pytext/plain; charset=utf-8; name=test_git_external_diff.pyDownload
test_git_integration.pytext/plain; charset=utf-8; name=test_git_integration.pyDownload
On Oct 21, 2026, at 12:16, 夏侯莯昍 <xiahoumuxuan@gmail.com> wrote:
Hi,
src/tools/git-external-diff is a Bash script, but its usage text is enclosed
in the Perl POD markers =comment and =cut. Bash therefore tries to execute
the prose and the embedded git config/git diff examples on each invocation.The attached patch changes only those two delimiters to a quoted no-op
here-document. This preserves the text literally, without executing it or
performing shell expansions, and leaves the actual diff code unchanged.The patch was prepared against master at
3cde90ecc5f85e7c6cb9fba29d473b2f6dd40ee1.Validation:
- bash -n and git diff --check pass.
- The attached standalone test passes all three cases with the patch;
all three fail against the unmodified master file. It records Git calls
rather than allowing the documentation examples to change configuration
or invoke another diff. It covers unchanged content, context diffs with
spaced paths, and custom DIFF_OPTS=-u.
- A separate integration check using real Git in an isolated temporary
repository produces the expected context diff and leaves configuration
unchanged.Run the standalone test with an explicit path to the file under test:
python3 test_git_external_diff.py /path/to/postgres/src/tools/git-external-diffThis was originally proposed to IvorySQL; its maintainers asked that this
inherited tool change be sent upstream first:
https://github.com/IvorySQL/IvorySQL/pull/2510AI assistance was used to prepare the patch, tests, and this message.
The reported validation results are from actual local runs.Regards,
zmuxuny
<v1-0001-Make-git-external-diff-usage-text-a-shell-comment.patch><test_git_external_diff.py><test_git_integration.py>
The fix looks good to me.
Per PG News on May 27 2018 [1], not sure how many folks still use this tool:
```
- Preserve information on use of git-external-diff. Now that the Working with
git wiki page no longer suggests producing context diffs, we should preserve
the information on how to use git-external-diff for those people who want to
view context format diffs. The most obvious place is in the script itself, so
that's what's done here.
https://git.postgresql.org/pg/commitdiff/4431c94c3606ab54594b15ad89c7e71e46b4fb6a
```
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
On Oct 22, 2026, at 14:53, Chao Li <li.evan.chao@gmail.com> wrote:
On Oct 21, 2026, at 12:16, 夏侯莯昍 <xiahoumuxuan@gmail.com> wrote:
Hi,
src/tools/git-external-diff is a Bash script, but its usage text is enclosed
in the Perl POD markers =comment and =cut. Bash therefore tries to execute
the prose and the embedded git config/git diff examples on each invocation.The attached patch changes only those two delimiters to a quoted no-op
here-document. This preserves the text literally, without executing it or
performing shell expansions, and leaves the actual diff code unchanged.The patch was prepared against master at
3cde90ecc5f85e7c6cb9fba29d473b2f6dd40ee1.Validation:
- bash -n and git diff --check pass.
- The attached standalone test passes all three cases with the patch;
all three fail against the unmodified master file. It records Git calls
rather than allowing the documentation examples to change configuration
or invoke another diff. It covers unchanged content, context diffs with
spaced paths, and custom DIFF_OPTS=-u.
- A separate integration check using real Git in an isolated temporary
repository produces the expected context diff and leaves configuration
unchanged.Run the standalone test with an explicit path to the file under test:
python3 test_git_external_diff.py /path/to/postgres/src/tools/git-external-diffThis was originally proposed to IvorySQL; its maintainers asked that this
inherited tool change be sent upstream first:
https://github.com/IvorySQL/IvorySQL/pull/2510AI assistance was used to prepare the patch, tests, and this message.
The reported validation results are from actual local runs.Regards,
zmuxuny
<v1-0001-Make-git-external-diff-usage-text-a-shell-comment.patch><test_git_external_diff.py><test_git_integration.py>The fix looks good to me.
Per PG News on May 27 2018 [1], not sure how many folks still use this tool:
```
- Preserve information on use of git-external-diff. Now that the Working with
git wiki page no longer suggests producing context diffs, we should preserve
the information on how to use git-external-diff for those people who want to
view context format diffs. The most obvious place is in the script itself, so
that's what's done here.
https://git.postgresql.org/pg/commitdiff/4431c94c3606ab54594b15ad89c7e71e46b4fb6a
```
Oops, missed the reference [1]/messages/by-id/20180527190517.GA29473@fetter.org.
[1]: /messages/by-id/20180527190517.GA29473@fetter.org
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
Chao Li <li.evan.chao@gmail.com> writes:
On Oct 21, 2026, at 12:16, 夏侯莯昍 <xiahoumuxuan@gmail.com> wrote:
src/tools/git-external-diff is a Bash script, but its usage text is enclosed
in the Perl POD markers =comment and =cut. Bash therefore tries to execute
the prose and the embedded git config/git diff examples on each invocation.
Per PG News on May 27 2018 [1], not sure how many folks still use this tool:
Surely, the number of people who use it is exactly zero --- else we'd
have heard complaints before now. So I'm rather inclined to just
delete it instead of expending effort on fixing it.
regards, tom lane
On 22 Oct 2026, at 22:33, Tom Lane <tgl@sss.pgh.pa.us> wrote:
So I'm rather inclined to just delete it instead of expending effort on fixing
it.
+1
--
Daniel Gustafsson
On 23 Oct 2026, at 05:27, Daniel Gustafsson <daniel@yesql.se> wrote:
On 22 Oct 2026, at 22:33, Tom Lane <tgl@sss.pgh.pa.us> wrote:
So I'm rather inclined to just delete it instead of expending effort on fixing
it.+1
PFA patch removing it.
--
Daniel Gustafsson
On Oct 25, 2026, at 04:52, Daniel Gustafsson <daniel@yesql.se> wrote:
On 23 Oct 2026, at 05:27, Daniel Gustafsson <daniel@yesql.se> wrote:
On 22 Oct 2026, at 22:33, Tom Lane <tgl@sss.pgh.pa.us> wrote:
So I'm rather inclined to just delete it instead of expending effort on fixing
it.+1
PFA patch removing it.
--
Daniel Gustafsson<0001-Remove-git-external-diff-from-tools-directory.patch>
LGTM. I also checked if there is any doc needs to be updated for the removal, and didn’t find any.
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/