Merge branch 'bc/utf16-portability-fix'

The code and tests assume that the system supplied iconv() would
always use BOM in its output when asked to encode to UTF-16 (or
UTF-32), but apparently some implementations output big-endian
without BOM.  A compile-time knob has been added to help such
systems (e.g. NonStop) to add BOM to the output to increase
portability.

* bc/utf16-portability-fix:
  utf8: handle systems that don't write BOM for UTF-16
diff --git a/Documentation/RelNotes/2.21.0.txt b/Documentation/RelNotes/2.21.0.txt
index 8a9a8dd..702ebfc 100644
--- a/Documentation/RelNotes/2.21.0.txt
+++ b/Documentation/RelNotes/2.21.0.txt
@@ -26,7 +26,7 @@
    the fast-export side has been made.
 
  * "git push $there $src:$dst" rejects when $dst is not a fully
-   qualified refname and not clear what the end user meant.  The
+   qualified refname and it is not clear what the end user meant.  The
    codepath has been taught to give a clearer error message, and also
    guess where the push should go by taking the type of the pushed
    object into account (e.g. a tag object would want to go under
@@ -77,9 +77,9 @@
 
  * A new date format "--date=human" that morphs its output depending
    on how far the time is from the current time has been introduced.
-   "--date=auto" can be used to use this new format when the output is
-   going to the pager or to the terminal and otherwise the default
-   format.
+   "--date=auto:human" can be used to use this new format (or any
+   existing format) when the output is going to the pager or to the
+   terminal, and otherwise the default format.
 
 
 Performance, Internal Implementation, Development Support etc.
@@ -88,7 +88,7 @@
    (non-)existence of loose objects.
 
  * More codepaths have become aware of working with in-core repository
-   instance other than the default "the_repository".
+   instances other than the default "the_repository".
 
  * The "strncat()" function is now among the banned functions.
 
@@ -125,13 +125,13 @@
  * The in-core repository instances are passed through more codepaths.
 
  * Update the protocol message specification to allow only the limited
-   use of scaled quantities.  This is ensure potential compatibility
-   issues will not go out of hand.
+   use of scaled quantities.  This is to ensure potential compatibility
+   issues will not get out of hand.
 
  * Micro-optimize the code that prepares commit objects to be walked
    by "git rev-list" when the commit-graph is available.
 
- * "git fetch" and "git upload-pack" learned to send all exchange over
+ * "git fetch" and "git upload-pack" learned to send all exchanges over
    the sideband channel while talking the v2 protocol.
 
  * The codepath to write out commit-graph has been optimized by
diff --git a/Makefile b/Makefile
index 457311b..f0b2299 100644
--- a/Makefile
+++ b/Makefile
@@ -437,6 +437,8 @@
 #
 # Define HAVE_GETDELIM if your system has the getdelim() function.
 #
+# Define FILENO_IS_A_MACRO if fileno() is a macro, not a real function.
+#
 # Define PAGER_ENV to a SP separated VAR=VAL pairs to define
 # default environment variables to be passed when a pager is spawned, e.g.
 #
@@ -1807,6 +1809,11 @@
 	BASIC_CFLAGS += -DHAVE_WPGMPTR
 endif
 
+ifdef FILENO_IS_A_MACRO
+	COMPAT_CFLAGS += -DFILENO_IS_A_MACRO
+	COMPAT_OBJS += compat/fileno.o
+endif
+
 ifeq ($(TCLTK_PATH),)
 NO_TCLTK = NoThanks
 endif
diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c
index c1cff32..e7325fe 100644
--- a/builtin/bisect--helper.c
+++ b/builtin/bisect--helper.c
@@ -173,7 +173,7 @@
 			argv_array_clear(&argv);
 			return error(_("could not check out original"
 				       " HEAD '%s'. Try 'git bisect"
-				       "reset <commit>'."), branch.buf);
+				       " reset <commit>'."), branch.buf);
 		}
 		argv_array_clear(&argv);
 	}
@@ -646,7 +646,7 @@
 		OPT_BOOL(0, "no-checkout", &no_checkout,
 			 N_("update BISECT_HEAD instead of checking out the current commit")),
 		OPT_BOOL(0, "no-log", &nolog,
-			 N_("no log for BISECT_WRITE ")),
+			 N_("no log for BISECT_WRITE")),
 		OPT_END()
 	};
 	struct bisect_terms terms = { .term_good = NULL, .term_bad = NULL };
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 5a09fe2..b620fd5 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -1480,7 +1480,7 @@
 	if (strcmp(remote->name, repository_format_partial_clone)) {
 		if (filter_options.choice)
 			die(_("--filter can only be used with the remote "
-			      "configured in extensions.partialclone"));
+			      "configured in extensions.partialClone"));
 		return;
 	}
 
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 96efd40..7c7bc13 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -1434,7 +1434,7 @@
 	}
 
 	if (options.reschedule_failed_exec && !is_interactive(&options))
