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 <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
Feb 28, 2012 at 21:00 UTC
989937221a95cd6c3a829da043162e18e0371b1e
2 files changed
+17
-13
bisect.h
+2
-2
@@ -15,12 +15,12 @@ extern void print_commit_list(struct commit_list *list,
15
const char *format_cur,
16
const char *format_last);
17
18
-/* bisect_show_flags flags in struct rev_list_info */
18
#define BISECT_SHOW_ALL (1<<0)
19
+#define REV_LIST_QUIET (1<<1)
20
21
struct rev_list_info {
22
struct rev_info *revs;
23
- int bisect_show_flags;
23
+ int flags;
24
int show_timestamp;
25
int hdr_termination;
26
const char *header_prefix;
builtin/rev-list.c
+15
-11
@@ -52,6 +52,11 @@ static void show_commit(struct commit *commit, void *data)
52
struct rev_list_info *info = data;
53
struct rev_info *revs = info->revs;
54
55
+ if (info->flags & REV_LIST_QUIET) {
56
+ finish_commit(commit, data);
57
+ return;
58
+ }
59
+
60
graph_show_commit(revs->graph);
61
62
if (revs->count) {
@@ -172,8 +177,11 @@ static void finish_object(struct object *obj,
177
const struct name_path *path, const char *name,
178
void *cb_data)
179
{
180
+ struct rev_list_info *info = cb_data;
181
if (obj->type == OBJ_BLOB && !has_sha1_file(obj->sha1))
182
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);
185
}
186
187
static void show_object(struct object *obj,
@@ -181,10 +189,9 @@ static void show_object(struct object *obj,
189
void *cb_data)
190
{
191
struct rev_list_info *info = cb_data;
184
-
192
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;
195
show_object_with_name(stdout, obj, path, component);
196
}
197
@@ -254,7 +261,7 @@ static void print_var_int(const char *var, int val)
261
262
static int show_bisect_vars(struct rev_list_info *info, int reaches, int all)
263
{
257
- int cnt, flags = info->bisect_show_flags;
264
+ int cnt, flags = info->flags;
265
char hex[41] = "";
266
struct commit_list *tried;
267
struct rev_info *revs = info->revs;
@@ -305,7 +312,6 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
312
int bisect_list = 0;
313
int bisect_show_vars = 0;
314
int bisect_find_all = 0;
308
- int quiet = 0;
315
316
git_config(git_default_config, NULL);
317
init_revisions(&revs, prefix);
@@ -318,7 +324,8 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
324
if (revs.bisect)
325
bisect_list = 1;
326
321
- quiet = DIFF_OPT_TST(&revs.diffopt, QUICK);
327
+ if (DIFF_OPT_TST(&revs.diffopt, QUICK))
328
+ info.flags |= REV_LIST_QUIET;
329
for (i = 1 ; i < argc; i++) {
330
const char *arg = argv[i];
331
@@ -337,7 +344,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
344
if (!strcmp(arg, "--bisect-all")) {
345
bisect_list = 1;
346
bisect_find_all = 1;
340
- info.bisect_show_flags = BISECT_SHOW_ALL;
347
+ info.flags |= BISECT_SHOW_ALL;
348
revs.show_decorations = 1;
349
continue;
350
}
@@ -388,10 +395,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
395
return show_bisect_vars(&info, reaches, all);
396
}
397
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);
399
400
if (revs.count) {
401
if (revs.left_right && revs.cherry_mark)