Tuesday, August 27, 2013

git review : dealing with - You have more than one commit that you are about to submit

In git + gerrit, you get below message while trying to submit change for review. How to deal with this if you just want to submit only one commit for review not all ?

$  git review -n
You have more than one commit that you are about to submit.
The outstanding commits are:

0e6b2fe (HEAD, betabranch) second commit for second_file.txt
26e6ec2 first commit for first_file.txt

Is this really what you meant to do?
Type 'yes' to confirm: no
Aborting.

You need to move the commit you want to submit for review to another branch and submit it. See below article how to move a commit to another branch.

http://techmolecules.blogspot.sg/2013/08/git-cherry-pick-move-selected-commit-to.html

Tuesday, August 20, 2013

git cherry-pick : move a selected commit to another branch

This git post is to demonstrate :
1 - use git cherry-pick to move a selected commit (among many commit of a brnach ) to amother from
2 - git review : just one commit out of many commit to gerrit code review

Working Bed:

Clone you central repo to your local system. create a branch alphabranch create a file first_file.txt and commit it.

$ git clone ssh://gerrit:29418/centralrepo.git mygitrepo
Initialized empty Git repository in /home/nasimuddin.ansari/git/mygitrepo/.git/
remote: Counting objects: 8272, done
remote: Finding sources: 100% (8272/8272)
remote: Total 8272 (delta 3517), reused 7971 (delta 3517)
Receiving objects: 100% (8272/8272), 1.31 MiB | 932 KiB/s, done.
Resolving deltas: 100% (3517/3517), done.

$ cd mygitrepo/

$  git checkout -b alphabranch
Switched to a new branch 'alphabranch'

$  git branch
* alphabranch
  master

$  date >first_file.txt

$  git status
# On branch alphabranch
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       first_file.txt
nothing added to commit but untracked files present (use "git add" to track)

$  git add first_file.txt

$  git status
# On branch alphabranch
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       new file:   first_file.txt
#

$  git commit -m"first commit for first_file.txt"
[alphabranch 1e9f56d] first commit for first_file.txt
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 first_file.txt

$  git log -1
commit 1e9f56d5e1acdf90360ddf553dd47cdc15071173
Author: Nasimuddin Ansari <nasimuddin.ansari@company.com>
Date:   Tue Aug 20 07:26:50 2013 +0000

    first commit for first_file.txt


Create a second file, do second commit and then create third file and do third commit in same branch alphabranch.

$  cal >second_file.txt
$  git add second_file.txt &&  git commit -m"second commit for second_file.txt"
$  cal 2013 >third_file.txt
$  git add third_file.txt && git commit -m"third commit on third_file.txt"

$  git log --graph --decorate --oneline -n3
d60352(HEAD, alphabranch) third commit on third_file.txt
e30f0b second commit for second_file.txt
1e9f56 first commit for first_file.txt


$  git status
# On branch alphabranch
nothing to commit (working directory clean)

 Now it is time to submit it for gerrit review. I just want to submit only second commit for review for the moment. On first and 3rd I need to do some more changes before submitting for review. Do a dry run and you know the problem - all three commits are listing in git review list !



$  git review -n
You have more than one commit that you are about to submit.
The outstanding commits are:

d60352(HEAD, alphabranch) third commit on third_file.txt
e30f0b second commit for second_file.txt
1e9f56 first commit for first_file.txt

Is this really what you meant to do?
Type 'yes' to confirm:no

I  just want to submit second commit for review.

git cherry-pick : moving a selected commit to new branch

Create a  commitbranch branch from master

$  git checkout -b commitbranch master
Switched to a new branch 'commitbranch'

$  git log --graph --decorate --oneline -n5
* 3d1bb52 (HEAD, master, commitbranch) boss has submitted fix
* bb7ebab change for system foo config file

Switch to alphabranch and find out commit ID you want to move to commit branch

$  git checkout alphabranch
Switched to branch 'alphabranch'

$  git log --graph --decorate --oneline -n3
d60352(HEAD, alphabranch) third commit on third_file.txt
e30f0b second commit for second_file.txt
1e9f56 first commit for first_file.txt


