aboutsummaryrefslogtreecommitdiff
path: root/src/libfetchers/git.cc
AgeCommit message (Collapse)Author
2022-04-12assert hash types for Git and MercurialKasper Gałkowski
2022-04-09libfetchers: Replace regex to clarify intentDaniel Pauls
2022-04-06libfetchers: Fix assertionDaniel Pauls
The filter expects all paths to have a prefix of the raw `actualUrl`, but `Store::addToStore(...)` provides absolute canonicalized paths. To fix this create an absolute and canonicalized path from the `actualUrl` and use it instead. Fixes #6195.
2022-03-11StyleEelco Dolstra
2022-03-11Merge pull request #5758 from mschwaig/fix-git-workspace-dirty-detectionThéophane Hufschmitt
git fetcher: fix detection of dirty git workspaces
2022-03-01Move some stuff from `Settings` to a new `FetchSettings`.John Ericson
Starting work on #5638 The exact boundary between `FetchSettings` and `EvalSettings` is not clear to me, but that's fine. First lets clean out `libstore`, and then worry about what, if anything, should be the separation between those two.
2022-02-24libfetchers: Rename immutable -> lockedEelco Dolstra
This is more consistent with flake terminology.
2022-02-19git fetcher: set locale for rev-parseMartin Schwaighofer
2022-02-19git fetcher: distinguish errors more preciselyMartin Schwaighofer
2022-02-19git fetcher: invoke diff instead of diff-indexMartin Schwaighofer
diff-index operates on the view that git has of the working tree, which might be outdated. The higher-level diff command does this automatically. This change also adds handling for submodules. fixes #4140 Alternative fixes would be invoking update-index before diff-index or matching more closely what require_clean_work_tree from git-sh-setup.sh does, but both those options make it more difficult to reason about correctness.
2022-02-19git fetcher: improve check for valid repositoryMartin Schwaighofer
The .git/refs/heads directory might be empty for a valid usable git repository. This often happens in CI environments, which might only fetch commits, not branches. Therefore instead we let git itself check if HEAD points to something that looks like a commit. fixes #5302
2022-02-16InputScheme::fetch(): Return a StorePath instead of a TreeEelco Dolstra
2021-11-16Merge pull request #5452 from Kha/git-extend-lockEelco Dolstra
git: extend cache dir lock over all mutating operations
2021-11-01git: extend cache dir lock over all mutating operationsSebastian Ullrich
2021-10-26Support building flakes from a Git repo url with submodules query parameterTimothy
2021-09-24Explicitly set initial branch name for gitoxalica
2021-09-22Revert "Merge pull request #4922 from nrdxp/default-submodules"Eelco Dolstra
This reverts commit 6678e98411cd3bfe8143a4ba1b35d1451babce32, reversing changes made to 90b2dd570cbd8313a8cf45b3cf66ddef2bb06e07.
2021-09-14Fix macOS buildEelco Dolstra
2021-09-13RunOptions: Use designated initializersEelco Dolstra
Also get rid of _killStderr because it wasn't actually checked anywhere.
2021-09-07Merge pull request #4922 from nrdxp/default-submodulesShea Levy
libfetchers/git: fetch submodules by default
2021-08-02fix git init race conditionMichael Fellinger
2021-07-06Allow `fetchGit` to take a `name` argumentregnat
Fix #3388
2021-06-17libfetchers/git: fetch submodules by defaultTimothy DeHerrera
2021-04-19Include sys/wait.h everywhere WIFEXITED etc is usedAlyssa Ross
This is required on NetBSD, and I think FreeBSD too.
2021-03-30fetchGit: don't prefix "refs/heads/" on ref = "HEAD"Bjørn Forsman
This fixes builtins.fetchGit { url = ...; ref = "HEAD"; }, that works in stable nix (v2.3.10), but is broken in nix master: $ ./result/bin/nix repl Welcome to Nix version 2.4pre19700101_dd77f71. Type :? for help. nix-repl> builtins.fetchGit { url = "https://github.com/NixOS/nix"; ref = "HEAD"; } fetching Git repository 'https://github.com/NixOS/nix'fatal: couldn't find remote ref refs/heads/HEAD error: program 'git' failed with exit code 128 The documentation for builtins.fetchGit says ref = "HEAD" is the default, so it should also be supported to explicitly pass it. I came across this issue because poetry2nix can use ref = "HEAD" in some situations. Fixes #4674.
2021-03-01Add support for bare git repositories with git+fileKjetil Orbekk
Local git repositories are normally used directly instead of cloning. This commit checks if a repo is bare and forces a clone. Co-authored-by: Théophane Hufschmitt <regnat@users.noreply.github.com>
2020-12-22Add explicit `allRefs = true;` argument to `fetchGit`Maximilian Bosch
Sometimes it's necessary to fetch a git repository at a revision and it's unknown which ref contains the revision in question. An example would be a Cargo.lock which only provides the URL and the revision when using a git repository as build input. However it's considered a bad practice to perform a full checkout of a repository since this may take a lot of time and can eat up a lot of disk space. This patch makes a full checkout explicit by adding an `allRefs` argument to `builtins.fetchGit` which fetches all refs if explicitly set to true. Closes #2409
2020-12-22Provide a more meaningful error-message for `builtins.fetchGit` if a ↵Maximilian Bosch
revision can't be checked out A common pitfall when using e.g. `builtins.fetchGit` is the `fatal: not a tree object`-error when trying to fetch a revision of a git-repository that isn't on the `master` branch and no `ref` is specified. In order to make clear what's the problem, I added a simple check whether the revision in question exists and if it doesn't a more meaningful error-message is displayed: ``` nix-repl> builtins.fetchGit { url = "https://github.com/owner/myrepo"; rev = "<commit not on master>"; } moderror: --- Error -------------------------------------------------------------------- nix Cannot find Git revision 'bf1cc5c648e6aed7360448a3745bb2fe4fbbf0e9' in ref 'master' of repository 'https://gitlab.com/Ma27/nvim.nix'! Please make sure that the rev exists on the ref you've specified or add allRefs = true; to fetchGit. ``` Closes #2431
2020-11-10Fix use of dirty Git/Mercurial inputs with chroot storesEelco Dolstra
Fixes: $ nix build --store /tmp/nix /home/eelco/Dev/patchelf#hydraJobs.build.x86_64-linux warning: Git tree '/home/eelco/Dev/patchelf' is dirty error: --- RestrictedPathError ------------------------------------------------------------------------------------------- nix access to path '/tmp/nix/nix/store/xmkvfmffk7xfnazykb5kx999aika8an4-source/flake.nix' is forbidden in restricted mode (use '--show-trace' to show detailed location information)
2020-10-06Remove static variable name clashesEelco Dolstra
This was useful for an experiment with building Nix as a single compilation unit. It's not very useful otherwise but also doesn't hurt...
2020-09-21Don't include <regex> in header filesEelco Dolstra
This reduces compilation time by ~15 seconds (CPU time). Issue #4045.
2020-08-13Don't try to parse signature check as commit timestampChuck
When the log.showSignature git setting is enabled, the output of "git log" contains signature verification information in addition to the timestamp GitInputScheme::fetch wants: $ git log -1 --format=%ct gpg: Signature made Sat 07 Sep 2019 02:02:03 PM PDT gpg: using RSA key 0123456789ABCDEF0123456789ABCDEF01234567 gpg: issuer "user@example.com" gpg: Good signature from "User <user@example.com>" [ultimate] 1567890123 1567890123 For folks that had log.showSignature set, this caused all nix operations on flakes to fail: $ nix build error: stoull
2020-08-05Merge remote-tracking branch 'upstream/master' into misc-caJohn Ericson
2020-07-20Add UnimplementedError to ease grepping for theseCarlo Nucera
2020-07-16Merge branch 'hash-always-has-type' of github.com:obsidiansystems/nix into ↵John Ericson
better-ca-parse-errors
2020-07-01Rename two hash constructors to proper functionsCarlo Nucera
2020-07-01Support building flakes from a shallow Git repoEelco Dolstra
Fixes #3756.
2020-06-03Merge remote-tracking branch 'origin/master' into flakesEelco Dolstra
2020-06-01use Tree ctorMatthew Kenigsberg
2020-05-30Ensure we restrict refspec interpretation while fetchingNikola Knezevic
As `git fetch` may chose to interpret refspec to it's liking, ensure that we only pass refs that begin with `refs/` as is, otherwise, prepend them with `refs/heads`. Otherwise, branches named `heads/foo` (I know it's bad, but it's allowed), would be fetched as `foo`, instead of `heads/foo`.
2020-05-30Improve ref validity checking in fetchGitNikola Knezevic
The previous regex was too strict and did not match what git was allowing. It could lead to `fetchGit` not accepting valid branch names, even though they exist in a repository (for example, branch names containing `/`, which are pretty standard, like `release/1.0` branches). The new regex defines what a branch name should **NOT** contain. It takes the definitions from `refs.c` in https://github.com/git/git and `git help check-ref-format` pages. This change also introduces a test for ref name validity checking, which compares the result from Nix with the result of `git check-ref-format --branch`.
2020-05-30Remove TreeInfoEelco Dolstra
The attributes previously stored in TreeInfo (narHash, revCount, lastModified) are now stored in Input. This makes it less arbitrary what attributes are stored where. As a result, the lock file format has changed. An entry like "info": { "lastModified": 1585405475, "narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE=" }, "locked": { "owner": "NixOS", "repo": "nixpkgs", "rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be", "type": "github" }, is now stored as "locked": { "owner": "NixOS", "repo": "nixpkgs", "rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be", "type": "github", "lastModified": 1585405475, "narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE=" }, The 'Input' class is now a dumb set of attributes. All the fetcher implementations subclass InputScheme, not Input. This simplifies the API. Also, fix substitution of flake inputs. This was broken since lazy flake fetching started using fetchTree internally.
2020-05-26Change remaining bools with FileIngestionMethodCarlo Nucera
2020-05-13Update src/libfetchers/git.ccEelco Dolstra
Co-authored-by: Jörg Thalheim <Mic92@users.noreply.github.com>
2020-04-07Merge remote-tracking branch 'origin/master' into flakesEelco Dolstra
2020-04-07Merge branch 'fetchgit-recursive' of https://github.com/blitz/nixEelco Dolstra
2020-04-07Respect the narHash attribute in more input typesEelco Dolstra
(cherry picked from commit a6ff66b658b61aef80d936f0183447fe4cb46000)
2020-04-07Backport libfetchers from the flakes branchEelco Dolstra
This provides a pluggable mechanism for defining new fetchers. It adds a builtin function 'fetchTree' that generalizes existing fetchers like 'fetchGit', 'fetchMercurial' and 'fetchTarball'. 'fetchTree' takes a set of attributes, e.g. fetchTree { type = "git"; url = "https://example.org/repo.git"; ref = "some-branch"; rev = "abcdef..."; } The existing fetchers are just wrappers around this. Note that the input attributes to fetchTree are the same as flake input specifications and flake lock file entries. All fetchers share a common cache stored in ~/.cache/nix/fetcher-cache-v1.sqlite. This replaces the ad hoc caching mechanisms in fetchGit and download.cc (e.g. ~/.cache/nix/{tarballs,git-revs*}). This also adds support for Git worktrees (c169ea59049f861aaba429f48b828d0820b74d1d).
2020-04-02Respect the narHash attribute in more input typesEelco Dolstra
call-flake.nix now passes node.info.narHash to fetchTree. This ensures that dirty Git trees work even in pure mode.
2020-03-30Move fetchers from libstore to libfetchersEelco Dolstra