git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/3] daemon: cleanup: replace loop with if

From
René Scharfe <rene.scharfe@lsrfire.ath.cx>
Date
Dec 26, 2008, 10:01 UTC
Message-ID
<1230285717.6728.40.camel@ubuntu.ubuntu-domain>
In-Reply-To
<1230284785.6728.26.camel@ubuntu.ubuntu-domain>

Replace a loop around an enter_repo() call, which was used to retry a single time with a different parameter in case the first call fails, with two calls and an if. This is shorter and cleaner.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
---
 daemon.c |   18 +++++-------------
 1 files changed, 5 insertions(+), 13 deletions(-)
diff --git a/daemon.c b/daemon.c
index 8c317be..4468fb9 100644
--- a/daemon.c
+++ b/daemon.c
@@ -150,7 +150,6 @@ static char *path_ok(char *directory)
 {
 	static char rpath[PATH_MAX];
 	static char interp_path[PATH_MAX];
-	int retried_path = 0;
 	char *path;
 	char *dir;
 
@@ -219,22 +218,15 @@ static char *path_ok(char *directory)
 		dir = rpath;
 	}
 
-	do {
-		path = enter_repo(dir, strict_paths);
-		if (path)
-			break;
-
+	path = enter_repo(dir, strict_paths);
+	if (!path && base_path && base_path_relaxed) {
 		/*
 		 * if we fail and base_path_relaxed is enabled, try without
 		 * prefixing the base path
 		 */
-		if (base_path && base_path_relaxed && !retried_path) {
-			dir = directory;
-			retried_path = 1;
-			continue;
-		}
-		break;
-	} while (1);
+		dir = directory;
+		path = enter_repo(dir, strict_paths);
+	}
 
 	if (!path) {
 		logerror("'%s': unable to chdir or not a git archive", dir);
-- 
1.6.1
Previous: René ScharfeNext: René Scharfe
Message 2 of 4 in “daemon: handle freopen() failure”
  1. 1/3 daemon: handle freopen() failureRené Scharfe, Dec 26, 2008
  2. 2/3 daemon: cleanup: replace loop with ifRené Scharfe, Dec 26, 2008
  3. 3/3 daemon: cleanup: factor out xstrdup_tolower()René Scharfe, Dec 26, 2008
  4. merge-file: handle freopen() failureRené Scharfe, Dec 26, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.