]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'js/format-2047'
authorJeff King <peff@peff.net>
Fri, 9 Nov 2012 17:42:32 +0000 (12:42 -0500)
committerJeff King <peff@peff.net>
Fri, 9 Nov 2012 17:42:32 +0000 (12:42 -0500)
Fixes many rfc2047 quoting issues in the output from format-patch.

* js/format-2047:
  format-patch tests: check quoting/encoding in To: and Cc: headers
  format-patch: fix rfc2047 address encoding with respect to rfc822 specials
  format-patch: make rfc2047 encoding more strict
  format-patch: introduce helper function last_line_length()
  format-patch: do not wrap rfc2047 encoded headers too late
  format-patch: do not wrap non-rfc2047 headers too early
  utf8: fix off-by-one wrapping of text

1  2 
git-compat-util.h
t/t4202-log.sh
utf8.c

diff --combined git-compat-util.h
index 2fbf1fd8b14a57e065674ffec238406f09b71639,f011a8d7bb9fc61b0bd840ea954257f505bd62d5..2e79b8a2f379d7c72a0934b36c7538db2143c722
@@@ -74,8 -74,7 +74,8 @@@
  # define _XOPEN_SOURCE 500
  # endif
  #elif !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__USLC__) && \
 -      !defined(_M_UNIX) && !defined(__sgi) && !defined(__DragonFly__)
 +      !defined(_M_UNIX) && !defined(__sgi) && !defined(__DragonFly__) && \
 +      !defined(__TANDEM)
  #define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */
  #define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */
  #endif
@@@ -99,9 -98,6 +99,9 @@@
  #include <stdlib.h>
  #include <stdarg.h>
  #include <string.h>
 +#ifdef __TANDEM /* or HAVE_STRINGS_H or !NO_STRINGS_H? */
 +#include <strings.h> /* for strcasecmp() */
 +#endif
  #include <errno.h>
  #include <limits.h>
  #include <sys/param.h>
  #else
  #include <stdint.h>
  #endif
 +#ifdef NO_INTPTR_T
 +/*
 + * On I16LP32, ILP32 and LP64 "long" is the save bet, however
 + * on LLP86, IL33LLP64 and P64 it needs to be "long long",
 + * while on IP16 and IP16L32 it is "int" (resp. "short")
 + * Size needs to match (or exceed) 'sizeof(void *)'.
 + * We can't take "long long" here as not everybody has it.
 + */
 +typedef long intptr_t;
 +typedef unsigned long uintptr_t;
 +#endif
  #if defined(__CYGWIN__)
  #undef _XOPEN_SOURCE
  #include <grp.h>
  #endif
  #endif
  
 +/* used on Mac OS X */
 +#ifdef PRECOMPOSE_UNICODE
 +#include "compat/precompose_utf8.h"
 +#else
 +#define precompose_str(in,i_nfd2nfc)
 +#define precompose_argv(c,v)
 +#define probe_utf8_pathname_composition(a,b)
 +#endif
 +
 +#ifdef MKDIR_WO_TRAILING_SLASH
 +#define mkdir(a,b) compat_mkdir_wo_trailing_slash((a),(b))
 +extern int compat_mkdir_wo_trailing_slash(const char*, mode_t);
 +#endif
 +
 +#ifdef NO_STRUCT_ITIMERVAL
 +struct itimerval {
 +      struct timeval it_interval;
 +      struct timeval it_value;
 +}
 +#endif
 +
 +#ifdef NO_SETITIMER
 +#define setitimer(which,value,ovalue)
 +#endif
 +
  #ifndef NO_LIBGEN_H
  #include <libgen.h>
  #else
