Skip to content

Commit 5b1e14e

Browse files
mhaggergitster
authored andcommitted
cmd_diff(): make it obvious which cases are exclusive of each other
At first glance the OBJ_COMMIT, OBJ_TREE, and OBJ_BLOB cases look like they might be mutually exclusive. But the OBJ_COMMIT case doesn't end the loop iteration with "continue" like the other two cases, but rather falls through. So use if...else if...else construct to make it more obvious that only the last two cases are mutually exclusive. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 026f09e commit 5b1e14e

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

builtin/diff.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -350,22 +350,21 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
350350
die(_("invalid object '%s' given."), name);
351351
if (obj->type == OBJ_COMMIT)
352352
obj = &((struct commit *)obj)->tree->object;
353+
353354
if (obj->type == OBJ_TREE) {
354355
obj->flags |= flags;
355356
add_object_array(obj, name, &ent);
356-
continue;
357-
}
358-
if (obj->type == OBJ_BLOB) {
357+
} else if (obj->type == OBJ_BLOB) {
359358
if (2 <= blobs)
360359
die(_("more than two blobs given: '%s'"), name);
361360
hashcpy(blob[blobs].sha1, obj->sha1);
362361
blob[blobs].name = name;
363362
blob[blobs].mode = entry->mode;
364363
blobs++;
365-
continue;
366364

365+
} else {
366+
die(_("unhandled object '%s' given."), name);
367367
}
368-
die(_("unhandled object '%s' given."), name);
369368
}
370369
if (rev.prune_data.nr) {
371370
if (!path)

0 commit comments

Comments
 (0)