Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I had to dig through the source files to figure out how to use the git_drupalorg package handler with a git --reference cache to speed up my development.
After figuring that out, I recognized that drush's cache lives in the user's home directory by default, which is on a different filesystem in my case (slowing down clones from cache), and which also prevents to re-use/share the cache with other local system/network users.
So attached patch is what I came up with; might need some tweaking.
Comment | File | Size | Author |
---|---|---|---|
#12 | drush.clone_.12.patch | 4.6 KB | sun |
#10 | drush.clone_.10.patch | 5.4 KB | sun |
#9 | drush.clone_.9.patch | 6.92 KB | sun |
#7 | drush.clone_.7.patch | 6.08 KB | sun |
#4 | drush.clone_.4.patch | 3.96 KB | sun |
Comments
Comment #1
sunThis new clone alias revealed some more instances of drush_delete_dir() that are missing the $force = TRUE argument. Fixed those in attached patch.
EDIT: Those might rather belong into a follow-up patch for #1214018: Bogus filesystem paths, warnings, and stale directories
Comment #2
sunThe alias could probably have the --dev flag built-in, not sure.
Would also be lovely if there was a way to default --gitusername to the currently logged in user.
---
However, a much larger remaining issue is that - even though the clone seems to come from cache - it is cloned into a temporary directory first, and only afterwards moved to the destination:
EDIT: To clarify: I don't understand why the repo is cloned into a temp directory first, and only moved afterwards. That looks like a totally superfluous (and slow and heavy) file operation to me...?
Comment #3
sunOuch: #1178036-4: Exception: bad reference: HEAD in Git->revParse() :(
Comment #4
sunSo #1178036: Exception: bad reference: HEAD in Git->revParse() is caused by drush checking out an odd (possibly bogus?) commit hash by default -- it does not seem to checkout a tag, but its commit hash instead -- or something along those lines...
We can work around that bug by also passing the
--dev
option, which I think makes sense anyway -- if youdrush clone
, then you most likely want to work on the currently recommended development branch.Attached patch performs that change.
Comment #5
sun#1235044: halstead/glip 1.0 is outdated, doesn't contain fix for --reference resolves that git_deploy issue with git --reference clones.
Comment #6
sunmmm, it's even worse than I outlined in #2 -- drush performs a full separate git clone in the temp directory instead of adding the remote to its gitcache and fetching it:
Comment #7
sunAlright, attached patch pretty much fixes all issues I've encountered.
I've also seen that #6 happens on purpose in drush_gitcache_add_project() (although the documented reasoning is a bit sparse...)
Comment #8
sunumphhhh.... The initial clone is not found, because git remote add points to the temporary directory instead of the bare git repository directory inside of it.
This means that the entire purpose of the separate clone performed in drush_gitcache_add_project() is moot. Instead, the remote is effectively fetched two times from scratch.
Comment #9
sunAlright, attached patch also fixes that initial gitcache clone path mismatch outlined in #8.
Thus, the only remaining issue is that the final clone is initially performed in a temporary directory, and the files are only moved afterwards into the destination directory.
Due to the new 'home' and 'temp' drushrc options, the massive file move operation is no longer an issue, since it can be performed on the same filesystem by setting the drushrc options.
However, I'd still like to get rid of that move operation, since on Windows, git marks the moved files as "changed" - until I run a git diff, in which case git seems to determine that the files are actually matching the index. Might be better to investigate that in a separate follow-up issue though.
---
Also, but rather minor: the suggested 'clone' alias example still contains my own username. While it's possible that some developers are using a system username that matches their d.o username (as in my case), it might be overkill to implement dynamic placeholder support for --gitusername.
Comment #10
sunFollow-up patch in #1214018: Bogus filesystem paths, warnings, and stale directories has been committed.
Incorporated @msonnabaum's suggested alternative fix from https://gist.github.com/1123094
Comment #11
moshe weitzman CreditAttribution: moshe weitzman commentedOK, so the bits I am undecided about in the latest patch:
The shell alias 'clone' should probably just map to `git clone` so that folks who confuse their `git` and their `drush` are OK. Thats what we do for pull shell alias. Maybe 'dl-gitdev'?
I think the new options to set tmp and home are a bit dangerous but I'd like feedback on that. I say dangerous because you really change drush's behavior by changing home 'home' (backups, search path for commands, aliases, etc). 'home' and 'tmp' can be changed today using Env variables (see putenv). Thats how the test framework sets them. We would need to mention this env variable technique in the option help.
We could potentially take the hunks that fix reference cache and leave out the drush clone and option stuff
Comment #12
sunReplaced 'home' and 'temp' overrides with Windows .bat documentation.
Comment #13
moshe weitzman CreditAttribution: moshe weitzman commentedCommitted to master (SHA b2cf9ad) without the new options. I think the --reference fixes should backport fine but the shell alias stuff is master only ... Thanks sun.
Comment #14
msonnabaum CreditAttribution: msonnabaum commentedI backported only the changes to the git pm backend. The rest doesn't apply as it builds on changes we made for windows in drush5 that I won't be backporting.