A minor improvement to the variables involved.
[rsync/rsync-patches.git] / inplace-protocol-bump.diff
CommitLineData
59790457
WD
1This patch sends the new fnamecmp_type value from the generator to the
2sender if --inplace was specified. This allows the sender to know when
3the transfer can fully utilize the basis file (i.e., when the basis file
4is not the destination file).
5
be47f4c4 6--- orig/generator.c 2004-11-11 22:13:09
59790457 7+++ generator.c 2004-11-03 20:37:57
be47f4c4 8@@ -568,6 +568,8 @@ prepare_to_open:
59790457
WD
9
10 notify_others:
11 write_int(f_out, i);
12+ if (protocol_version >= 29 && inplace && !read_batch)
13+ write_byte(f_out, fnamecmp_type);
14 if (f_out_name >= 0)
15 write_byte(f_out_name, fnamecmp_type);
16
17--- orig/match.c 2004-09-07 21:45:30
be47f4c4
WD
18+++ match.c 2004-11-12 05:48:57
19@@ -23,8 +23,8 @@ extern int verbose;
20 extern int am_server;
59790457
WD
21 extern int do_progress;
22 extern int checksum_seed;
be47f4c4 23-extern int inplace;
59790457
WD
24-extern int make_backups;
25+
be47f4c4 26+int updating_basis_file;
59790457
WD
27
28 typedef unsigned short tag;
29
be47f4c4
WD
30@@ -203,9 +203,9 @@ static void hash_search(int f,struct sum
31 if (l != s->sums[i].len)
32 continue;
59790457 33
be47f4c4
WD
34- /* inplace: ensure chunk's offset is either >= our
35+ /* in-place: ensure chunk's offset is either >= our
59790457
WD
36 * offset or that the data didn't move. */
37- if (inplace && !make_backups && s->sums[i].offset < offset
be47f4c4 38+ if (updating_basis_file && s->sums[i].offset < offset
59790457
WD
39 && !(s->sums[i].flags & SUMFLG_SAME_OFFSET))
40 continue;
41
be47f4c4
WD
42@@ -224,10 +224,10 @@ static void hash_search(int f,struct sum
43 continue;
44 }
45
46- /* If inplace is enabled, the best possible match is
47+ /* When updating in-place, the best possible match is
59790457
WD
48 * one with an identical offset, so we prefer that over
49 * the following want_i optimization. */
50- if (inplace && !make_backups) {
be47f4c4 51+ if (updating_basis_file) {
59790457
WD
52 do {
53 size_t i2 = targets[j].i;
54 if (s->sums[i2].offset != offset)
be47f4c4 55@@ -250,7 +250,7 @@ static void hash_search(int f,struct sum
59790457
WD
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
be47f4c4 60+ && (!updating_basis_file || s->sums[want_i].offset >= offset
59790457
WD
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) {
be47f4c4 64--- orig/options.c 2004-11-11 22:13:09
59790457 65+++ options.c 2004-11-03 20:47:21
be47f4c4 66@@ -917,10 +917,9 @@ int parse_arguments(int *argc, const cha
59790457
WD
67 am_server ? "server" : "client");
68 return 0;
69 #endif
70- if (compare_dest) {
71+ if (link_dest) {
72 snprintf(err_buf, sizeof err_buf,
73- "--inplace does not yet work with %s\n",
74- link_dest ? "--link-dest" : "--compare-dest");
75+ "--inplace does not yet work with --link-dest\n");
76 return 0;
77 }
78 } else {
79--- orig/rsync.h 2004-11-03 20:30:45
80+++ rsync.h 2004-11-03 20:32:34
81@@ -62,7 +62,7 @@
82 #define FLAG_MOUNT_POINT (1<<2) /* sender only */
83
84 /* update this if you make incompatible changes */
85-#define PROTOCOL_VERSION 28
86+#define PROTOCOL_VERSION 29
87
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 2004-09-20 05:10:48
be47f4c4 91+++ sender.c 2004-11-12 05:51:25
59790457
WD
92@@ -27,7 +27,9 @@ extern int dry_run;
93 extern int am_server;
94 extern int am_daemon;
95 extern int protocol_version;
be47f4c4 96+extern int updating_basis_file;
59790457
WD
97 extern int make_backups;
98+extern int inplace;
99 extern struct stats stats;
100
101
be47f4c4 102@@ -166,6 +168,11 @@ void send_files(struct file_list *flist,
59790457
WD
103 } else
104 offset = 0;
105 fname2 = f_name_to(file, fname + offset);
be47f4c4
WD
106+ if (inplace && protocol_version >= 29) {
107+ uchar fnamecmp_type = read_byte(f_in);
108+ updating_basis_file = fnamecmp_type == FNAMECMP_FNAME;
59790457 109+ } else
be47f4c4 110+ updating_basis_file = inplace && !make_backups;
59790457
WD
111
112 if (verbose > 2)
113 rprintf(FINFO, "send_files(%d, %s)\n", i, fname);