Rapunzel
Rapunzel

Reputation: 75

How to download a specific folder of Chromium code?

Recently, I tried to download source code for chromium browser. In details, I just wanted to download code at https://github.com/chromium/chromium/tree/master/chrome. I tried several methods such as Downgit and SVN but nothing worked. The thing is, the methods I used worked on other sites and folders. I can't understand. Could anyone help me? If not, please let me know any other place where I can download desktop version chromium browser source code. Thanks in advance.

Upvotes: 4

Views: 919

Answers (2)

VonC
VonC

Reputation: 1324497

I don't want to download full source nor build it. I just want to check out some codes in chromium browser source code

Since it is a Git repository, you can use a filter clone (I detail its syntax here):

git clone \
  --depth 1 \
  --filter=blob:none \
  --no-checkout \
  https://github.com/chromium/chromium \
;
cd chromium
git switch main -- chrome

You also have the sparse cone option:

git clone \
  --depth 1 \
  --filter=blob:none \
  --no-checkout \
  https://github.com/chromium/chromium \
;
cd chromium
git sparse-checkout init --cone
git sparse-checkout set chrome
git switch main

Upvotes: 2

kinshukdua
kinshukdua

Reputation: 1994

I found this question when I was looking for the same thing and as it turns out @VonC's solution is almost right. You do

git clone \
--depth 1 \
--filter=blob:none \
--no-checkout \
https://github.com/chromium/chromium \
;
cd chromium

but before you checkout you just set core.fscache = false via the

git config core.fscache false

command and then continue with

 git sparse-checkout init --cone
 git sparse-checkout set chrome

The sha1 error is not your fault and is just a bug with git, in another similar post an issue was opened about it and this fscache was the solution they gave for the time being. If you're on Linux you don't even have to do this. The commands mentioned above would work! Cheers.

Upvotes: 3

Related Questions