Thursday, November 18, 2010

Minimal git commands

Initialize a repository by,

git init

Add files to the repo by,

git add .

git add file

removal,
git rm file

rename,
git mv old new

This will add all the file under the directory recursively.

Now do a base commit,

git commit -a

This will commit all the files to the repository .

To create a new branch for editing,
git checkout -b devel

Commit only required changes
If you have many changes, for example in folders like drivers/video and drivers/sound. And you only want to commit the changes to drivers/video, then git add those files and type git commit without using -a option.

git add drivers/video/
git commit

If your master has grown beyond the point when you took the devel branch, you can update the master and you can rebase the devel branch to master,

git rebase -i master

Have a look here for more doubts about merging issues.
http://stackoverflow.com/questions/449541/how-do-you-merge-selective-files-with-git-merge

configuring the .gitconfig file,
My .gitconfig file looks like this
cat ~/.gitconfig
[user]
name = "Arun Sudhilal"
email = "arun.sudhilal@lntinfotech.com"
[core]
editor = vim
[color]
ui = auto
[merge]
tool = vimdiff

Creating patches,
git format-patch HEAD~1

HEAD^^ == HEAD~2


---
git show
git show --stat
git show --name-status HEAD~3
git show HEAD:file
contents.....

git log
git log HEAD~10..

git log --author=arun
git log --committer=arun
git log --grep="commit.*message.*text"

For expample if i want to grep "frame", then
git log --grep="grame"
git log -S "some code change"
git log file
git grep -e "pattern" -- some/file

git branch name commit
git checkout name
git checkout -b name commit
git checkout -m name
merge outstanding diff onto branch "name", can result in conflict.

git tag -a -m "got somewhere" good

git rebase
moves new work to a new base line

git fetch
Just update the remote, but doesn't update work space

git fetch + git merge = git pull

to apply a patch in you local tree,
git am -3

Pushing to the repositories,
* git push origin will push changes from all local branches to matching branches the origin remote
* git push origin master will push changes from the local master branch to the remote master branch
* git push origin master:staginwill push changes from the local master branch to the remote staging branch if it exists

Recovering lost commits,Sometime by mistake you might have done git reset --hard HEAD^. Then you realise that you need that commit. Dont worry, git has a way to recover your lost commit.

git reflog

Git tracks almost everything you does. If you feels that you have screwed up you repo by rebase, merge or even by reset, you can dig reflog and get it back.

git reflog output may be something like this,
6d2a85e HEAD@{0}: merge 6d2a85e: Fast-forward
28eb495 HEAD@{1}: 28eb49561313ce479f228acea6d25a2bf20166a8: updating HEAD
6d2a85e HEAD@{2}: pull : Fast-forward
6744afe HEAD@{3}: 6744afe5afa033763cdb4e698eea1a5febabae8e: updating HEAD

once you get this you can check with git show which commit you want. For here you can cherry-pic, merge or checkout.


.gitconfig
And this is how my .gitconfig looks like,



Renaming current branch,
git branch -m linux-linaro-tracking

Checkout with the same name as remote,
git co -t remotes/origin/linux-linaro

Suwon, S Korea

Monday, November 8, 2010

Touch doesnt work in lock screen after resuming from sleep

In file drivers/i2c/busses/i2c-s3c2410.c, function,
static int s3c24xx_i2c_set_master(struct s3c24xx_i2c *i2c)
{
unsigned long iicstat;
int timeout = 400;

while (timeout-- > 0) {
iicstat = readl(i2c->regs + S3C2410_IICSTAT);

if (!(iicstat & S3C2410_IICSTAT_BUSBUSY))
return 0;

msleep(1);
}

return -ETIMEDOUT;
}

Some how the bus is busy even after 400 iterations. The i2c adaptor may be going to some invalid state. Added,

writel(iicstat & ~S3C2410_IICSTAT_TXRXEN, i2c->regs + S3C2410_IICSTAT);

after the msleep(1). This will disable the Rx/Tx of the i2c adapter, which is later enabled. So basically its a reset of the register

I2C-bus data output enable/ disable bit.
0 = Disables Rx/Tx,
1 = Enables Rx/Tx

This blog looks interesting about the i2c drive in linux-2.6.32
http://www.embedded-bits.co.uk/?p=174

Saturday, November 6, 2010

wakeup from suspend to Ram

echo mem > /sys/power/state should suspend to ram and
echo on > /sys/power/state should wake up the device from suspend.

Former was not working on Atlas phone. It was because the read from /sys/power/state was not implemented properly. When you try to read it should print all the valid power states. But it was only giving mem as the output. In file kernel/power/main.c, function state_show calls valid_states which in turn calls a architecture implemented function pointer. The function is called by passing mem, on or standby as the argument. It will return true if it architecture support the argument state. So state_show will give out put accordingly.

Previously it was giving true only for mem. Modified the .valid function pointer in the architecutre file (arch/arm/plat-samsung/pm.c) to give true for mem, on and standby. This fixed the wakeup issue.

Got some help from,
Linux Symposium