Including "dir.h" in "diff-no-index.c", it causes a compile error, because
the same name function read_directory() is declared globally in "dir.h".
This change is to avoid conflicts as above.
Signed-off-by: Hiroyuki Sano <redacted>
---
diff-no-index.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
The is_dot_or_dotdot() is used to check if the string is either "." or "..".
Include the "dir.h" header file to use is_dot_or_dotdot().
Signed-off-by: Hiroyuki Sano <redacted>
---
diff-no-index.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
There were two different ways to check flag values,
one way is using if-statement, and the other way is
using logical expression.
To make sensible, replace if-statements to logical expressions
in fsck_tree().
When checking "has_dot" and "has_dotdot", use is_dot_or_dotdot()
instead of strcmp() to avoid hard coding.
The is_dot_or_dotdot() is used to check if the string is
either "." or "..".
Include the "dir.h" header file to use is_dot_or_dotdot().
Signed-off-by: Hiroyuki Sano <redacted>
---
fsck.c | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
@@ -165,18 +166,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|=is_dot_or_dotdot(name)&&!name[1];+has_dotdot|=is_dot_or_dotdot(name)&&name[1];+has_dotgit|=!strcmp(name,".git");has_zero_pad|=*(char*)desc.buffer=='0';update_tree_entry(&desc);
From: Eric Sunshine <hidden> Date: 2016-06-15 23:00:23
On Wed, Mar 19, 2014 at 7:23 AM, Hiroyuki Sano [off-list ref] wrote:
Subject: diff: rename read_directory() to get_path_list()
You probably mean 'diff-no-index' here rather than 'diff'.
Including "dir.h" in "diff-no-index.c", it causes a compile error, because
the same name function read_directory() is declared globally in "dir.h".
It might be a bit clearer to give a hint as to why dir.h will be a problem:
A subsequent patch will include dir.h in diff-no-index.c,
however, dir.h declares a read_directory() which is different
from the one defined statically by diff-no-index.c.
This change is to avoid conflicts as above.
Good explanation, but write in imperative mood:
Rename the local read_directory() to avoid the conflict.
From: Eric Sunshine <hidden> Date: 2016-06-15 23:00:23
On Wed, Mar 19, 2014 at 7:23 AM, Hiroyuki Sano [off-list ref] wrote:
Subject: diff: use is_dot_or_dotdot() instead of strcmp()
You probably meant 'diff-no-index' rather than 'diff'.
You could make the subject a bit more explanatory by saying:
use is_dot_or_dotdot() instead of a manual "."/".." check
The is_dot_or_dotdot() is used to check if the string is either "." or "..".
It's pretty obvious what this function does, so it's not necessary to
explain it.
Include the "dir.h" header file to use is_dot_or_dotdot().
Including dir.h is a obvious requirement of using is_dot_or_dotdot(),
thus also does not require explanation.
Otherwise, the patch looks fine.