repo 'bisect' for debugging Android? - android

git bisect works by counting the number of commits between 'good' and 'bad' and checking out the change in the middle. Unfortunately this wouldn't work well for repo because one project (e.g. framework) may have a lot of changes early on and another project (e.g. kernel) may have a bunch of later changes, so 'repo forall -c "git bisect ..."' could have one project checked out in a state a lot older than an other.
My question is whether there is a way to get git-bisect to choose its commit based on the date of the commit, so when done across projects we're most likely to be left in a state that compiles cleanly.

git bisect is not designed to be used across multiple repositories simultaneously.
You'd probably be better of writing your own script that implements a basic bisection algorithm across date ranges, and use git rev-list -n1 --before <DATEVALUE> in each repository to obtain a git commit to check out corresponding to whatever date your script is currently bisecting.
Here's an example bisection script that I had written for another purpose. Note that it is not specifically designed for your situation; it's just an example of implementing bisection:
https://gist.github.com/2040290

Someone has coded such a script up:
https://github.com/tdm/android-scripts/blob/master/repo-bisect

Related

GIT separating 1 project into the 2

I am working in some project for mobile devices. Soon it will be separated into the two projects with the same code but another one will be for AndroidTV.
So how we should build git logic, when I am working with mobile project and the other programmer working with my code, but adapting it for AndroidTV?
My ideas:
We need to have two different branches in repository. One for mobile and one for AndroidTV. So before the other programmer will be comitting and pushing his changes to his branch, first he must make "Pull" from my branch and then Commit and Push to AndroidTV branch.
Am I right? If no, please upgrade my ideas.

Forking a repository in server using git path [duplicate]

I keep hearing people say they're forking code in Git. Git "fork" sounds suspiciously like Git "clone" plus some (meaningless) psychological willingness to forgo future merges. There is no fork command in Git, right?
GitHub makes forks a little more real by stapling correspondence onto it. That is, you press the fork button and later, when you press the pull request button, the system is smart enough to email the owner. Hence, it's a little bit of a dance around repository ownership and permissions.
Yes/No? Any angst over GitHub extending Git in this direction? Or any rumors of Git absorbing the functionality?
Fork, in the GitHub context, doesn't extend Git.
It only allows clone on the server side.
When you clone a GitHub repository on your local workstation, you cannot contribute back to the upstream repository unless you are explicitly declared as "contributor". That's because your clone is a separate instance of that project. If you want to contribute to the project, you can use forking to do it, in the following way:
clone that GitHub repository on your GitHub account (that is the "fork" part, a clone on the server side)
contribute commits to that GitHub repository (it is in your own GitHub account, so you have every right to push to it)
signal any interesting contribution back to the original GitHub repository (that is the "pull request" part by way of the changes you made on your own GitHub repository)
Check also "Collaborative GitHub Workflow".
If you want to keep a link with the original repository (also called upstream), you need to add a remote referring that original repository.
See "What is the difference between origin and upstream on GitHub?"
And with Git 2.20 (Q4 2018) and more, fetching from fork is more efficient, with delta islands.
I keep hearing people say they're forking code in git. Git "fork" sounds suspiciously like git "clone" plus some (meaningless) psychological willingness to forgo future merges. There is no fork command in git, right?
"Forking" is a concept, not a command specifically supported by any version control system.
The simplest kind of forking is synonymous with branching. Every time you create a branch, regardless of your VCS, you've "forked". These forks are usually pretty easy to merge back together.
The kind of fork you're talking about, where a separate party takes a complete copy of the code and walks away, necessarily happens outside the VCS in a centralized system like Subversion. A distributed VCS like Git has much better support for forking the entire codebase and effectively starting a new project.
Git (not GitHub) natively supports "forking" an entire repo (ie, cloning it) in a couple of ways:
when you clone, a remote called origin is created for you
by default all the branches in the clone will track their origin equivalents
fetching and merging changes from the original project you forked from is trivially easy
Git makes contributing changes back to the source of the fork as simple as asking someone from the original project to pull from you, or requesting write access to push changes back yourself. This is the part that GitHub makes easier, and standardizes.
Any angst over Github extending git in this direction? Or any rumors of git absorbing the functionality?
There is no angst because your assumption is wrong. GitHub "extends" the forking functionality of Git with a nice GUI and a standardized way of issuing pull requests, but it doesn't add the functionality to Git. The concept of full-repo-forking is baked right into distributed version control at a fundamental level. You could abandon GitHub at any point and still continue to push/pull projects you've "forked".
Yes, fork is a clone. It emerged because, you cannot push to others' copies without their permission. They make a copy of it for you (fork), where you will have write permission as well.
In the future if the actual owner or others users with a fork like your changes they can pull it back to their own repository. Alternatively you can send them a "pull-request".
"Fork" in this context means "Make a copy of their code so that I can add my own modifications". There's not much else to say. Every clone is essentially a fork, and it's up to the original to decide whether to pull the changes from the fork.
Cloning involves making a copy of the git repository to a local machine, while forking is cloning the repository into another repository. Cloning is for personal use only (although future merges may occur), but with forking you are copying and opening a new possible project path
I think fork is a copy of other repository but with your account modification. for example, if you directly clone other repository locally, the remote object origin is still using the account who you clone from. You can't commit and contribute your code. It is just a pure copy of codes. Otherwise, If you fork a repository, it will clone the repo with the update of your account setting in you github account. And then cloning the repo in the context of your account, you can commit your codes.
Forking is done when you decide to contribute to some project. You would make a copy of the entire project along with its history logs. This copy is made entirely in your repository and once you make these changes, you issue a pull request. Now its up-to the owner of the source to accept your pull request and incorporate the changes into the original code.
Git clone is an actual command that allows users to get a copy of the source.
git clone [URL]
This should create a copy of [URL] in your own local repository.
There is a misunderstanding here with respect to what a "fork" is. A fork is in fact nothing more than a set of per-user branches. When you push to a fork you actually do push to the original repository, because that is the ONLY repository.
You can try this out by pushing to a fork, noting the commit and then going to the original repository and using the commit ID, you'll see that the commit is "in" the original repository.
This makes a lot of sense, but it is far from obvious (I only discovered this accidentally recently).
When John forks repository SuperProject what seems to actually happen is that all branches in the source repository are replicated with a name like "John.master", "John.new_gui_project", etc.
GitHub "hides" the "John." from us and gives us the illusion we have our own "copy" of the repository on GitHub, but we don't and nor is one even needed.
So my fork's branch "master" is actually named "Korporal.master", but the GitHub UI never reveals this, showing me only "master".
This is pretty much what I think goes on under the hood anyway based on stuff I've been doing recently and when you ponder it, is very good design.
For this reason I think it would be very easy for Microsoft to implement Git forks in their Visual Studio Team Services offering.
Apart from the fact that cloning is from server to your machine and forking is making a copy on the server itself, an important difference is that when we clone, we actually get all the branches, labels, etc.
But when we fork, we actually only get the current files in the master branch, nothing other than that. This means we don't get the other branches, etc.
Hence if you have to merge something back to the original repository, it is a inter-repository merge and will definitely need higher privileges.
Fork is not a command in Git; it is just a concept which GitHub implements. Remember Git was designed to work in peer-to-peer environment without the need to synchronize stuff with any master copy. The server is just another peer, but we look at it as a master copy.
In simplest terms,
When you say you are forking a repository, you are basically creating a copy of the original repository under your GitHub ID in your GitHub account.
and
When you say you are cloning a repository, you are creating a local copy of the original repository in your system (PC/laptop) directly without having a copy in your GitHub account.

