Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions doc/manual/expressions/builtins.xml
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,13 @@ stdenv.mkDerivation { … }
This is often a branch or tag name. Defaults to
<literal>HEAD</literal>.
</para>

<para>
By default, the <varname>ref</varname> value is prefixed
with <literal>refs/heads/</literal>. As of Nix 2.3.0
Nix will not prefix <literal>refs/heads/</literal> if
<varname>ref</varname> starts with <literal>refs/</literal>.
</para>
</listitem>
</varlistentry>
</variablelist>
Expand All @@ -432,6 +439,14 @@ stdenv.mkDerivation { … }
}</programlisting>
</example>

<example>
<title>Fetching an arbitrary ref</title>
<programlisting>builtins.fetchGit {
url = "https://gitub.com/NixOS/nix.git";
ref = "refs/heads/0.5-release";
}</programlisting>
</example>

<example>
<title>Fetching a repository's specific commit on an arbitrary branch</title>
<para>
Expand Down
1 change: 1 addition & 0 deletions doc/manual/release-notes/release-notes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
</partintro>
-->

<xi:include href="rl-2.3.xml" />
<xi:include href="rl-2.2.xml" />
<xi:include href="rl-2.1.xml" />
<xi:include href="rl-2.0.xml" />
Expand Down
22 changes: 22 additions & 0 deletions doc/manual/release-notes/rl-2.3.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<section xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude"
version="5.0"
xml:id="ssec-relnotes-2.3">

<title>Release 2.3 (????-??-??)</title>

<para>This release contains the following changes:</para>

<itemizedlist>

<listitem>
<para><function>builtins.fetchGit</function>'s <varname>ref</varname>
argument now allows specifying an absolute remote ref.
Nix will automatically prefix <varname>ref</varname> with
<literal>refs/heads</literal> only if <varname>ref</varname> doesn't
already begin with <literal>refs/</literal>.
</para>
</listitem>
</itemizedlist>
</section>
6 changes: 5 additions & 1 deletion src/libexpr/primops/fetchGit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ GitInfo exportGit(ref<Store> store, const std::string & uri,
runProgram("git", true, { "init", "--bare", cacheDir });
}

Path localRefFile = cacheDir + "/refs/heads/" + *ref;
Path localRefFile;
if (ref->compare(0, 5, "refs/") == 0)
localRefFile = cacheDir + "/" + *ref;
else
localRefFile = cacheDir + "/refs/heads/" + *ref;

bool doFetch;
time_t now = time(0);
Expand Down