Skip to content

Commit 9899372

Browse files
pcloudsgitster
authored andcommitted
rev-list: fix --verify-objects --quiet becoming --objects
When --quiet is specified, finish_object() is called instead of show_object(). The latter is in charge of --verify-objects and will be skipped if --quiet is specified. Move the code up to finish_object(). Also pass the quiet flag along and make it always call show_* functions to avoid similar problems in future. Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8ba8fe0 commit 9899372

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

bisect.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ extern void print_commit_list(struct commit_list *list,
1515
const char *format_cur,
1616
const char *format_last);
1717

18-
/* bisect_show_flags flags in struct rev_list_info */
1918
#define BISECT_SHOW_ALL (1<<0)
19+
#define REV_LIST_QUIET (1<<1)
2020

2121
struct rev_list_info {
2222
struct rev_info *revs;
23-
int bisect_show_flags;
23+
int flags;
2424
int show_timestamp;
2525
int hdr_termination;
2626
const char *header_prefix;

builtin/rev-list.c

+15-11
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ static void show_commit(struct commit *commit, void *data)
5252
struct rev_list_info *info = data;
5353
struct rev_info *revs = info->revs;
5454

55+
if (info->flags & REV_LIST_QUIET) {
56+
finish_commit(commit, data);
57+
return;
58+
}
59+
5560
graph_show_commit(revs->graph);
5661

5762
if (revs->count) {
@@ -172,19 +177,21 @@ static void finish_object(struct object *obj,
172177
const struct name_path *path, const char *name,
173178
void *cb_data)
174179
{
180+
struct rev_list_info *info = cb_data;
175181
if (obj->type == OBJ_BLOB && !has_sha1_file(obj->sha1))
176182
die("missing blob object '%s'", sha1_to_hex(obj->sha1));
183+
if (info->revs->verify_objects && !obj->parsed && obj->type != OBJ_COMMIT)
184+
parse_object(obj->sha1);
177185
}
178186

179187
static void show_object(struct object *obj,
180188
const struct name_path *path, const char *component,
181189
void *cb_data)
182190
{
183191
struct rev_list_info *info = cb_data;
184-
185192
finish_object(obj, path, component, cb_data);
186-
if (info->revs->verify_objects && !obj->parsed && obj->type != OBJ_COMMIT)
187-
parse_object(obj->sha1);
193+
if (info->flags & REV_LIST_QUIET)
194+
return;
188195
show_object_with_name(stdout, obj, path, component);
189196
}
190197

@@ -254,7 +261,7 @@ static void print_var_int(const char *var, int val)
254261

255262
static int show_bisect_vars(struct rev_list_info *info, int reaches, int all)
256263
{
257-
int cnt, flags = info->bisect_show_flags;
264+
int cnt, flags = info->flags;
258265
char hex[41] = "";
259266
struct commit_list *tried;
260267
struct rev_info *revs = info->revs;
@@ -305,7 +312,6 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
305312
int bisect_list = 0;
306313
int bisect_show_vars = 0;
307314
int bisect_find_all = 0;
308-
int quiet = 0;
309315

310316
git_config(git_default_config, NULL);
311317
init_revisions(&revs, prefix);
@@ -318,7 +324,8 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
318324
if (revs.bisect)
319325
bisect_list = 1;
320326

321-
quiet = DIFF_OPT_TST(&revs.diffopt, QUICK);
327+
if (DIFF_OPT_TST(&revs.diffopt, QUICK))
328+
info.flags |= REV_LIST_QUIET;
322329
for (i = 1 ; i < argc; i++) {
323330
const char *arg = argv[i];
324331

@@ -337,7 +344,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
337344
if (!strcmp(arg, "--bisect-all")) {
338345
bisect_list = 1;
339346
bisect_find_all = 1;
340-
info.bisect_show_flags = BISECT_SHOW_ALL;
347+
info.flags |= BISECT_SHOW_ALL;
341348
revs.show_decorations = 1;
342349
continue;
343350
}
@@ -388,10 +395,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
388395
return show_bisect_vars(&info, reaches, all);
389396
}
390397

391-
traverse_commit_list(&revs,
392-
quiet ? finish_commit : show_commit,
393-
quiet ? finish_object : show_object,
394-
&info);
398+
traverse_commit_list(&revs, show_commit, show_object, &info);
395399

396400
if (revs.count) {
397401
if (revs.left_right && revs.cherry_mark)

0 commit comments

Comments
 (0)