Check the integrity of files downloaded by repo sync - android

I was downloading the source code of a Custom ROM of Android from GitHub, using repo sync command. During the download I had a bunch of errors, all related to fatal: The remote end hung up unexpectedly.
After running repo sync a couple of times more, I finally managed to download all the files. However, I would like to check the integrity of the files downloaded. That means, if I manually edit any of the files, or if any file is broken during download, I would like them to be downloaded and replaced.
I have scoured the net for such a command, but I can't find any for repo. I found repo status shows all the edits I have made, but I can't find any that'll actually check the integrity of the unchanged files.
I am using Ubuntu 18.10, by the way. Is there any such command?

repo forall -vc "git fsck --all" did the trick.
git fsck checks for the integrity on each git repository, and running that inside repo forall executes it on all repositories created.
Thanks to Philippe for the idea in comment.

Related

Delete all non-current branches using Android repo

I apologize if some of my terminology is off, feel free to correct that as well.
If you use repo sync -c, you will only download the current branch for every project in the selected manifest. If you don't use -c you will download other branches for all projects. Is there a way to delete all other branches after you have already repo synced without -c? I was hoping for something like:
repo forall -c git [delete all branches except current],
but there doesn't seem to be a command like that in git. Can repo do this?

How to clone clarifai-android-sdk using "git lfs"?

I want to create an object detection application using clarifai android library found in the following link:
clarifai android
The documentation is very clear but the problem is in cloning the clarifai-android-sdk using git-lfs
and this what is mentioned in the documentation:
1) Git LFS
Before doing anything else, please make sure you have Git-LFS
installed on your system. The binary contained in the framework is
managed by GitHub using git-lfs.
If you don't have it installed yet, you can find details at:
https://git-lfs.github.com. IF YOU DON'T HAVE GIT-LFS INSTALLED, THE
SDK WILL NOT WORK.
2) Verifying the SDK
After setting up Git LFS, please ensure that the SDK
cloned correctly, by checking the size of the *.aar. If the size is
less than ~120MB, then you will need to re-pull master now that Git
LFS is set up.
If you downloaded a ZIP of the project via the "Clone or download"
button, the SDK will be cloned incorrectly. Either clone the repo with
git, or download the *.aar file specifically by clicking on the file
through GitHub, and clicking the "Download" button.
if it is not clear this is a link of the full clarifai-android-sdk documentation
I have already installed git-lfs but when I try to clone the repository of clarifai-android-sdk the size of '.aar' file is 100 megabyte not as mentioned previously that:
if the '*.aar' file is less than 120 megabyte then you will need to
re-pull master now that Git LFS is set up.
so generally: I need to know what should I do to solve this problem ?
and specifically what is the meaning of re-pull master now that Git LFS is set up.
I would think that doing a git pull would solve that (yeah its unusual to do it right after a git clone but that seems to be what it is saying.

Git fails to pull error unrelated histories

So I have an android studio project that I'm syncing between my laptop and my computer with git. Every time I push with one and pull with the other when I try to pull I get error refusing to merge unrelated histories
I tried using --allow-unrelated-histories but that causes a ton of merge conflicts.
I need to be able to sync between the two because my computer supports the emulator and my laptop is portable.
This happens because your repositories was initialized independly.
You should create the repository only in one location, and clone it to the other.
If the other repository already exists and you have there some change which you don't want to lose, you could do the following:
(from location2, commit all uncommitted changes first!)
git fetch location1
git branch save_location2
git reset --hard origin/location1
So you switch to the history started at location1, and would not lose your history started at location2, and will be able to look up stuff from there.
There are exceptional cases where you should use --allow-unrelated-histories, but I'm sure it is not your case.
I had same problem. Try this:
git pull origin master --allow-unrelated-histories
git push origin master
Reference:- Github unrelated histories issue

how to fix Commit to git failed due to network

I added files to git git->add in android studio, files were added successfully. When I pressed commit and push, it was interrupted due to network issue. And nothing was pushed to git.
Now When I'm trying to add and commit, it ways nothing to push.
Kindly advise how to fix this in android studio.
Thanks in advance.
Your files already committed in your local system. Thats why you are unable to see any files when committing again.
To push the committed code, Goto VCS -> Git -> Push, You will see all the committed files, So you can push it to repository.
Alternative Terminal way,
You can also execute this command in terminal to push your code to master
git push -u origin master
Hope this helps.

how to use "repo" to clone minimal android source?

I am able to clone the Android source code by using the "repo" tool. However, what I want to do is clone the source code in a more minimal way than having an 11GB footprint. It seems to download things related to every Android device and every prior release. I tried thought I could reduce this by checking out a specific branch like this:
repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
However, what ends up happening is that I still get everything involved, just at a specific snapshot (understandable). But is there any way to limit the amount that is cloned?
The android source tree is made up of many separate git repositories, which are all managed by repo. You can't really reduce the amount of data that's downloaded for a given git repository.
However, you can only download a subset of the git repos that are available, using repo sync <project>. I.e. if you only wanted the frameworks/base package, you should be able to do repo sync frameworks/base, after doing the initial repo init.
If you are actually wanting to build the source though, you probably want the full thing.
You might be able to save a gig or two by removing the device repositories that you don't need. You can do this by editing <source>/.repo/manifest.xml and removing the repositories for the devices you don't want.
There are a number of things you can do. First, "repo sync" with a -c argument will limit the checked-out sandbox to only the "current" branch. The repo sync will not download material for other branches.
You can also edit the .repo/manifests/default.xml manifest. What I do is make a backup of it such as "default.bak" and then strip out the lines from the default.xml file I know I don't need. Because I'm not building on a Macintosh, I know I don't need any of the "darwin" tools, so I remove every line that contains "darwin". Then "repo sync" doesn't download any darwin projects or install the source code in the sandbox.
If you already synched a sandbox, and you want to trim its size, you can strip projects out as above, and then do "repo sync -c -l", and repo sync will only strip the directories that you just removed. The -l flag only does the local part of the sync, which means it only syncs the local git projects with your source tree. The network is not used. See the "-n" flag for the other half of a normal sync, which does the network sync to update the local git projects with the upstream repository.
To also remove the git backing object stores for the unwanted projects (which take up a lot of room) I use this:
for project in `diff ~/android/.repo/manifests/default.xml ~/android/.repo/manifests/default.bak | awk '{print $3}' | grep path | cut -f2 -d\"`; do rm -rf ~/android/.repo/projects/$project.git ; rm -rf ~/android/.repo/project-objects/$project.git ; done
This finds all the projects that are in your backup manifest, but have been removed from your active manifest, and removes the git projects and all the backing data for them. This recovers a lot of space.
If you remove too much, just recover the project line from your backup manifest, and add it back into your active manifest. Then, a repo sync will get your git projects and your sandbox straight again. You can test the build to see if you've removed too much by doing "mma -B -n" in your project directory. This will try to do a full dependency build on your target, forcing all the targets to build even if they don't need it, and it will do it as a dry run. If the build fails, you removed something your project needs.
You can also set up a local mirror sandbox, and create small, working, reference sandboxes from your mirror. The working sandboxes don't contain git object stores, but refer to the central ones in the mirror. Use "repo init -u ... --mirror" to set up the mirror, and "repo init --reference=~/android-mirror -u ..." to refer to the mirror. The -u flag in the latter allows a real upstream repository to be used as the authority, while the mirror reference is used as a local cache. Local mirrors also avoid the download quota that the AOSP project enforces, and they are faster to sync to.

Categories

Resources