Now switch to commitbranch and do cherry-pick on second commit's ID.

$  git checkout commitbranch
Switched to branch 'commitbranch'

$  git cherry-pick e30f0b
Finished one cherry-pick.
[commitbranch c957988] second commit for second_file.txt
 1 files changed, 8 insertions(+), 0 deletions(-)
 create mode 100644 second_file.txt
                            ( Commit ID will change !)

$  git log --graph --decorate --oneline -n3
* c957988 (HEAD, commitbranch) second commit for second_file.txt
* 3d1bb52 (master) boss has submitted fix
* bb7ebab change for system foo config file


Now you are good to submit only one change for review. Do a dry run and submit it !

$  git review -n
Please use the following command to send your commits to review:

        git push gerrit HEAD:refs/publish/master/commitbranch

$ git review

                              Did this post help anyone ?

git - uncommiting last commit

--soft : uncommit all changes and move back to stage state



Create a new file, stage it (add), commit it and do soft reset HEAD^

$ git branch
* master

$ git checkout -b a_branch
Switched to a new branch 'a_branch'

$ git log --graph --decorate --oneline -n3
* 3d1bb52 (HEAD, master, a_branch) Noh has build ship
* bb7ebab this is john sermon

$ cal 2013 > a_test_file.txt

$ git status
# On branch a_branch
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       a_test_file.txt

$ git add a_test_file.txt

$ git status
# On branch a_branch
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       new file:   a_test_file.txt
#

$ git commit -m"a new change commited in a_test_file.txt"
[a_branch c1a194c] a new change commited in a_test_file.txt
 1 files changed, 35 insertions(+), 0 deletions(-)
 create mode 100644 a_test_file.txt

$ git log --graph --decorate --oneline -n3
* c1a194c (HEAD, a_branch) a new change commited in a_test_file.txt
* 3d1bb52 (master) Noh has build ship
* bb7ebab this is john sermon

$ git reset --soft HEAD^

$ git log --graph --decorate --oneline -n3
* 3d1bb52 (HEAD, master, a_branch) Noh has build ship
* bb7ebab this is john sermon


$ git status
# On branch a_branch
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       new file:   a_test_file.txt
#


--hard : discard all changes permanently ! 

All new files will be deleted and modification to all file will disappear (you cannot recover !)

Commit newly created import file and do --hard reset to make your life hell !

$ git commit -m"a new change commited in a_test_file.txt"
[a_branch 8a59c62] a new change commited in a_test_file.txt
 1 files changed, 35 insertions(+), 0 deletions(-)
 create mode 100644 a_test_file.txt

$ git log --graph --decorate --oneline -n3
* 8a59c62 (HEAD, a_branch) a new change commited in a_test_file.txt
* 3d1bb52 (master) Noh has build ship
* bb7ebab this is john sermon

$ git reset --hard HEAD^
HEAD is now at 3d1bb52 Noh has build ship
$ git log --graph --decorate --oneline -n3
* 3d1bb52 (HEAD, master, a_branch) Noh has build ship
* bb7ebab this is john sermon


