Merge branch 'ab/rebase-test-fix'
authorJunio C Hamano <gitster@pobox.com>
Thu, 14 Feb 2019 02:18:43 +0000 (18:18 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 14 Feb 2019 02:18:43 +0000 (18:18 -0800)
* ab/rebase-test-fix:
rebase: fix regression in rebase.useBuiltin=false test mode

15 files changed:
Makefile
compat/fileno.c [new file with mode: 0644]
compat/mingw.h
config.mak.uname
git-compat-util.h
sequencer.c
sequencer.h
sha1-name.c
t/README
t/t0028-working-tree-encoding.sh
t/t5318-commit-graph.sh
t/t5562-http-backend-content-length.sh
t/test-lib-functions.sh
t/test-lib.sh
utf8.c
index 0e13a5b4698a02e93c9f2c95e06b4193fe229567..f0b2299172cf631470e1935869021bebb0e5ea96 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -259,6 +259,10 @@ all::
 # Define OLD_ICONV if your library has an old iconv(), where the second
 # (input buffer pointer) parameter is declared with type (const char **).
 #
+# Define ICONV_OMITS_BOM if your iconv implementation does not write a
+# byte-order mark (BOM) when writing UTF-16 or UTF-32 and always writes in
+# big-endian format.
+#
 # Define NO_DEFLATE_BOUND if your zlib does not have deflateBound.
 #
 # Define NO_R_TO_GCC_LINKER if your gcc does not like "-R/path/lib"
@@ -433,6 +437,8 @@ all::
 #
 # 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.
 #
@@ -1415,6 +1421,9 @@ ifndef NO_ICONV
                EXTLIBS += $(ICONV_LINK) -liconv
        endif
 endif
+ifdef ICONV_OMITS_BOM
+       BASIC_CFLAGS += -DICONV_OMITS_BOM
+endif
 ifdef NEEDS_LIBGEN
        EXTLIBS += -lgen
 endif
@@ -1800,6 +1809,11 @@ ifdef HAVE_WPGMPTR
        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/compat/fileno.c b/compat/fileno.c
new file mode 100644 (file)
index 0000000..7b105f4
--- /dev/null
@@ -0,0 +1,7 @@
+#define COMPAT_CODE
+#include "../git-compat-util.h"
+
+int git_fileno(FILE *stream)
+{
+       return fileno(stream);
+}
index 98407744f2ce9aaeb4aed77e0a4e19493ca2789c..30d9fb3e36274657e5d2a63ef2f5eb3e1c55ce61 100644 (file)
@@ -6,25 +6,6 @@ typedef _sigset_t sigset_t;
 #include <winsock2.h>
 #include <ws2tcpip.h>
 
-#ifdef __MINGW64_VERSION_MAJOR
-/*
- * In Git for Windows, we cannot rely on `uname -m` to report the correct
- * architecture: /usr/bin/uname.exe will report the architecture with which the
- * current MSYS2 runtime was built, not the architecture for which we are
- * currently compiling (both 32-bit and 64-bit `git.exe` is built in the 64-bit
- * Git for Windows SDK).
- */
-#undef GIT_HOST_CPU
-/* This was figured out by looking at `cpp -dM </dev/null`'s output */
-#if defined(__x86_64__)
-#define GIT_HOST_CPU "x86_64"
-#elif defined(__i686__)
-#define GIT_HOST_CPU "i686"
-#else
-#error "Unknown architecture"
-#endif
-#endif
-
 /* MinGW-w64 reports to have flockfile, but it does not actually have it. */
 #ifdef __MINGW64_VERSION_MAJOR
 #undef _POSIX_THREAD_SAFE_FUNCTIONS
index 281c547e2f6ef617029821a617d518ea5e133915..b37fa8424c88cae23abf02f8276e8b4f6ffef19a 100644 (file)
@@ -221,6 +221,7 @@ ifeq ($(uname_S),FreeBSD)
        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 @@ ifeq ($(uname_S),OpenBSD)
        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
@@ -508,9 +510,7 @@ ifeq ($(uname_S),NONSTOP_KERNEL)
        # RFE 10-120912-4693 submitted to HP NonStop development.
        NO_SETITIMER = UnfortunatelyYes
        SANE_TOOL_PATH = /usr/coreutils/bin:/usr/local/bin
-       SHELL_PATH = /usr/local/bin/bash
-       # as of H06.25/J06.14, we might better use this
-       #SHELL_PATH = /usr/coreutils/bin/bash
+       SHELL_PATH = /usr/coreutils/bin/bash
 endif
 ifneq (,$(findstring MINGW,$(uname_S)))
        pathsep = ;
@@ -572,9 +572,11 @@ else
                prefix = /usr/
                ifeq (MINGW32,$(MSYSTEM))
                        prefix = /mingw32
+                       HOST_CPU = i686
                endif
                ifeq (MINGW64,$(MSYSTEM))
                        prefix = /mingw64
+                       HOST_CPU = x86_64
                else
                        COMPAT_CFLAGS += -D_USE_32BIT_TIME_T
                        BASIC_LDFLAGS += -Wl,--large-address-aware
index 29a19902aaa00b90176e253c90c2384fca65857c..6573808ebd991b52eca7cc644af4c9611b9c3747 100644 (file)
@@ -1234,6 +1234,14 @@ struct tm *git_gmtime_r(const time_t *, struct tm *);
 #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
index 972402e8c0a09de5ec9069826cbb7ecae1ac9803..0db410d59023e4b2fdd21bc342872324e7c2e7b3 100644 (file)
@@ -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")
index 93e891309bb7982c283c77e8950ba8848fdd7d2b..4d505b3590ed158600844cfe3889112b5da4e511 100644 (file)
@@ -107,8 +107,6 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla
                    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
index d1cc77c124c11ffd49be472b1368baeda3afbe17..6dda2c16df1026e50b7d9be255b6bbfc4e92725c 100644 (file)
@@ -1820,9 +1820,11 @@ void maybe_die_on_misspelt_object_name(const char *name, const char *prefix)
                               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");
index 1326fd7505fde3a9e34fef1e197623c8d409d6ff..886bbec5bc8e40995817c042874be4860a4b58b8 100644 (file)
--- a/t/README
+++ b/t/README
@@ -211,6 +211,11 @@ appropriately before running "make".
        '.stress-<nr>' suffix, and the trash directory of the failed
        test job is renamed to end with a '.stress-failed' suffix.
 
+--stress-limit=<N>::
+       When combined with --stress run the test script repeatedly
+       this many times in each of the parallel jobs or until one of
+       them fails, whichever comes first.
+
 You can also set the GIT_TEST_INSTALLED environment variable to
 the bindir of an existing git installation to test that installation.
 You still need to have built this git sandbox, from which various
index e58ecbfc44037fa1d38707b30545e803e1401b4f..1090e650edb788ec7dc570c0412cb87b1f245219 100755 (executable)
@@ -6,6 +6,30 @@ test_description='working-tree-encoding conversion via gitattributes'
 
 GIT_TRACE_WORKING_TREE_ENCODING=1 && export GIT_TRACE_WORKING_TREE_ENCODING
 
+test_lazy_prereq NO_UTF16_BOM '
+       test $(printf abc | iconv -f UTF-8 -t UTF-16 | wc -c) = 6
+'
+
+test_lazy_prereq NO_UTF32_BOM '
+       test $(printf abc | iconv -f UTF-8 -t UTF-32 | wc -c) = 12
+'
+
+write_utf16 () {
+       if test_have_prereq NO_UTF16_BOM
+       then
+               printf '\xfe\xff'
+       fi &&
+       iconv -f UTF-8 -t UTF-16
+}
+
+write_utf32 () {
+       if test_have_prereq NO_UTF32_BOM
+       then
+               printf '\x00\x00\xfe\xff'
+       fi &&
+       iconv -f UTF-8 -t UTF-32
+}
+
 test_expect_success 'setup test files' '
        git config core.eol lf &&
 
@@ -13,8 +37,8 @@ test_expect_success 'setup test files' '
        echo "*.utf16 text working-tree-encoding=utf-16" >.gitattributes &&
        echo "*.utf16lebom text working-tree-encoding=UTF-16LE-BOM" >>.gitattributes &&
        printf "$text" >test.utf8.raw &&
-       printf "$text" | iconv -f UTF-8 -t UTF-16 >test.utf16.raw &&
-       printf "$text" | iconv -f UTF-8 -t UTF-32 >test.utf32.raw &&
+       printf "$text" | write_utf16 >test.utf16.raw &&
+       printf "$text" | write_utf32 >test.utf32.raw &&
        printf "\377\376"                         >test.utf16lebom.raw &&
        printf "$text" | iconv -f UTF-8 -t UTF-32LE >>test.utf16lebom.raw &&
 
@@ -25,12 +49,12 @@ test_expect_success 'setup test files' '
        # BOM tests
        printf "\0a\0b\0c"                         >nobom.utf16be.raw &&
        printf "a\0b\0c\0"                         >nobom.utf16le.raw &&
-       printf "\376\777\0a\0b\0c"                 >bebom.utf16be.raw &&
-       printf "\777\376a\0b\0c\0"                 >lebom.utf16le.raw &&
+       printf "\376\377\0a\0b\0c"                 >bebom.utf16be.raw &&
+       printf "\377\376a\0b\0c\0"                 >lebom.utf16le.raw &&
        printf "\0\0\0a\0\0\0b\0\0\0c"             >nobom.utf32be.raw &&
        printf "a\0\0\0b\0\0\0c\0\0\0"             >nobom.utf32le.raw &&
-       printf "\0\0\376\777\0\0\0a\0\0\0b\0\0\0c" >bebom.utf32be.raw &&
-       printf "\777\376\0\0a\0\0\0b\0\0\0c\0\0\0" >lebom.utf32le.raw &&
+       printf "\0\0\376\377\0\0\0a\0\0\0b\0\0\0c" >bebom.utf32be.raw &&
+       printf "\377\376\0\0a\0\0\0b\0\0\0c\0\0\0" >lebom.utf32le.raw &&
 
        # Add only UTF-16 file, we will add the UTF-32 file later
        cp test.utf16.raw test.utf16 &&
@@ -124,8 +148,8 @@ do
                test_when_finished "rm -f crlf.utf${i}.raw lf.utf${i}.raw" &&
                test_when_finished "git reset --hard HEAD^" &&
 
-               cat lf.utf8.raw | iconv -f UTF-8 -t UTF-${i} >lf.utf${i}.raw &&
-               cat crlf.utf8.raw | iconv -f UTF-8 -t UTF-${i} >crlf.utf${i}.raw &&
+               cat lf.utf8.raw | write_utf${i} >lf.utf${i}.raw &&
+               cat crlf.utf8.raw | write_utf${i} >crlf.utf${i}.raw &&
                cp crlf.utf${i}.raw eol.utf${i} &&
 
                cat >expectIndexLF <<-EOF &&
@@ -223,7 +247,7 @@ test_expect_success ICONV_SHIFT_JIS 'check roundtrip encoding' '
 
        text="hallo there!\nroundtrip test here!" &&
        printf "$text" | iconv -f UTF-8 -t SHIFT-JIS >roundtrip.shift &&
-       printf "$text" | iconv -f UTF-8 -t UTF-16 >roundtrip.utf16 &&
+       printf "$text" | write_utf16 >roundtrip.utf16 &&
        echo "*.shift text working-tree-encoding=SHIFT-JIS" >>.gitattributes &&
 
        # SHIFT-JIS encoded files are round-trip checked by default...
index 16d10ebce82fa1fc2e4396f8d30911541b96d7b6..d4bd1522fe2e6e94578b2d6f709005c7a271b4b0 100755 (executable)
@@ -383,7 +383,7 @@ corrupt_graph_and_verify() {
        cp $objdir/info/commit-graph commit-graph-backup &&
        printf "$data" | dd of="$objdir/info/commit-graph" bs=1 seek="$pos" conv=notrunc &&
        dd of="$objdir/info/commit-graph" bs=1 seek="$zero_pos" count=0 &&
-       dd if=/dev/zero of="$objdir/info/commit-graph" bs=1 seek="$zero_pos" count=$(($orig_size - $zero_pos)) &&
+       generate_zero_bytes $(($orig_size - $zero_pos)) >>"$objdir/info/commit-graph" &&
        test_must_fail git commit-graph verify 2>test_err &&
        grep -v "^+" test_err >err &&
        test_i18ngrep "$grepstr" err
index 90d890d02fd8f5451d0d78d880f6698d11b22a3d..bbadde2c6e6df58aebcc7e378824993cdefb31fd 100755 (executable)
@@ -143,14 +143,14 @@ test_expect_success GZIP 'push gzipped empty' '
 
 test_expect_success 'CONTENT_LENGTH overflow ssite_t' '
        NOT_FIT_IN_SSIZE=$(ssize_b100dots) &&
-       env \
+       generate_zero_bytes infinity  | env \
                CONTENT_TYPE=application/x-git-upload-pack-request \
                QUERY_STRING=/repo.git/git-upload-pack \
                PATH_TRANSLATED="$PWD"/.git/git-upload-pack \
                GIT_HTTP_EXPORT_ALL=TRUE \
                REQUEST_METHOD=POST \
                CONTENT_LENGTH="$NOT_FIT_IN_SSIZE" \
-               git http-backend </dev/zero >/dev/null 2>err &&
+               git http-backend >/dev/null 2>err &&
        grep "fatal:.*CONTENT_LENGTH" err
 '
 
index 92cf8f812cca26c94c8054ccd40af806f6b77310..094c07748aad423bff0eb8d5ff65ddceb3a4f5a6 100644 (file)
@@ -116,6 +116,19 @@ remove_cr () {
        tr '\015' Q | sed -e 's/Q$//'
 }
 
+# Generate an output of $1 bytes of all zeroes (NULs, not ASCII zeroes).
+# If $1 is 'infinity', output forever or until the receiving pipe stops reading,
+# whichever comes first.
+generate_zero_bytes () {
+       perl -e 'if ($ARGV[0] == "infinity") {
+               while (-1) {
+                       print "\0"
+               }
+       } else {
+               print "\0" x $ARGV[0]
+       }' "$@"
+}
+
 # In some bourne shell implementations, the "unset" builtin returns
 # nonzero status when a variable to be unset was not set in the first
 # place.
@@ -1289,7 +1302,7 @@ test_set_port () {
                        port=$(($port + 10000))
                fi
                ;;
-       *[^0-9]*|0*)
+       *[!0-9]*|0*)
                error >&7 "invalid port number: $port"
                ;;
        *)
