From f1b826f45f53ba120fabe1f58e7779892736af50 Mon Sep 17 00:00:00 2001
From: Robert Haas <rhaas@postgresql.org>
Date: Thu, 25 Apr 2024 11:40:45 -0400
Subject: [PATCH v2] Minor fixes to pg_combinebackup and its documentation.

The --tablespace-mapping option was specified with required_argument
rather than no_argument, which is wrong. Since the actual argument
string passed to getopt_long() included "T:", the single-character
form of the option still worked, but the long form did not. Repair.

The call to getopt_long() erroneously included "P", which doesn't
correspond to any supported option. Remove.

The help message used "do not" in one place and "don't" in another.
Standardize on "do not".

The documentation erroneously stated that the tablespace mappings
would be applied relative to the pathnames in the first backup
specified on the command line, rather than the final one. Fix.

Thanks to Tomas Vondra and Daniel Gustaffson for alerting me to
these mistakes.
---
 doc/src/sgml/ref/pg_combinebackup.sgml      | 2 +-
 src/bin/pg_combinebackup/pg_combinebackup.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/doc/src/sgml/ref/pg_combinebackup.sgml b/doc/src/sgml/ref/pg_combinebackup.sgml
index 96df3d81f1..89ee92d6a7 100644
--- a/doc/src/sgml/ref/pg_combinebackup.sgml
+++ b/doc/src/sgml/ref/pg_combinebackup.sgml
@@ -128,7 +128,7 @@ PostgreSQL documentation
         Relocates the tablespace in directory <replaceable>olddir</replaceable>
         to <replaceable>newdir</replaceable> during the backup.
         <replaceable>olddir</replaceable> is the absolute path of the tablespace
-        as it exists in the first backup specified on the command line,
+        as it exists in the final backup specified on the command line,
         and <replaceable>newdir</replaceable> is the absolute path to use for the
         tablespace in the reconstructed backup.  If either path needs to contain
         an equal sign (<literal>=</literal>), precede that with a backslash.
diff --git a/src/bin/pg_combinebackup/pg_combinebackup.c b/src/bin/pg_combinebackup/pg_combinebackup.c
index 4958372653..9331b790d5 100644
--- a/src/bin/pg_combinebackup/pg_combinebackup.c
+++ b/src/bin/pg_combinebackup/pg_combinebackup.c
@@ -126,7 +126,7 @@ main(int argc, char *argv[])
 		{"dry-run", no_argument, NULL, 'n'},
 		{"no-sync", no_argument, NULL, 'N'},
 		{"output", required_argument, NULL, 'o'},
-		{"tablespace-mapping", no_argument, NULL, 'T'},
+		{"tablespace-mapping", required_argument, NULL, 'T'},
 		{"manifest-checksums", required_argument, NULL, 1},
 		{"no-manifest", no_argument, NULL, 2},
 		{"sync-method", required_argument, NULL, 3},
@@ -163,7 +163,7 @@ main(int argc, char *argv[])
 	opt.copy_method = COPY_METHOD_COPY;
 
 	/* process command-line options */
-	while ((c = getopt_long(argc, argv, "dnNPo:T:",
+	while ((c = getopt_long(argc, argv, "dnNo:T:",
 							long_options, &optindex)) != -1)
 	{
 		switch (c)
@@ -727,7 +727,7 @@ help(const char *progname)
 	printf(_("  %s [OPTION]... DIRECTORY...\n"), progname);
 	printf(_("\nOptions:\n"));
 	printf(_("  -d, --debug               generate lots of debugging output\n"));
-	printf(_("  -n, --dry-run             don't actually do anything\n"));
+	printf(_("  -n, --dry-run             do not actually do anything\n"));
 	printf(_("  -N, --no-sync             do not wait for changes to be written safely to disk\n"));
 	printf(_("  -o, --output              output directory\n"));
 	printf(_("  -T, --tablespace-mapping=OLDDIR=NEWDIR\n"
-- 
2.39.3 (Apple Git-145)

