summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2013-05-25 09:08:06 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-05-28 16:25:01 (GMT)
commit5b1e14eab3109c1d33e27b00ee18f8f9f60e779c (patch)
tree1163f874d9d52c02fe00840804035f465572252b /builtin
parent026f09e79689f99f573b8399443e8c4ffa84a794 (diff)
downloadgit-5b1e14eab3109c1d33e27b00ee18f8f9f60e779c.zip
git-5b1e14eab3109c1d33e27b00ee18f8f9f60e779c.tar.gz
git-5b1e14eab3109c1d33e27b00ee18f8f9f60e779c.tar.bz2
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>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/diff.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/builtin/diff.c b/builtin/diff.c
index 84243d9..9fc273d 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -350,22 +350,21 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
die(_("invalid object '%s' given."), name);
if (obj->type == OBJ_COMMIT)
obj = &((struct commit *)obj)->tree->object;
+
if (obj->type == OBJ_TREE) {
obj->flags |= flags;
add_object_array(obj, name, &ent);
- continue;
- }
- if (obj->type == OBJ_BLOB) {
+ } else if (obj->type == OBJ_BLOB) {
if (2 <= blobs)
die(_("more than two blobs given: '%s'"), name);
hashcpy(blob[blobs].sha1, obj->sha1);
blob[blobs].name = name;
blob[blobs].mode = entry->mode;
blobs++;
- continue;
+ } else {
+ die(_("unhandled object '%s' given."), name);
}
- die(_("unhandled object '%s' given."), name);
}
if (rev.prune_data.nr) {
if (!path)