index 42b1a0aa7f0b8f5b06735293089f640b7f228f62..8665b0a9b6186a7ad17889213f5225265c9f27d1 100644 (file)
@@ -149,7 +149,7 @@ do
        --stress=*)
                stress=${opt#--*=}
                case "$stress" in
-               *[^0-9]*|0*|"")
+               *[!0-9]*|0*|"")
                        echo "error: --stress=<N> requires the number of jobs to run" >&2
                        exit 1
                        ;;
@@ -157,6 +157,17 @@ do
                        ;;
                esac
                ;;
+       --stress-limit=*)
+               stress_limit=${opt#--*=}
+               case "$stress_limit" in
+               *[!0-9]*|0*|"")
+                       echo "error: --stress-limit=<N> requires the number of repetitions" >&2
+                       exit 1
+                       ;;
+               *)      # Good.
+                       ;;
+               esac
+               ;;
        *)
                echo "error: unknown test option '$opt'" >&2; exit 1 ;;
        esac
@@ -242,8 +253,10 @@ then
                                exit 1
                        ' TERM INT
 
-                       cnt=0
-                       while ! test -e "$stressfail"
+                       cnt=1
+                       while ! test -e "$stressfail" &&
+                             { test -z "$stress_limit" ||
+                               test $cnt -le $stress_limit ; }
                        do
                                $TEST_SHELL_PATH "$0" "$@" >"$TEST_RESULTS_BASE.stress-$job_nr.out" 2>&1 &
                                test_pid=$!
