Commit eef9542c44a360aeec73151d75342f0559a590b4

Stefan Sperling 2020-10-22T20:37:50

preserve what was passed in if got_repo_map_path() can't figure out a path problem found by + ok naddy

diff --git a/lib/repository.c b/lib/repository.c
index 3c8f844..6d8ef4d 100644
--- a/lib/repository.c
+++ b/lib/repository.c
@@ -824,8 +824,11 @@ got_repo_map_path(char **in_repo_path, struct got_repository *repo,
 			if (got_repo_is_bare(repo)) {
 				/*
 				 * Matched an on-disk path inside repository
-				 * database. Treat as repository-relative.
+				 * database. Treat input as repository-relative.
 				 */
+				 free(path);
+				 path = canonpath;
+				 canonpath = NULL;
 			} else {
 				char *child;
 				/* Strip common prefix with repository path. */
@@ -839,8 +842,11 @@ got_repo_map_path(char **in_repo_path, struct got_repository *repo,
 		} else {
 			/*
 			 * Matched unrelated on-disk path.
-			 * Treat it as repository-relative.
+			 * Treat input as repository-relative.
 			 */
+			 free(path);
+			 path = canonpath;
+			 canonpath = NULL;
 		}
 	}