Kill the useless progress meter in merge-recursive
The mess known as the progress meter in merge-recursive was my own fault; I put it in thinking that we might be spending a lot of time resolving unmerged entries in the index that were not handled by the simple 3-way index merge code. Turns out we don't really spend that much time there, so the progress meter was pretty much always jumping to "(n/n) 100%" as soon as the program started. That isn't a very good indication of progress. Since I don't have a great solution for how a progress meter should work here, I'm proposing we back it out entirely. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Shawn O. Pearce committed
Apr 20, 2007 at 02:37 UTC
ad57cbca61afc921349ddb9e884ceee5bf2322a8
1 file changed
+3
-62
merge-recursive.c
+3
-62
@@ -95,11 +95,6 @@ static struct path_list current_directory_set = {NULL, 0, 0, 1};
95
static int call_depth = 0;
96
static int verbosity = 2;
97
static int buffer_output = 1;
98
-static int do_progress = 1;
99
-static unsigned last_percent;
100
-static unsigned merged_cnt;
101
-static unsigned total_cnt;
102
-static volatile sig_atomic_t progress_update;
98
static struct output_buffer *output_list, *output_end;
99
100
static int show (int v)
@@ -174,39 +169,6 @@ static void output_commit_title(struct commit *commit)
169
}
170
}
171
177
-static void progress_interval(int signum)
178
-{
179
- progress_update = 1;
180
-}
181
-
182
-static void setup_progress_signal(void)
183
-{
184
- struct sigaction sa;
185
- struct itimerval v;
186
-
187
- memset(&sa, 0, sizeof(sa));
188
- sa.sa_handler = progress_interval;
189
- sigemptyset(&sa.sa_mask);
190
- sa.sa_flags = SA_RESTART;
191
- sigaction(SIGALRM, &sa, NULL);
192
-
193
- v.it_interval.tv_sec = 1;
194
- v.it_interval.tv_usec = 0;
195
- v.it_value = v.it_interval;
196
- setitimer(ITIMER_REAL, &v, NULL);
197
-}
198
-
199
-static void display_progress()
200
-{
201
- unsigned percent = total_cnt ? merged_cnt * 100 / total_cnt : 0;
202
- if (progress_update || percent != last_percent) {
203
- fprintf(stderr, "%4u%% (%u/%u) done\r",
204
- percent, merged_cnt, total_cnt);
205
- progress_update = 0;
206
- last_percent = percent;
207
- }
208
-}
209
-
172
static struct cache_entry *make_cache_entry(unsigned int mode,
173
const unsigned char *sha1, const char *path, int stage, int refresh)
174
{
@@ -377,14 +339,11 @@ static struct path_list *get_unmerged(void)
339
int i;
340
341
unmerged->strdup_paths = 1;
380
- total_cnt += active_nr;
342
382
- for (i = 0; i < active_nr; i++, merged_cnt++) {
343
+ for (i = 0; i < active_nr; i++) {
344
struct path_list_item *item;
345
struct stage_data *e;
346
struct cache_entry *ce = active_cache[i];
386
- if (do_progress)
387
- display_progress();
347
if (!ce_stage(ce))
348
continue;
349
@@ -1218,15 +1177,12 @@ static int merge_trees(struct tree *head,
1177
re_merge = get_renames(merge, common, head, merge, entries);
1178
clean = process_renames(re_head, re_merge,
1179
branch1, branch2);
1221
- total_cnt += entries->nr;
1222
- for (i = 0; i < entries->nr; i++, merged_cnt++) {
1180
+ for (i = 0; i < entries->nr; i++) {
1181
const char *path = entries->items[i].path;
1182
struct stage_data *e = entries->items[i].util;
1183
if (!e->processed
1184
&& !process_entry(path, e, branch1, branch2))
1185
clean = 0;
1228
- if (do_progress)
1229
- display_progress();
1186
}
1187
1188
path_list_clear(re_merge, 0);
@@ -1334,15 +1290,6 @@ static int merge(struct commit *h1,
1290
commit_list_insert(h1, &(*result)->parents);
1291
commit_list_insert(h2, &(*result)->parents->next);
1292
}
1337
- if (!call_depth && do_progress) {
1338
- /* Make sure we end at 100% */
1339
- if (!total_cnt)
1340
- total_cnt = 1;
1341
- merged_cnt = total_cnt;
1342
- progress_update = 1;
1343
- display_progress();
1344
- fputc('\n', stderr);
1345
- }
1293
flush_output();
1294
return clean;
1295
}
@@ -1419,12 +1366,8 @@ int main(int argc, char *argv[])
1366
}
1367
if (argc - i != 3) /* "--" "<head>" "<remote>" */
1368
die("Not handling anything other than two heads merge.");
1422
- if (verbosity >= 5) {
1369
+ if (verbosity >= 5)
1370
buffer_output = 0;
1424
- do_progress = 0;
1425
- }
1426
- else
1427
- do_progress = isatty(1);
1371
1372
branch1 = argv[++i];
1373
branch2 = argv[++i];
@@ -1435,8 +1378,6 @@ int main(int argc, char *argv[])
1378
branch1 = better_branch_name(branch1);
1379
branch2 = better_branch_name(branch2);
1380
1438
- if (do_progress)
1439
- setup_progress_signal();
1381
if (show(3))
1382
printf("Merging %s with %s\n", branch1, branch2);
1383