@@ -266,6 +279,7 @@ then
 
        if test -f "$stressfail"
        then
+               stress_exit=1
                echo "Log(s) of failed test run(s):"
                for failed_job_nr in $(sort -n "$stressfail")
                do
diff --git a/utf8.c b/utf8.c
index 83824dc2f4ab151a19418c61c46e0c1ffbb0e42c..3b42fadffd7ccb89a5658fdf8d314014f299a769 100644 (file)
--- a/utf8.c
+++ b/utf8.c
@@ -559,6 +559,10 @@ char *reencode_string_len(const char *in, size_t insz,
        /*
         * For writing, UTF-16 iconv typically creates "UTF-16BE-BOM"
         * Some users under Windows want the little endian version
+        *
+        * We handle UTF-16 and UTF-32 ourselves only if the platform does not
+        * provide a BOM (which we require), since we want to match the behavior
+        * of the system tools and libc as much as possible.
         */
        if (same_utf_encoding("UTF-16LE-BOM", out_encoding)) {
                bom_str = utf16_le_bom;
@@ -568,6 +572,16 @@ char *reencode_string_len(const char *in, size_t insz,
                bom_str = utf16_be_bom;
                bom_len = sizeof(utf16_be_bom);
                out_encoding = "UTF-16BE";
+#ifdef ICONV_OMITS_BOM
+       } else if (same_utf_encoding("UTF-16", out_encoding)) {
+               bom_str = utf16_be_bom;
+               bom_len = sizeof(utf16_be_bom);
+               out_encoding = "UTF-16BE";
+       } else if (same_utf_encoding("UTF-32", out_encoding)) {
+               bom_str = utf32_be_bom;
+               bom_len = sizeof(utf32_be_bom);
+               out_encoding = "UTF-32BE";
+#endif
        }
 
        conv = iconv_open(out_encoding, in_encoding);