Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

read_directory_recursive: reduce one indentation level

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information...
commit 02cb67530e62e77d437cd68b4bb4307ab752b6a0 1 parent 5fb8c05
Nguyễn Thái Ngọc Duy authored gitster committed

Showing 1 changed file with 25 additions and 25 deletions. Show diff stats Hide diff stats

  1. 50  dir.c
50  dir.c
@@ -968,34 +968,34 @@ static int read_directory_recursive(struct dir_struct *dir,
968 968
 {
969 969
 	DIR *fdir = opendir(*base ? base : ".");
970 970
 	int contents = 0;
  971
+	struct dirent *de;
  972
+	char path[PATH_MAX + 1];
971 973
 
972  
-	if (fdir) {
973  
-		struct dirent *de;
974  
-		char path[PATH_MAX + 1];
975  
-		memcpy(path, base, baselen);
976  
-
977  
-		while ((de = readdir(fdir)) != NULL) {
978  
-			int len;
979  
-			switch (treat_path(dir, de, path, sizeof(path),
980  
-					   baselen, simplify, &len)) {
981  
-			case path_recurse:
982  
-				contents += read_directory_recursive
983  
-					(dir, path, len, 0, simplify);
984  
-				continue;
985  
-			case path_ignored:
986  
-				continue;
987  
-			case path_handled:
988  
-				break;
989  
-			}
990  
-			contents++;
991  
-			if (check_only)
992  
-				goto exit_early;
993  
-			else
994  
-				dir_add_name(dir, path, len);
  974
+	if (!fdir)
  975
+		return 0;
  976
+
  977
+	memcpy(path, base, baselen);
  978
+
  979
+	while ((de = readdir(fdir)) != NULL) {
  980
+		int len;
  981
+		switch (treat_path(dir, de, path, sizeof(path),
  982
+				   baselen, simplify, &len)) {
  983
+		case path_recurse:
  984
+			contents += read_directory_recursive(dir, path, len, 0, simplify);
  985
+			continue;
  986
+		case path_ignored:
  987
+			continue;
  988
+		case path_handled:
  989
+			break;
995 990
 		}
996  
-exit_early:
997  
-		closedir(fdir);
  991
+		contents++;
  992
+		if (check_only)
  993
+			goto exit_early;
  994
+		else
  995
+			dir_add_name(dir, path, len);
998 996
 	}
  997
+exit_early:
  998
+	closedir(fdir);
999 999
 
1000 1000
 	return contents;
1001 1001
 }

0 notes on commit 02cb675

Please sign in to comment.
Something went wrong with that request. Please try again.