@@@ -506,6 -466,7 +506,7 @@@ extern const char tolower_trans_tbl[256
  #undef isdigit
  #undef isalpha
  #undef isalnum
+ #undef isprint
  #undef islower
  #undef isupper
  #undef tolower
@@@ -523,6 -484,7 +524,7 @@@ extern unsigned char sane_ctype[256]
  #define isdigit(x) sane_istest(x,GIT_DIGIT)
  #define isalpha(x) sane_istest(x,GIT_ALPHA)
  #define isalnum(x) sane_istest(x,GIT_ALPHA | GIT_DIGIT)
+ #define isprint(x) ((x) >= 0x20 && (x) <= 0x7e)
  #define islower(x) sane_iscase(x, 1)
  #define isupper(x) sane_iscase(x, 0)
  #define is_glob_special(x) sane_istest(x,GIT_GLOB_SPECIAL)
@@@ -635,12 -597,6 +637,12 @@@ int rmdir_or_warn(const char *path)
   */
  int remove_or_warn(unsigned int mode, const char *path);
  
 +/* Call access(2), but warn for any error besides ENOENT. */
 +int access_or_warn(const char *path, int mode);
 +
 +/* Warn on an inaccessible file that ought to be accessible */
 +void warn_on_inaccessible(const char *path);
 +
  /* Get the passwd entry for the UID of the current process. */
  struct passwd *xgetpwuid_self(void);
  
diff --combined t/t4202-log.sh
index e6537abe1d611aa2d96215fb263f76c5c0cf3b1a,37023e30ea7c747f7dd92efebd2195127e94103a..a343bf6c629f8e6acaf7559d3168a97fcce9d286
@@@ -72,9 -72,9 +72,9 @@@ cat > expect << EO
    commit.
  EOF
  
- test_expect_success 'format %w(12,1,2)' '
+ test_expect_success 'format %w(11,1,2)' '
  
-       git log -2 --format="%w(12,1,2)This is the %s commit." > actual &&
+       git log -2 --format="%w(11,1,2)This is the %s commit." > actual &&
        test_cmp expect actual
  '
  
@@@ -178,21 -178,11 +178,21 @@@ test_expect_success 'git log --no-walk 
        test_cmp expect actual
  '
  
 +test_expect_success 'git log --no-walk=sorted <commits> sorts by commit time' '
 +      git log --no-walk=sorted --oneline 5d31159 804a787 394ef78 > actual &&
 +      test_cmp expect actual
 +'
 +
  cat > expect << EOF
  5d31159 fourth
  804a787 sixth
  394ef78 fifth
  EOF
 +test_expect_success 'git log --no-walk=unsorted <commits> leaves list of commits as given' '
 +      git log --no-walk=unsorted --oneline 5d31159 804a787 394ef78 > actual &&
 +      test_cmp expect actual
 +'
 +
  test_expect_success 'git show <commits> leaves list of commits as given' '
        git show --oneline -s 5d31159 804a787 394ef78 > actual &&
        test_cmp expect actual
@@@ -230,12 -220,6 +230,12 @@@ test_expect_success 'log --grep -i' 
        test_cmp expect actual
  '
  
 +test_expect_success 'log -F -E --grep=<ere> uses ere' '
 +      echo second >expect &&
 +      git log -1 --pretty="tformat:%s" -F -E --grep=s.c.nd >actual &&
 +      test_cmp expect actual
 +'
 +
  cat > expect <<EOF
  * Second
  * sixth
@@@ -819,7 -803,7 +819,7 @@@ sanitize_output () 
  test_expect_success 'log --graph with diff and stats' '
        git log --graph --pretty=short --stat -p >actual &&
        sanitize_output >actual.sanitized <actual &&
 -      test_cmp expect actual.sanitized
 +      test_i18ncmp expect actual.sanitized
  '
  
  test_expect_success 'dotdot is a parent directory' '
diff --combined utf8.c
index a544f15456656df642253533eaa28885ce3496a6,523a78a651c50129ab759fa319f8bfce55b2bee7..28791a7c3174924967182d54c8b4a7f9600c87bf
--- 1/utf8.c
--- 2/utf8.c
+++ b/utf8.c
@@@ -353,7 -353,7 +353,7 @@@ retry
  
                c = *text;
                if (!c || isspace(c)) {
-                       if (w < width || !space) {
+                       if (w <= width || !space) {
                                const char *start = bol;
                                if (!c && text == start)
                                        return w;
@@@ -433,12 -433,19 +433,12 @@@ int is_encoding_utf8(const char *name
  #else
        typedef char * iconv_ibp;
  #endif
 -char *reencode_string(const char *in, const char *out_encoding, const char *in_encoding)
 +char *reencode_string_iconv(const char *in, size_t insz, iconv_t conv)
  {
 -      iconv_t conv;
 -      size_t insz, outsz, outalloc;
 +      size_t outsz, outalloc;
        char *out, *outpos;
        iconv_ibp cp;
  
 -      if (!in_encoding)
 -              return NULL;
 -      conv = iconv_open(out_encoding, in_encoding);
 -      if (conv == (iconv_t) -1)
 -              return NULL;
 -      insz = strlen(in);
        outsz = insz;
        outalloc = outsz + 1; /* for terminating NUL */
        out = xmalloc(outalloc);
                        size_t sofar;
                        if (errno != E2BIG) {
                                free(out);
 -                              iconv_close(conv);
                                return NULL;
                        }
                        /* insz has remaining number of bytes.
                        break;
                }
        }
 +      return out;
 +}
 +
 +char *reencode_string(const char *in, const char *out_encoding, const char *in_encoding)
 +{
 +      iconv_t conv;
 +      char *out;
 +
 +      if (!in_encoding)
 +              return NULL;
 +      conv = iconv_open(out_encoding, in_encoding);
 +      if (conv == (iconv_t) -1)
 +              return NULL;
 +      out = reencode_string_iconv(in, strlen(in), conv);
        iconv_close(conv);
        return out;
  }