-		die(_("--reschedule-failed-exec requires an interactive rebase"));
+		die(_("%s requires an interactive rebase"), "--reschedule-failed-exec");
 
 	if (options.git_am_opts.argc) {
 		/* all am options except -q are compatible only with --am */
diff --git a/compat/fileno.c b/compat/fileno.c
new file mode 100644
index 0000000..7b105f4
--- /dev/null
+++ b/compat/fileno.c
@@ -0,0 +1,7 @@
+#define COMPAT_CODE
+#include "../git-compat-util.h"
+
+int git_fileno(FILE *stream)
+{
+	return fileno(stream);
+}
diff --git a/config.mak.uname b/config.mak.uname
index 786bb2f..bd55e82 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -221,6 +221,7 @@
 	HAVE_BSD_KERN_PROC_SYSCTL = YesPlease
 	PAGER_ENV = LESS=FRX LV=-c MORE=FRX
 	FREAD_READS_DIRECTORIES = UnfortunatelyYes
+	FILENO_IS_A_MACRO = UnfortunatelyYes
 endif
 ifeq ($(uname_S),OpenBSD)
 	NO_STRCASESTR = YesPlease
@@ -234,6 +235,7 @@
 	HAVE_BSD_KERN_PROC_SYSCTL = YesPlease
 	PROCFS_EXECUTABLE_PATH = /proc/curproc/file
 	FREAD_READS_DIRECTORIES = UnfortunatelyYes
+	FILENO_IS_A_MACRO = UnfortunatelyYes
 endif
 ifeq ($(uname_S),MirBSD)
 	NO_STRCASESTR = YesPlease
@@ -490,6 +492,7 @@
 	OLD_ICONV = UnfortunatelyYes
 	NO_REGEX = NeedsStartEnd
 	NO_PTHREADS = UnfortunatelyYes
+	FREAD_READS_DIRECTORIES = UnfortunatelyYes
 
 	# Not detected (nor checked for) by './configure'.
 	# We don't have SA_RESTART on NonStop, unfortunalety.
diff --git a/git-compat-util.h b/git-compat-util.h
index 29a1990..6573808 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -1234,6 +1234,14 @@
 #define getc_unlocked(fh) getc(fh)
 #endif
 
+#ifdef FILENO_IS_A_MACRO
+int git_fileno(FILE *stream);
+# ifndef COMPAT_CODE
+#  undef fileno
+#  define fileno(p) git_fileno(p)
+# endif
+#endif
+
 /*
  * Our code often opens a path to an optional file, to work on its
  * contents when we can successfully open it.  We can ignore a failure
diff --git a/imap-send.c b/imap-send.c
index 18ca6ba..6c54d8c 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -1114,7 +1114,7 @@
 
 			if (!strcmp(srvc->auth_method, "CRAM-MD5")) {
 				if (!CAP(AUTH_CRAM_MD5)) {
-					fprintf(stderr, "You specified"
+					fprintf(stderr, "You specified "
 						"CRAM-MD5 as authentication method, "
 						"but %s doesn't support it.\n", srvc->host);
 					goto bail;
diff --git a/sequencer.c b/sequencer.c
index 972402e..0db410d 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -35,7 +35,7 @@
 
 #define GIT_REFLOG_ACTION "GIT_REFLOG_ACTION"
 
-const char sign_off_header[] = "Signed-off-by: ";
+static const char sign_off_header[] = "Signed-off-by: ";
 static const char cherry_picked_prefix[] = "(cherry picked from commit ";
 
 GIT_PATH_FUNC(git_path_commit_editmsg, "COMMIT_EDITMSG")
diff --git a/sequencer.h b/sequencer.h
index 93e8913..4d505b3 100644
--- a/sequencer.h
+++ b/sequencer.h
@@ -107,8 +107,6 @@
 		    unsigned autosquash);
 int rearrange_squash(struct repository *r);
 
-extern const char sign_off_header[];
-
 /*
  * Append a signoff to the commit message in "msgbuf". The ignore_footer
  * parameter specifies the number of bytes at the end of msgbuf that should
diff --git a/sha1-name.c b/sha1-name.c
index d1cc77c..6dda2c1 100644
--- a/sha1-name.c
+++ b/sha1-name.c
@@ -1820,9 +1820,11 @@
 			       prefix, &oid, &oc);
 }
 
-int get_oid_with_context(struct repository *repo, const char *str,
-			 unsigned flags, struct object_id *oid,
-			 struct object_context *oc)
+enum get_oid_result get_oid_with_context(struct repository *repo,
+					 const char *str,
+					 unsigned flags,
+					 struct object_id *oid,
+					 struct object_context *oc)
 {
 	if (flags & GET_OID_FOLLOW_SYMLINKS && flags & GET_OID_ONLY_TO_DIE)
 		BUG("incompatible flags for get_sha1_with_context");