Skip to content

Commit 9f72d5b

Browse files
committed
Git fetcher: Don't pass URL query parameters for file:// URLs
Git interprets them as part of the file name, so passing parameters like 'rev' breaks. Only relevant for testing (when _NIX_FORCE_HTTP is set) and local bare repos.
1 parent cfe9329 commit 9f72d5b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/libfetchers/git.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,14 @@ struct GitInputScheme : InputScheme
459459
url);
460460
}
461461
repoInfo.location = std::filesystem::absolute(url.path);
462-
} else
462+
} else {
463+
if (url.scheme == "file")
464+
/* Query parameters are meaningless for file://, but
465+
Git interprets them as part of the file name. So get
466+
rid of them. */
467+
url.query.clear();
463468
repoInfo.location = url;
469+
}
464470

465471
// If this is a local directory and no ref or revision is
466472
// given, then allow the use of an unclean working tree.

0 commit comments

Comments
 (0)