How do developers who customise AOSP keep their changes under version control?

Fetching the AOSP source, is 134GB.
A checkout of a particular version of Android is likely to be many GBs.
How do developers who customise AOSP keep their changes under (their own) version control? (Given that checking-in a snapshot of an Android version's source will be many GBs.)
This is my flow, maybe not the best....
I don't like dealing with repo tool and multiple remotes, so I get rid of all the .git subfolders and create just one tremendously huge repository. This has the bad effect of essentially removing all the "history". So we have a server with the original sync for git blame if we need to.
First check-out for a developer will be time-consuming either way. To make it faster, we have a local bare git repo cloned. So people run git clone on the local server, and the switch the origin to the actual remote.
After all is set-up, the day-to-day dealings are not time consuming. Commits and pushes are quite fast ( maybe 5-10s ) even for a large repo like this. Thanks GIT!
Sorry for necro-posting, but maybe somebody find it useful.
I just use repo utility from Google, e.g. repo start.
Only first repo sync procedure take a long time,
even subsequent checkouts do not like so time-consuming.
If you check some popular ROM, e.g. GrapheneOS, you find they repo too.

Android source and merging branches

I've been learning to develop against the Android source tree, and while things are going well I'm not sure I've completed things in the most efficient way to merge into future versions.
Background: Android has many repositories that fit together. In some cases, a repo uses branches with names like "android-5.0.0_r6" to delineate a specific release. In other cases, that branch doesn't exist, instead, a tag exists with the name "android-5.0.0_r6".
My method: What I've done is create a new branch, called "nowsci-5.0.0_r6" based off the branch or tag (depending on which that repo had) for the repositories I needed to modify. I then made my changes, and pointed the android manifest at my new repos and everything seems to work fine.
My question: What should I do when "android-5.0.0_r7" rolls out? Is there an easy way to create a new branch of "nowsci-5.0.0_r7" and merge my modifications from r6 into r7? Or should I have done this completely different?
Here's one of the repos for example: https://github.com/Fmstrat/platform_frameworks_base
Thanks.
Follow their lollipop-release branch instead of the android-5.0.0_rX branches.

Git. Store several projects under the same repository

Imagine mobile application that is planned to be implemented for both iOS and Android.
Development was started from the iOS version only and now the time has come to start with Android one.
iOS application's code is stored at its' own Git repository that named after the apps name, e.g. "MYApp".
Now I would like to create one common repository for both iOS and Android applications and name it again after application's name: "MYApp".
It is not a problem at first glance.
Just create repository, create 2 subfolders there and start working.
But.
I would like that Android developer could work only with his folder and iOS developer only with his one too and both of them could see only their own folders related history (log).
I worked with SVN previously.
Usually I created subfolders and you could checkout any of them to work only with this subfolder.
History was also filtered to your scope.
I'm stuck with implementing the same under Git.
Please, help me to find right direction.
I will sum up solutions suggested.
Use branching for different platforms. I don't think that it is good idea, because branches used for another purpose. It seems to me very "jacky".
Use submodules. Just create as many repos as platforms you are targeting to, name them "MYApp-iOS", "MyApp-Android", etc. and finally end up with "master" repo, that could be names as "MYApp" (without any suffixes). Then add all related repos to "master" one with git submodules feature.
Use git slave. Investigating...
Please, feel free to edit this list to brainstorm the problem.
There is a way to keep to kind-of-related separate projects in a same git repository utilising git branching.
But keep in mind that that is not why branching was implemented into git. One of its uses would be development of a radical new functionality to your app that might not see the release any time soon for example.
On the end: it is a matter of opinion. If you are prepared to administrate a more complex repository just to keep both codes on the same place - you can.
I would definetly make two separate repositories though. Couple of opinions on this topic can also be found here on SO: Git branches with completely different content
EDIT:
gitslave seems to tackle your problem. You might want to give it a try.

Categories

Resources