Merge pull request #5236 from lynxis/rb_perl
[feed/packages.git] / net / rsync / patches / 005-more-fixes-for-progress-quirks.patch
1 commit ff66fd4bb6cc76488c6ea1e4b651a869847f6375
2 Author: Wayne Davison <wayned@samba.org>
3 Date: Sat Oct 29 14:47:58 2016 -0700
4
5 More fixes for --progress quirks.
6
7 This patch avoids inconsistent evaluation of options in the
8 show_filelist_p() function by turning it into a var. We
9 also avoid setting "output_needs_newline" if --quiet was
10 specified.
11
12 diff --git a/flist.c b/flist.c
13 index 4a9f4e6..54ced36 100644
14 --- a/flist.c
15 +++ b/flist.c
16 @@ -37,6 +37,7 @@ extern int checksum_type;
17 extern int module_id;
18 extern int ignore_errors;
19 extern int numeric_ids;
20 +extern int quiet;
21 extern int recurse;
22 extern int use_qsort;
23 extern int xfer_dirs;
24 @@ -128,6 +129,7 @@ static char tmp_sum[MAX_DIGEST_LEN];
25
26 static char empty_sum[MAX_DIGEST_LEN];
27 static int flist_count_offset; /* for --delete --progress */
28 +static int show_filelist_progress;
29
30 static void flist_sort_and_clean(struct file_list *flist, int strip_root);
31 static void output_flist(struct file_list *flist);
32 @@ -140,15 +142,14 @@ void init_flist(void)
33 }
34 parse_checksum_choice(); /* Sets checksum_type && xfersum_type */
35 checksum_len = csum_len_for_type(checksum_type);
36 -}
37
38 -static int show_filelist_p(void)
39 -{
40 - return INFO_GTE(FLIST, 1) && xfer_dirs && !am_server && !inc_recurse;
41 + show_filelist_progress = INFO_GTE(FLIST, 1) && xfer_dirs && !am_server && !inc_recurse;
42 }
43
44 static void start_filelist_progress(char *kind)
45 {
46 + if (quiet)
47 + return;
48 rprintf(FCLIENT, "%s ... ", kind);
49 output_needs_newline = 1;
50 rflush(FINFO);
51 @@ -156,25 +157,28 @@ static void start_filelist_progress(char *kind)
52
53 static void emit_filelist_progress(int count)
54 {
55 - output_needs_newline = 0; /* avoid a newline in the middle of this filelist-progress output */
56 + if (quiet)
57 + return;
58 + if (output_needs_newline == 2) /* avoid a newline in the middle of this filelist-progress output */
59 + output_needs_newline = 0;
60 rprintf(FCLIENT, " %d files...\r", count);
61 - output_needs_newline = 1;
62 + output_needs_newline = 2;
63 }
64
65 static void maybe_emit_filelist_progress(int count)
66 {
67 - if (INFO_GTE(FLIST, 2) && show_filelist_p() && (count % 100) == 0)
68 + if (INFO_GTE(FLIST, 2) && show_filelist_progress && (count % 100) == 0)
69 emit_filelist_progress(count);
70 }
71
72 static void finish_filelist_progress(const struct file_list *flist)
73 {
74 + output_needs_newline = 0;
75 if (INFO_GTE(FLIST, 2)) {
76 /* This overwrites the progress line */
77 rprintf(FINFO, "%d file%sto consider\n",
78 flist->used, flist->used == 1 ? " " : "s ");
79 } else {
80 - output_needs_newline = 0;
81 rprintf(FINFO, "done\n");
82 }
83 }
84 @@ -2089,7 +2093,7 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
85 int implied_dot_dir = 0;
86
87 rprintf(FLOG, "building file list\n");
88 - if (show_filelist_p())
89 + if (show_filelist_progress)
90 start_filelist_progress("building file list");
91 else if (inc_recurse && INFO_GTE(FLIST, 1) && !am_server)
92 rprintf(FCLIENT, "sending incremental file list\n");
93 @@ -2363,7 +2367,7 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
94 idev_destroy();
95 #endif
96
97 - if (show_filelist_p())
98 + if (show_filelist_progress)
99 finish_filelist_progress(flist);
100
101 gettimeofday(&end_tv, NULL);
102 @@ -2445,7 +2449,7 @@ struct file_list *recv_file_list(int f, int dir_ndx)
103 int64 start_read;
104
105 if (!first_flist) {
106 - if (show_filelist_p())
107 + if (show_filelist_progress)
108 start_filelist_progress("receiving file list");
109 else if (inc_recurse && INFO_GTE(FLIST, 1) && !am_server)
110 rprintf(FCLIENT, "receiving incremental file list\n");
111 @@ -2541,7 +2545,7 @@ struct file_list *recv_file_list(int f, int dir_ndx)
112 if (DEBUG_GTE(FLIST, 2))
113 rprintf(FINFO, "received %d names\n", flist->used);
114
115 - if (show_filelist_p())
116 + if (show_filelist_progress)
117 finish_filelist_progress(flist);
118
119 if (need_unsorted_flist) {
120 diff --git a/progress.c b/progress.c
121 index 3858fc4..d19fa25 100644
122 --- a/progress.c
123 +++ b/progress.c
124 @@ -25,6 +25,7 @@
125
126 extern int am_server;
127 extern int flist_eof;
128 +extern int quiet;
129 extern int need_unsorted_flist;
130 extern int output_needs_newline;
131 extern struct stats stats;
132 @@ -127,7 +128,7 @@ static void rprint_progress(OFF_T ofs, OFF_T size, struct timeval *now,
133 pct = ofs == size ? 100 : (int) (100.0 * ofs / size);
134 rprintf(FCLIENT, "\r%15s %3d%% %7.2f%s %s%s",
135 human_num(ofs), pct, rate, units, rembuf, eol);
136 - if (!is_last) {
137 + if (!is_last && !quiet) {
138 output_needs_newline = 1;
139 rflush(FCLIENT);
140 }