Making backup-dir-dels depend on backup-deleted.
[rsync-patches.git] / link-by-hash.diff
index 2d6b6d47126520123a8ca12a4d323aed76a149f0..ae06c75a679f20b300b383f66a44f98577f1d7f4 100644 (file)
@@ -12,7 +12,7 @@ To use this patch, run these commands for a successful build:
     ./configure
     make
 
-based-on: 24079e988fc31af4eba56cd2701fdc5a4154980d
+based-on: 28b519c93b6db30b6520d46f8cd65160213fddd2
 diff --git a/Makefile.in b/Makefile.in
 --- a/Makefile.in
 +++ b/Makefile.in
@@ -28,15 +28,15 @@ diff --git a/Makefile.in b/Makefile.in
 diff --git a/flist.c b/flist.c
 --- a/flist.c
 +++ b/flist.c
-@@ -72,6 +72,7 @@ extern int sender_keeps_checksum;
- extern int unsort_ndx;
+@@ -72,6 +72,7 @@ extern int unsort_ndx;
+ extern uid_t our_uid;
  extern struct stats stats;
  extern char *filesfrom_host;
 +extern char *link_by_hash_dir;
  extern char *usermap, *groupmap;
  
  extern char curr_dir[MAXPATHLEN];
-@@ -908,7 +909,7 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
+@@ -910,7 +911,7 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
                extra_len += EXTRA_LEN;
  #endif
  
@@ -392,7 +392,7 @@ new file mode 100644
 diff --git a/options.c b/options.c
 --- a/options.c
 +++ b/options.c
-@@ -158,6 +158,7 @@ char *backup_suffix = NULL;
+@@ -159,6 +159,7 @@ char *backup_suffix = NULL;
  char *tmpdir = NULL;
  char *partial_dir = NULL;
  char *basis_dir[MAX_BASIS_DIRS+1];
@@ -400,7 +400,7 @@ diff --git a/options.c b/options.c
  char *config_file = NULL;
  char *shell_cmd = NULL;
  char *logfile_name = NULL;
-@@ -746,6 +747,7 @@ void usage(enum logcode F)
+@@ -758,6 +759,7 @@ void usage(enum logcode F)
    rprintf(F,"     --compare-dest=DIR      also compare destination files relative to DIR\n");
    rprintf(F,"     --copy-dest=DIR         ... and include copies of unchanged files\n");
    rprintf(F,"     --link-dest=DIR         hardlink to files in DIR when unchanged\n");
@@ -408,7 +408,7 @@ diff --git a/options.c b/options.c
    rprintf(F," -z, --compress              compress file data during the transfer\n");
    rprintf(F,"     --compress-level=NUM    explicitly set compression level\n");
    rprintf(F,"     --skip-compress=LIST    skip compressing files with a suffix in LIST\n");
-@@ -798,7 +800,7 @@ enum {OPT_VERSION = 1000, OPT_DAEMON, OPT_SENDER, OPT_EXCLUDE, OPT_EXCLUDE_FROM,
+@@ -810,7 +812,7 @@ enum {OPT_VERSION = 1000, OPT_DAEMON, OPT_SENDER, OPT_EXCLUDE, OPT_EXCLUDE_FROM,
        OPT_FILTER, OPT_COMPARE_DEST, OPT_COPY_DEST, OPT_LINK_DEST, OPT_HELP,
        OPT_INCLUDE, OPT_INCLUDE_FROM, OPT_MODIFY_WINDOW, OPT_MIN_SIZE, OPT_CHMOD,
        OPT_READ_BATCH, OPT_WRITE_BATCH, OPT_ONLY_WRITE_BATCH, OPT_MAX_SIZE,
@@ -417,7 +417,7 @@ diff --git a/options.c b/options.c
        OPT_USERMAP, OPT_GROUPMAP, OPT_CHOWN, OPT_BWLIMIT,
        OPT_SERVER, OPT_REFUSED_BASE = 9000};
  
-@@ -938,6 +940,7 @@ static struct poptOption long_options[] = {
+@@ -954,6 +956,7 @@ static struct poptOption long_options[] = {
    {"compare-dest",     0,  POPT_ARG_STRING, 0, OPT_COMPARE_DEST, 0, 0 },
    {"copy-dest",        0,  POPT_ARG_STRING, 0, OPT_COPY_DEST, 0, 0 },
    {"link-dest",        0,  POPT_ARG_STRING, 0, OPT_LINK_DEST, 0, 0 },
@@ -425,7 +425,7 @@ diff --git a/options.c b/options.c
    {"fuzzy",           'y', POPT_ARG_VAL,    &fuzzy_basis, 1, 0, 0 },
    {"no-fuzzy",         0,  POPT_ARG_VAL,    &fuzzy_basis, 0, 0, 0 },
    {"no-y",             0,  POPT_ARG_VAL,    &fuzzy_basis, 0, 0, 0 },
-@@ -1763,6 +1766,21 @@ int parse_arguments(int *argc_p, const char ***argv_p)
+@@ -1780,6 +1783,21 @@ int parse_arguments(int *argc_p, const char ***argv_p)
                        return 0;
  #endif
  
@@ -447,7 +447,7 @@ diff --git a/options.c b/options.c
                default:
                        /* A large opt value means that set_refuse_options()
                         * turned this option off. */
-@@ -2621,6 +2639,11 @@ void server_options(char **args, int *argc_p)
+@@ -2662,6 +2680,11 @@ void server_options(char **args, int *argc_p)
        } else if (inplace)
                args[ac++] = "--inplace";
  
@@ -462,7 +462,7 @@ diff --git a/options.c b/options.c
 diff --git a/receiver.c b/receiver.c
 --- a/receiver.c
 +++ b/receiver.c
-@@ -196,11 +196,13 @@ int open_tmpfile(char *fnametmp, const char *fname, struct file_struct *file)
+@@ -217,11 +217,13 @@ int open_tmpfile(char *fnametmp, const char *fname, struct file_struct *file)
  }
  
  static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
@@ -477,7 +477,7 @@ diff --git a/receiver.c b/receiver.c
        int32 len;
        OFF_T offset = 0;
        OFF_T offset2;
-@@ -220,6 +222,9 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
+@@ -257,6 +259,9 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
        } else
                mapbuf = NULL;
  
