summaryrefslogtreecommitdiff
path: root/fsck.c
diff options
context:
space:
mode:
authorHiroyuki Sano <sh19910711@gmail.com>2014-03-19 23:02:04 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-03-20 18:20:48 (GMT)
commiteffd12ec876df016d4346fee0d3d6bf31308fa11 (patch)
tree5e09d92ad35c76c32359462a6767b717d5145746 /fsck.c
parent7bbc4e8fdb33e0a8e42e77cc05460d4c4f615f4d (diff)
downloadgit-effd12ec876df016d4346fee0d3d6bf31308fa11.zip
git-effd12ec876df016d4346fee0d3d6bf31308fa11.tar.gz
git-effd12ec876df016d4346fee0d3d6bf31308fa11.tar.bz2
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>
Diffstat (limited to 'fsck.c')
-rw-r--r--fsck.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/fsck.c b/fsck.c
index 99c0497..31ce993 100644
--- a/fsck.c
+++ b/fsck.c
@@ -165,18 +165,12 @@ static int fsck_tree(struct tree *item, int strict, fsck_error error_func)
sha1 = tree_entry_extract(&desc, &name, &mode);
- if (is_null_sha1(sha1))
- has_null_sha1 = 1;
- if (strchr(name, '/'))
- has_full_path = 1;
- if (!*name)
- has_empty_name = 1;
- if (!strcmp(name, "."))
- has_dot = 1;
- if (!strcmp(name, ".."))
- has_dotdot = 1;
- if (!strcmp(name, ".git"))
- has_dotgit = 1;
+ has_null_sha1 |= is_null_sha1(sha1);
+ has_full_path |= !!strchr(name, '/');
+ has_empty_name |= !*name;
+ has_dot |= !strcmp(name, ".");
+ has_dotdot |= !strcmp(name, "..");
+ has_dotgit |= !strcmp(name, ".git");
has_zero_pad |= *(char *)desc.buffer == '0';
update_tree_entry(&desc);