Skip to contentSkip to conversation

diff-no-index: rename read_directory()

PATCH In review Brian Bourn 3 participants 4 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/2 diff-no-index: rename read_directory()

It would be desirable to replace manual checking of "." or ".." in diff-no-index.c with is_dot_or_dotdot(), which is defined in dir.h, however, dir.h declares a read_directory() which conflicts with a (different) static read_directory() defined
in diff-no-index.c. As a preparatory step, rename the local read_directory() to avoid the collision.

---
Part 1 of my submission for GSoC

 diff-no-index.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff-no-index.c +3 -3
index 8e10bff..ec51106 100644
@@ -16,7 +16,7 @@
 #include "builtin.h"
 #include "string-list.h"
 
-static int read_directory(const char *path, struct string_list *list)
+static int read_directory_contents(const char *path, struct string_list *list)
 {
 	DIR *dir;
 	struct dirent *e;
@@ -107,9 +107,9 @@ static int queue_diff(struct diff_options *o,
 		int i1, i2, ret = 0;
 		size_t len1 = 0, len2 = 0;
 
-		if (name1 && read_directory(name1, &p1))
+		if (name1 && read_directory_contents(name1, &p1))
 			return -1;
-		if (name2 && read_directory(name2, &p2)) {
+		if (name2 && read_directory_contents(name2, &p2)) {
 			string_list_clear(&p1, 0);
 			return -1;
 		}
Signature · 1 line
1.9.0
#1 lore raw

PATCH v3 2/2 diff-no-index: replace manual "."/".." check with is_dot_or_dotdot()

---
Part 2 of my submission for GSoC

 diff-no-index.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff-no-index.c +2 -1
index ec51106..c554691 100644
@@ -15,6 +15,7 @@
 #include "log-tree.h"
 #include "builtin.h"
 #include "string-list.h"
+#include "dir.h"
 
 static int read_directory_contents(const char *path, struct string_list *list)
 {
@@ -25,7 +26,7 @@ static int read_directory_contents(const char *path, struct string_list *list)
 		return error("Could not open directory %s", path);
 
 	while ((e = readdir(dir)))
-		if (strcmp(".", e->d_name) && strcmp("..", e->d_name))
+		if (!is_dot_or_dotdot(e->d_name))
 			string_list_insert(list, e->d_name);
 
 	closedir(dir);
Signature · 1 line
1.9.0
#2 lore raw
In reply to Brian Bourn
Quoted 7 lines · Brian Bourn

It would be desirable to replace manual checking of "." or ".." in diff-no-index.c with is_dot_or_dotdot(), which is defined in dir.h, however, dir.h declares a read_directory() which conflicts with a (different) static read_directory() defined
in diff-no-index.c. As a preparatory step, rename the local read_directory() to avoid the collision.

Quoted 5 lines

---
Part 1 of my submission for GSoC

 diff-no-index.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Looks good to me. Doesn't Eric deserve a "Helped-by:" above?

Thanks.

Quoted 25 lines
diff-no-index.c +3 -3
index 8e10bff..ec51106 100644
@@ -16,7 +16,7 @@
 #include "builtin.h"
 #include "string-list.h"
 
-static int read_directory(const char *path, struct string_list *list)
+static int read_directory_contents(const char *path, struct string_list *list)
 {
 	DIR *dir;
 	struct dirent *e;
@@ -107,9 +107,9 @@ static int queue_diff(struct diff_options *o,
 		int i1, i2, ret = 0;
 		size_t len1 = 0, len2 = 0;
 
-		if (name1 && read_directory(name1, &p1))
+		if (name1 && read_directory_contents(name1, &p1))
 			return -1;
-		if (name2 && read_directory(name2, &p2)) {
+		if (name2 && read_directory_contents(name2, &p2)) {
 			string_list_clear(&p1, 0);
 			return -1;
 		}
#3 lore raw
Quoted 9 lines · Junio C Hamano
Quoted 7 lines · Brian Bourn

It would be desirable to replace manual checking of "." or ".." in diff-no-index.c with is_dot_or_dotdot(), which is defined in dir.h, however, dir.h declares a read_directory() which conflicts with a (different) static read_directory() defined
in diff-no-index.c. As a preparatory step, rename the local read_directory() to avoid the collision.

Quoted 7 lines
Quoted 5 lines

---
Part 1 of my submission for GSoC

 diff-no-index.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Looks good to me. Doesn't Eric deserve a "Helped-by:" above?

Both patches look good to me too.

One final comment for future submissions (no need to resend this one):
As a courtesy to reviewers, below the "---" line after your sign-off, provide a link to the previous attempt (like this [1]) and explain what changed since the since the last version.

[1]: http://thread.gmane.org/gmane.comp.version-control.git/244412

Quoted 25 lines
Quoted 25 lines
diff-no-index.c +3 -3
index 8e10bff..ec51106 100644
@@ -16,7 +16,7 @@
 #include "builtin.h"
 #include "string-list.h"
 
-static int read_directory(const char *path, struct string_list *list)
+static int read_directory_contents(const char *path, struct string_list *list)
 {
      DIR *dir;
      struct dirent *e;
@@ -107,9 +107,9 @@ static int queue_diff(struct diff_options *o,
              int i1, i2, ret = 0;
              size_t len1 = 0, len2 = 0;
 
-             if (name1 && read_directory(name1, &p1))
+             if (name1 && read_directory_contents(name1, &p1))
                      return -1;
-             if (name2 && read_directory(name2, &p2)) {
+             if (name2 && read_directory_contents(name2, &p2)) {
                      string_list_clear(&p1, 0);
                      return -1;
              }