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>

Michael Haggerty committed May 25, 2013 at 11:08 UTC 5b1e14eab3109c1d33e27b00ee18f8f9f60e779c
1 file changed +4 -5
builtin/diff.c
+4 -5
@@ -350,22 +350,21 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
350 die(_("invalid object '%s' given."), name);
351 if (obj->type == OBJ_COMMIT)
352 obj = &((struct commit *)obj)->tree->object;
353 +
354 if (obj->type == OBJ_TREE) {
355 obj->flags |= flags;
356 add_object_array(obj, name, &ent);
356 - continue;
357 - }
358 - if (obj->type == OBJ_BLOB) {
357 + } else if (obj->type == OBJ_BLOB) {
358 if (2 <= blobs)
359 die(_("more than two blobs given: '%s'"), name);
360 hashcpy(blob[blobs].sha1, obj->sha1);
361 blob[blobs].name = name;
362 blob[blobs].mode = entry->mode;
363 blobs++;
365 - continue;
364
365 + } else {
366 + die(_("unhandled object '%s' given."), name);
367 }
368 - die(_("unhandled object '%s' given."), name);
368 }
369 if (rev.prune_data.nr) {
370 if (!path)