1 This patch sends the new fnamecmp_type value from the generator to the
2 sender if --inplace was specified. This allows the sender to know when
3 the transfer can fully utilize the basis file (i.e., when the basis file
4 is not the destination file).
6 --- orig/generator.c 2005-01-14 18:30:18
7 +++ generator.c 2004-11-03 20:37:57
8 @@ -593,6 +593,8 @@ prepare_to_open:
12 + if (protocol_version >= 29 && inplace && !read_batch)
13 + write_byte(f_out, fnamecmp_type);
15 write_byte(f_out_name, fnamecmp_type);
17 --- orig/match.c 2005-01-01 21:11:00
18 +++ match.c 2004-11-12 05:48:57
19 @@ -23,8 +23,8 @@ extern int verbose;
21 extern int do_progress;
22 extern int checksum_seed;
24 -extern int make_backups;
26 +int updating_basis_file;
28 typedef unsigned short tag;
30 @@ -206,9 +206,9 @@ static void hash_search(int f,struct sum
31 if (l != s->sums[i].len)
34 - /* inplace: ensure chunk's offset is either >= our
35 + /* in-place: ensure chunk's offset is either >= our
36 * offset or that the data didn't move. */
37 - if (inplace && !make_backups && s->sums[i].offset < offset
38 + if (updating_basis_file && s->sums[i].offset < offset
39 && !(s->sums[i].flags & SUMFLG_SAME_OFFSET))
42 @@ -227,10 +227,10 @@ static void hash_search(int f,struct sum
46 - /* If inplace is enabled, the best possible match is
47 + /* When updating in-place, the best possible match is
48 * one with an identical offset, so we prefer that over
49 * the following want_i optimization. */
50 - if (inplace && !make_backups) {
51 + if (updating_basis_file) {
53 size_t i2 = targets[j].i;
54 if (s->sums[i2].offset != offset)
55 @@ -253,7 +253,7 @@ static void hash_search(int f,struct sum
56 /* we've found a match, but now check to see
57 * if want_i can hint at a better match. */
58 if (i != want_i && want_i < s->count
59 - && (!inplace || make_backups || s->sums[want_i].offset >= offset
60 + && (!updating_basis_file || s->sums[want_i].offset >= offset
61 || s->sums[want_i].flags & SUMFLG_SAME_OFFSET)
62 && sum == s->sums[want_i].sum1
63 && memcmp(sum2, s->sums[want_i].sum2, s->s2length) == 0) {
64 --- orig/options.c 2005-01-15 20:26:21
65 +++ options.c 2005-01-15 20:26:06
66 @@ -952,12 +952,6 @@ int parse_arguments(int *argc, const cha
71 - snprintf(err_buf, sizeof err_buf,
72 - "--inplace does not yet work with %s\n",
77 snprintf(err_buf, sizeof err_buf,
78 "--inplace is not supported on this %s\n",
79 --- orig/rsync.h 2005-01-10 00:21:12
80 +++ rsync.h 2004-11-03 20:32:34
82 #define FLAG_MOUNT_POINT (1<<2) /* sender only */
84 /* update this if you make incompatible changes */
85 -#define PROTOCOL_VERSION 28
86 +#define PROTOCOL_VERSION 29
88 /* We refuse to interoperate with versions that are not in this range.
89 * Note that we assume we'll work with later versions: the onus is on
90 --- orig/sender.c 2005-01-01 21:11:01
91 +++ sender.c 2004-11-12 05:51:25
92 @@ -27,7 +27,9 @@ extern int dry_run;
95 extern int protocol_version;
96 +extern int updating_basis_file;
97 extern int make_backups;
99 extern struct stats stats;
102 @@ -166,6 +168,11 @@ void send_files(struct file_list *flist,
105 fname2 = f_name_to(file, fname + offset);
106 + if (inplace && protocol_version >= 29) {
107 + uchar fnamecmp_type = read_byte(f_in);
108 + updating_basis_file = fnamecmp_type == FNAMECMP_FNAME;
110 + updating_basis_file = inplace && !make_backups;
113 rprintf(FINFO, "send_files(%d, %s)\n", i, fname);