@@ -487,7 +487,7 @@ diff --git a/receiver.c b/receiver.c
        sum_init(checksum_seed);
  
        if (append_mode > 0) {
-@@ -264,6 +269,8 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
+@@ -304,6 +309,8 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
                        cleanup_got_literal = 1;
  
                        sum_update(data, i);
@@ -496,7 +496,7 @@ diff --git a/receiver.c b/receiver.c
  
                        if (fd != -1 && write_file(fd,data,i) != i)
                                goto report_write_error;
-@@ -290,6 +297,8 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
+@@ -331,6 +338,8 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
  
                        see_token(map, len);
                        sum_update(map, len);
@@ -505,7 +505,7 @@ diff --git a/receiver.c b/receiver.c
                }
  
                if (updating_basis_or_equiv) {
-@@ -337,6 +346,9 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
+@@ -384,6 +393,9 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
        if (sum_end(file_sum1) != checksum_len)
                overflow_exit("checksum_len"); /* Impossible... */
  
@@ -515,7 +515,7 @@ diff --git a/receiver.c b/receiver.c
        if (mapbuf)
                unmap_file(mapbuf);
  
-@@ -351,7 +363,7 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
+@@ -398,7 +410,7 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
  
  static void discard_receive_data(int f_in, OFF_T length)
  {
@@ -524,7 +524,7 @@ diff --git a/receiver.c b/receiver.c
  }
  
  static void handle_delayed_updates(char *local_name)
-@@ -779,7 +791,7 @@ int recv_files(int f_in, int f_out, char *local_name)
+@@ -828,7 +840,7 @@ int recv_files(int f_in, int f_out, char *local_name)
  
                /* recv file data */
                recv_ok = receive_data(f_in, fnamecmp, fd1, st.st_size,
@@ -536,7 +536,7 @@ diff --git a/receiver.c b/receiver.c
 diff --git a/rsync.c b/rsync.c
 --- a/rsync.c
 +++ b/rsync.c
-@@ -48,6 +48,7 @@ extern int flist_eof;
+@@ -47,6 +47,7 @@ extern int flist_eof;
  extern int file_old_total;
  extern int keep_dirlinks;
  extern int make_backups;
@@ -544,28 +544,24 @@ diff --git a/rsync.c b/rsync.c
  extern struct file_list *cur_flist, *first_flist, *dir_flist;
  extern struct chmod_mode_struct *daemon_chmod_modes;
  #ifdef ICONV_OPTION
-@@ -644,8 +645,15 @@ int finish_transfer(const char *fname, const char *fnametmp,
+@@ -648,7 +649,12 @@ int finish_transfer(const char *fname, const char *fnametmp,
        /* move tmp file over real file */
        if (DEBUG_GTE(RECV, 1))
                rprintf(FINFO, "renaming %s to %s\n", fnametmp, fname);
--      ret = robust_rename(fnametmp, fname, temp_copy_name,
--                          file->mode & INITACCESSPERMS);
+-      ret = robust_rename(fnametmp, fname, temp_copy_name, file->mode);
 +#ifdef HAVE_LINK
 +      if (link_by_hash_dir)
 +              ret = link_by_hash(fnametmp, fname, file);
 +      else
 +#endif
-+      {
-+              ret = robust_rename(fnametmp, fname, temp_copy_name,
-+                                  file->mode & INITACCESSPERMS);
-+      }
++              ret = robust_rename(fnametmp, fname, temp_copy_name, file->mode);
        if (ret < 0) {
                rsyserr(FERROR_XFER, errno, "%s %s -> \"%s\"",
                        ret == -2 ? "copy" : "rename",
 diff --git a/rsync.h b/rsync.h
 --- a/rsync.h
 +++ b/rsync.h
-@@ -865,6 +865,14 @@ struct stats {
+@@ -899,6 +899,14 @@ struct stats {
        int xferred_files;
  };
  
@@ -583,7 +579,7 @@ diff --git a/rsync.h b/rsync.h
 diff --git a/rsync.yo b/rsync.yo
 --- a/rsync.yo
 +++ b/rsync.yo
-@@ -400,6 +400,7 @@ to the detailed description below for a complete description.  verb(
+@@ -402,6 +402,7 @@ to the detailed description below for a complete description.  verb(
       --compare-dest=DIR      also compare received files relative to DIR
       --copy-dest=DIR         ... and include copies of unchanged files
       --link-dest=DIR         hardlink to files in DIR when unchanged