relax usage of the progress API
Since it is now OK to pass a null pointer to display_progress() and stop_progress() resulting in a no-op, then we can simplify the code and remove a bunch of lines by not making those calls conditional all the time. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
dc6a0757c4
commit
4d4fcc5451
@ -629,7 +629,6 @@ static void write_pack_file(void)
|
|||||||
if (!offset_one)
|
if (!offset_one)
|
||||||
break;
|
break;
|
||||||
offset = offset_one;
|
offset = offset_one;
|
||||||
if (do_progress)
|
|
||||||
display_progress(progress_state, written);
|
display_progress(progress_state, written);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -684,7 +683,6 @@ static void write_pack_file(void)
|
|||||||
} while (nr_remaining && i < nr_objects);
|
} while (nr_remaining && i < nr_objects);
|
||||||
|
|
||||||
free(written_list);
|
free(written_list);
|
||||||
if (do_progress)
|
|
||||||
stop_progress(&progress_state);
|
stop_progress(&progress_state);
|
||||||
if (written != nr_result)
|
if (written != nr_result)
|
||||||
die("wrote %u objects while expecting %u", written, nr_result);
|
die("wrote %u objects while expecting %u", written, nr_result);
|
||||||
@ -853,7 +851,6 @@ static int add_object_entry(const unsigned char *sha1, enum object_type type,
|
|||||||
else
|
else
|
||||||
object_ix[-1 - ix] = nr_objects;
|
object_ix[-1 - ix] = nr_objects;
|
||||||
|
|
||||||
if (progress)
|
|
||||||
display_progress(progress_state, nr_objects);
|
display_progress(progress_state, nr_objects);
|
||||||
|
|
||||||
if (name && no_try_delta(name))
|
if (name && no_try_delta(name))
|
||||||
@ -1517,7 +1514,6 @@ static void find_deltas(struct object_entry **list, unsigned list_size,
|
|||||||
|
|
||||||
progress_lock();
|
progress_lock();
|
||||||
(*processed)++;
|
(*processed)++;
|
||||||
if (progress)
|
|
||||||
display_progress(progress_state, *processed);
|
display_progress(progress_state, *processed);
|
||||||
progress_unlock();
|
progress_unlock();
|
||||||
|
|
||||||
@ -1722,7 +1718,6 @@ static void prepare_pack(int window, int depth)
|
|||||||
nr_deltas);
|
nr_deltas);
|
||||||
qsort(delta_list, n, sizeof(*delta_list), type_size_sort);
|
qsort(delta_list, n, sizeof(*delta_list), type_size_sort);
|
||||||
ll_find_deltas(delta_list, n, window+1, depth, &nr_done);
|
ll_find_deltas(delta_list, n, window+1, depth, &nr_done);
|
||||||
if (progress)
|
|
||||||
stop_progress(&progress_state);
|
stop_progress(&progress_state);
|
||||||
if (nr_done != nr_deltas)
|
if (nr_done != nr_deltas)
|
||||||
die("inconsistency with delta count");
|
die("inconsistency with delta count");
|
||||||
@ -2142,7 +2137,6 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
|
|||||||
rp_av[rp_ac] = NULL;
|
rp_av[rp_ac] = NULL;
|
||||||
get_object_list(rp_ac, rp_av);
|
get_object_list(rp_ac, rp_av);
|
||||||
}
|
}
|
||||||
if (progress)
|
|
||||||
stop_progress(&progress_state);
|
stop_progress(&progress_state);
|
||||||
|
|
||||||
if (non_empty && !nr_result)
|
if (non_empty && !nr_result)
|
||||||
|
@ -15,7 +15,6 @@ static void prune_dir(int i, DIR *dir, char *pathname, int len, int opts)
|
|||||||
struct dirent *de;
|
struct dirent *de;
|
||||||
char hex[40];
|
char hex[40];
|
||||||
|
|
||||||
if (opts == VERBOSE)
|
|
||||||
display_progress(progress, i + 1);
|
display_progress(progress, i + 1);
|
||||||
|
|
||||||
sprintf(hex, "%02x", i);
|
sprintf(hex, "%02x", i);
|
||||||
@ -64,7 +63,6 @@ void prune_packed_objects(int opts)
|
|||||||
prune_dir(i, d, pathname, len + 3, opts);
|
prune_dir(i, d, pathname, len + 3, opts);
|
||||||
closedir(d);
|
closedir(d);
|
||||||
}
|
}
|
||||||
if (opts == VERBOSE)
|
|
||||||
stop_progress(&progress);
|
stop_progress(&progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,10 +326,8 @@ static void unpack_all(void)
|
|||||||
obj_list = xmalloc(nr_objects * sizeof(*obj_list));
|
obj_list = xmalloc(nr_objects * sizeof(*obj_list));
|
||||||
for (i = 0; i < nr_objects; i++) {
|
for (i = 0; i < nr_objects; i++) {
|
||||||
unpack_one(i);
|
unpack_one(i);
|
||||||
if (!quiet)
|
|
||||||
display_progress(progress, i + 1);
|
display_progress(progress, i + 1);
|
||||||
}
|
}
|
||||||
if (!quiet)
|
|
||||||
stop_progress(&progress);
|
stop_progress(&progress);
|
||||||
|
|
||||||
if (delta_list)
|
if (delta_list)
|
||||||
|
@ -418,11 +418,9 @@ static void parse_pack_objects(unsigned char *sha1)
|
|||||||
} else
|
} else
|
||||||
sha1_object(data, obj->size, obj->type, obj->idx.sha1);
|
sha1_object(data, obj->size, obj->type, obj->idx.sha1);
|
||||||
free(data);
|
free(data);
|
||||||
if (verbose)
|
|
||||||
display_progress(progress, i+1);
|
display_progress(progress, i+1);
|
||||||
}
|
}
|
||||||
objects[i].idx.offset = consumed_bytes;
|
objects[i].idx.offset = consumed_bytes;
|
||||||
if (verbose)
|
|
||||||
stop_progress(&progress);
|
stop_progress(&progress);
|
||||||
|
|
||||||
/* Check pack integrity */
|
/* Check pack integrity */
|
||||||
@ -486,7 +484,6 @@ static void parse_pack_objects(unsigned char *sha1)
|
|||||||
obj->size, obj->type);
|
obj->size, obj->type);
|
||||||
}
|
}
|
||||||
free(data);
|
free(data);
|
||||||
if (verbose)
|
|
||||||
display_progress(progress, nr_resolved_deltas);
|
display_progress(progress, nr_resolved_deltas);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -594,7 +591,6 @@ static void fix_unresolved_deltas(int nr_unresolved)
|
|||||||
die("local object %s is corrupt", sha1_to_hex(d->base.sha1));
|
die("local object %s is corrupt", sha1_to_hex(d->base.sha1));
|
||||||
append_obj_to_pack(d->base.sha1, data, size, type);
|
append_obj_to_pack(d->base.sha1, data, size, type);
|
||||||
free(data);
|
free(data);
|
||||||
if (verbose)
|
|
||||||
display_progress(progress, nr_resolved_deltas);
|
display_progress(progress, nr_resolved_deltas);
|
||||||
}
|
}
|
||||||
free(sorted_by_pos);
|
free(sorted_by_pos);
|
||||||
@ -774,7 +770,6 @@ int main(int argc, char **argv)
|
|||||||
deltas = xmalloc(nr_objects * sizeof(struct delta_entry));
|
deltas = xmalloc(nr_objects * sizeof(struct delta_entry));
|
||||||
parse_pack_objects(sha1);
|
parse_pack_objects(sha1);
|
||||||
if (nr_deltas == nr_resolved_deltas) {
|
if (nr_deltas == nr_resolved_deltas) {
|
||||||
if (verbose)
|
|
||||||
stop_progress(&progress);
|
stop_progress(&progress);
|
||||||
/* Flush remaining pack final 20-byte SHA1. */
|
/* Flush remaining pack final 20-byte SHA1. */
|
||||||
flush();
|
flush();
|
||||||
@ -788,11 +783,10 @@ int main(int argc, char **argv)
|
|||||||
(nr_objects + nr_unresolved + 1)
|
(nr_objects + nr_unresolved + 1)
|
||||||
* sizeof(*objects));
|
* sizeof(*objects));
|
||||||
fix_unresolved_deltas(nr_unresolved);
|
fix_unresolved_deltas(nr_unresolved);
|
||||||
if (verbose) {
|
|
||||||
stop_progress(&progress);
|
stop_progress(&progress);
|
||||||
|
if (verbose)
|
||||||
fprintf(stderr, "%d objects were added to complete this thin pack.\n",
|
fprintf(stderr, "%d objects were added to complete this thin pack.\n",
|
||||||
nr_objects - nr_objects_initial);
|
nr_objects - nr_objects_initial);
|
||||||
}
|
|
||||||
fixup_pack_header_footer(output_fd, sha1,
|
fixup_pack_header_footer(output_fd, sha1,
|
||||||
curr_pack, nr_objects);
|
curr_pack, nr_objects);
|
||||||
}
|
}
|
||||||
|
@ -316,7 +316,6 @@ static void check_updates(struct cache_entry **src, int nr,
|
|||||||
while (nr--) {
|
while (nr--) {
|
||||||
struct cache_entry *ce = *src++;
|
struct cache_entry *ce = *src++;
|
||||||
|
|
||||||
if (total)
|
|
||||||
if (!ce->ce_mode || ce->ce_flags & mask)
|
if (!ce->ce_mode || ce->ce_flags & mask)
|
||||||
display_progress(progress, ++cnt);
|
display_progress(progress, ++cnt);
|
||||||
if (!ce->ce_mode) {
|
if (!ce->ce_mode) {
|
||||||
@ -332,7 +331,6 @@ static void check_updates(struct cache_entry **src, int nr,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (total)
|
|
||||||
stop_progress(&progress);
|
stop_progress(&progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user