$ git status
# On branch a_branch
nothing to commit (working directory clean


You file has been permanently deleted by Mr   --hard !

Saturday, August 17, 2013

php-gd installation fails because of libjpeg.so.62 though it is installed

Problem : php-gd installation fails on rhel6 because of libjpeg.so.62 though libjpeg-6b-46.el6.x86_64 is installed.


# /usr/bin/yum -d 0 -e 0 -y install php-gd-5.3.3-22.el6
Error: Package: php-gd-5.3.3-22.el6.x86_64 (qa-redhat-x86_64-6-repository)
           Requires: libjpeg.so.62(LIBJPEG_6.2)(64bit)
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest
#rpm -qf /usr/lib64/libjpeg.so.62
libjpeg-6b-46.el6.x86_64



Solution : Install libjpeg-turbo along with other installed package since libjpeg-6b-4 is replaced with libjpeg-turbo

# yum install php-gd libjpeg-turbo


Referencehttps://access.redhat.com/site/solutions/324053

Did it help you ?

Thursday, August 15, 2013

xhost command hangs

Problem : On a unix system LinuxSystem below xhost command hangs forever.
   
         LinuxSystem # xhost +


Situation : You have already exported DISPLAY variable and some Xservers is already running on RemoteSystem
 
   LinuxSystem# export DISPLAY=RemoteSystem:0.0


Solution : xhost use outgoing tcp port 6000 to connect to RemoteSystem. Your firewall is blocking is. Run strace to confirm.

LinuxSystem# strace xhost + | tail -10
socket(PF_NETLINK, SOCK_RAW, 0)         = 3
bind(3, {sa_family=AF_NETLINK, pid=0, groups=00000000}, 12) = 0
getsockname(3, {sa_family=AF_NETLINK, pid=33705, groups=00000000}, [12]) = 0
sendto(3, "\24\0\0\0\26\0\1\3\361\256\rR\0\0\0\0\0\0\0\0", 20, 0, {sa_family=AF_NETLINK, pid=0, groups=00000000}, 12) = 20
recvmsg(3, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000}, msg_iov(1)=[{"\24\0\0\0\3\0\2\0\361\256\rR\251\203\0\0\0\0\0\0\1\0\0\0\24\0\1\0\0\0\0\0"..., 4096}], msg_controllen=0, msg_flags=0}, 0) = 20
close(3)                                = 0
socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 3
setsockopt(3, SOL_TCP, TCP_NODELAY, [1], 4) = 0
setsockopt(3, SOL_SOCKET, SO_KEEPALIVE, [1], 4) = 0

connect(3, {sa_family=AF_INET, sin_port=htons(6000), sin_addr=inet_addr("RemoteSystem")}, 16 <unfinished ...>

Wednesday, August 14, 2013

git clone : "not a Gerrit project" OR "Could not read from remote repository" fatal error

First try to follow this document. If you are still  getting below error while you are cloning a git repo, it indicates that you or your group do not have permission (we are using gerrit to manage repository permission and code review) on repository.

$ git clone
ssh://UserName@MyGitServer.MyCompany.com:29418/MyGitRepo.git
Cloning into 'MyGitRepo'...
fatal: '/MyGitRepo.git': not a Gerrit project
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists
.

Surprisingly, below command shows that user is partof group that have rw permission.

$ id UserName|grep GroupNameOfUser
uid=512(UserName) gid=503(GroupNameOfUser)

BUT, query against  GroupNameOfUser on windows AD shows that it is not !

$ ldapsearch -h MyLDAPserver -p 389 -D 'CN=svc_UNIX_LDAP,OU=Standard Service Accounts,OU=Service Accounts,DC=MyCompany,DC=com' -w w82A4CCXq6A -x -b 'DC=MyCompany,DC=com' 'CN=GroupNameOfUser'


Solution : We were able to resolve it by removing user from group in AD and adding it again in the group. Run ldapsearch to crosscheck and did successful clone the repo. Is this page was useful for anyone ?

Thursday, May 2, 2013

TFTP - Fails with timeout

PROBLEM

On my Linux system:
* dhcp and tftp is running on same system  - tftp-dhcp-server
* tftp-dhcp-client is able to get IP address from DHCP server but tftp fails with below message

 $ tcpdump |grep ICMP

3:54:09.379106 IP tftp-dhcp-server > tftp-dhcp-client: ICMP host tftp-dhcp-server unreachable - admin prohibited, length 80
03:54:19.320800 IP tftp-dhcp-server > tftp-dhcp-client: ICMP host tftp-dhcp-server unreachable - admin prohibited, length 85
03:54:55.351027 IP tftp-dhcp-server > tftp-dhcp-client: ICMP host tftp-dhcp-server unreachable - admin prohibited, length 85

FIX
$ service iptables status
$ service iptablesstop
$ chkconfig iptables off

* If above did not help, checkif firewal is blocking tftp request.