update longlink patch for upstream 1.27
[debian/tar] / debian / patches / longlink-hack.diff
1 diff --git a/src/common.h b/src/common.h
2 index eb801bb..4aaace5 100644
3 --- a/src/common.h
4 +++ b/src/common.h
5 @@ -907,4 +907,6 @@ void finish_deferred_unlinks (void);
6  /* Module exit.c */
7  extern void (*fatal_exit_hook) (void);
8  
9 +GLOBAL int debian_longlink_hack;
10 +
11  _GL_INLINE_HEADER_END
12 diff --git a/src/create.c b/src/create.c
13 index e14e13d..3a84c79 100644
14 --- a/src/create.c
15 +++ b/src/create.c
16 @@ -27,6 +27,8 @@
17  #include "common.h"
18  #include <hash.h>
19  
20 +extern int debian_longlink_hack;
21 +
22  /* Error number to use when an impostor is discovered.
23     Pretend the impostor isn't there.  */
24  enum { IMPOSTOR_ERRNO = ENOENT };
25 @@ -724,7 +726,7 @@ write_header_name (struct tar_stat_info *st)
26        return write_short_name (st);
27      }
28    else if (NAME_FIELD_SIZE - (archive_format == OLDGNU_FORMAT)
29 -          < strlen (st->file_name))
30 +          < strlen (st->file_name) + debian_longlink_hack)
31      return write_long_name (st);
32    else
33      return write_short_name (st);
34 @@ -1476,7 +1478,7 @@ dump_hard_link (struct tar_stat_info *st)
35           block_ordinal = current_block_ordinal ();
36           assign_string (&st->link_name, link_name);
37           if (NAME_FIELD_SIZE - (archive_format == OLDGNU_FORMAT)
38 -             < strlen (link_name))
39 +             < strlen (link_name) + debian_longlink_hack)
40             write_long_link (st);
41  
42           st->stat.st_size = 0;
43 diff --git a/src/tar.c b/src/tar.c
44 index 4f5017d..e9a5126 100644
45 --- a/src/tar.c
46 +++ b/src/tar.c
47 @@ -1246,6 +1246,16 @@ expand_pax_option (struct tar_args *targs, const char *arg)
48    return res;
49  }
50  
51 +/* Debian specific environment variable used by pristine-tar to enable use of
52 + * longlinks for filenames exactly 100 bytes long. */
53 +void debian_longlink_hack_init () {
54 + char *s=getenv ("TAR_LONGLINK_100");
55 + if (s && strcmp(s, "1") == 0)
56 +        debian_longlink_hack=1;
57 + else
58 +        debian_longlink_hack=0;
59 +}
60 +
61  \f
62  static uintmax_t
63  parse_owner_group (char *arg, uintmax_t field_max, char const **name_option)
64 @@ -2626,6 +2636,8 @@ main (int argc, char **argv)
65    filename_terminator = '\n';
66    set_quoting_style (0, DEFAULT_QUOTING_STYLE);
67  
68 +  debian_longlink_hack_init ();
69 +
70    /* Make sure we have first three descriptors available */
71    stdopen ();
72