fsck: use bitwise-or assignment operator to set flag
fsck_tree() has two different ways to set a flag variable, either by using a if-statement that guards an assignment, or by using a bitwise-or assignment operator. Most are done with the former, and only one variable is assigned with the latter. Since all the conditions are short-and-sweet, we can afford to uniformly use the latter style, which makes the resulting code shorter and easier to read. Signed-off-by: Hiroyuki Sano <sh19910711@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Hiroyuki Sano committed
Mar 20, 2014 at 08:02 UTC
effd12ec876df016d4346fee0d3d6bf31308fa11
1 file changed
+6
-12
fsck.c
+6
-12
@@ -165,18 +165,12 @@ static int fsck_tree(struct tree *item, int strict, fsck_error error_func)
165
166
sha1 = tree_entry_extract(&desc, &name, &mode);
167
168
- if (is_null_sha1(sha1))
169
- has_null_sha1 = 1;
170
- if (strchr(name, '/'))
171
- has_full_path = 1;
172
- if (!*name)
173
- has_empty_name = 1;
174
- if (!strcmp(name, "."))
175
- has_dot = 1;
176
- if (!strcmp(name, ".."))
177
- has_dotdot = 1;
178
- if (!strcmp(name, ".git"))
179
- has_dotgit = 1;
168
+ has_null_sha1 |= is_null_sha1(sha1);
169
+ has_full_path |= !!strchr(name, '/');
170
+ has_empty_name |= !*name;
171
+ has_dot |= !strcmp(name, ".");
172
+ has_dotdot |= !strcmp(name, "..");
173
+ has_dotgit |= !strcmp(name, ".git");
174
has_zero_pad |= *(char *)desc.buffer == '0';
175
update_tree_entry(&desc);
176