Pages

Unixbhaskar's Blog

Wednesday, August 16, 2017

How to format patch and send patch by mail in Git

Well, these topic are littered on the internet. Still ,give you a detail ,what actually you need to do.

Step 1:

First and foremost thing, configure your git client like below:

The file you need to manipulate or put configuration in, should be in your home dir, the file name is :.gitconfig. I want you to only concentrate on sendmail part of it.

Here is how my .gitconfig file looks like :


[user]
email = yourmail@maildomain.com
name = Bhaskar Chowdhury
signingkey = yoursigninggpgkey
[push]
default = matching
[commit]
[gpg]
program = gpg2
[commit]
gpgsign = true
[core]
editor = vim
abbrev = 12
[color]
ui = true

[pretty]
fixes = Fixes: %h (\"%s\")
[log]
showSignature = true
[alias]
logline = log --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit

[sendemail]
; setup for using git send-email; prompts for password
smtpuser = yourmail@maildomain.com
smtpserver = smtp.maildomain.com
smtpencryption = tls
smtpserverport = 587
smtppass = yoursmtppassword


Well, we need to create the patch in a specific format that git email understands that.That is next step:

Step 2:

We need to get into the directory, where we want to create the patch(in fact it is not necessary, if you specify the path of the file )



bhaskar@GentooLinux_20:03:57_Wed Aug 16:~/git-linux/AdminScripts>git format-patch -1
0001-linux-counter-machine-update.patch

bhaskar@GentooLinux_20:04:15_Wed Aug 16:~/git-linux/AdminScripts>ls -al 0001-linux-counter-machine-update.patch
-rw-r--r-- 1 bhaskar vboxusers 35358 Aug 16 20:04 0001-linux-counter-machine-update.patch


Okay, git format-patch sub-command is used to create the patch and the -1 stands for the last commit you did in that directory.

Likewise, you can pick up any commit, which supposes to create a patch on.

So, next, send the patch to the designated parties. Please go through the output below to understand how it works.



bhaskar@GentooLinux_20:11:42_Wed Aug 16:~/git-linux/AdminScripts>git send-email 0001-linux-counter-machine-update.patch
0001-linux-counter-machine-update.patch
The following files are 8bit, but do not declare a Content-Transfer-Encoding.
0001-linux-counter-machine-update.patch
Which 8bit encoding should I declare [UTF-8]?
To whom should the emails be sent (if anyone)? unixbhaskar@lycos.com
Message-ID to be used as In-Reply-To for the first email (if any)?
(mbox) Adding cc: Bhaskar Chowdhury from line 'From: Bhaskar Chowdhury '
(body) Adding cc: Bhaskar Chowdhury from line 'Signed-off-by: Bhaskar Chowdhury '

From: Bhaskar Chowdhury
To: unixbhaskar@lycos.com
Cc: Bhaskar Chowdhury
Subject: [PATCH] linux counter machine update
Date: Wed, 16 Aug 2017 20:12:13 +0530
Message-Id: <20170816144213.31205-1-unixbhaskar@gmail.com>
X-Mailer: git-send-email 2.13.0
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The Cc list above has been expanded by additional
addresses found in the patch commit message. By default
send-email prompts before sending whenever this occurs.
This behavior is controlled by the sendemail.confirm
configuration setting.

For additional information, run 'git send-email --help'.
To retain the current behavior, but squelch this message,
run 'git config --global sendemail.confirm auto'.

Send this email? ([y]es|[n]o|[q]uit|[a]ll): y
OK. Log says:
Server: smtp.googlemail.com
MAIL FROM:
RCPT TO:
RCPT TO:
From: Bhaskar Chowdhury
To: unixbhaskar@lycos.com
Cc: Bhaskar Chowdhury
Subject: [PATCH] linux counter machine update
Date: Wed, 16 Aug 2017 20:12:13 +0530
Message-Id: <20170816144213.31205-1-unixbhaskar@gmail.com>
X-Mailer: git-send-email 2.13.0
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Result: 250


The above git command uses a sub-command send-email to send the mail to the designated parties. It also takes the patch file name as an argument to it.

If you look at the output closely, you can see that I have added some mail id in CC block apart from the default recipient.Once it's done taking your input, whom to send the patch, it will ask you with the option to quit and send et al.

Now, you should go back to your inbox and see the patch there!

Here is how it looks like in my mailbox:


Installing and working with Docker on Arch Linux i686 system


I am intentionally publishing this old, almost a year back draft for the reason of understanding.

Okay,building it on i686 arch is not fun or straight forward most people thorught ,or at least my dull head had that kind of impression.I am gonna give the steps I follwed :

bhaskar@ArchLinux_19:57:24_Mon Apr 06:~> sudo pacman -S docker-git
[sudo] password for bhaskar:
error: target not found: docker-git
bhaskar@ArchLinux_19:58:28_Mon Apr 06:~> sudo pacman -S docker
[sudo] password for bhaskar:
error: target not found: docker
bhaskar@ArchLinux_20:03:42_Mon Apr 06:~> sudo pacman -Ss docker


The above code is a routine habit on Arch ...but it was not working..plus I made the blunder not consulting the Docker-Archwiki page properly to install it on this specific architecture.

Then I got that tarball from AUR..


bhaskar@ArchLinux_20:03:52_Mon Apr 06:~> cd Downloads/
bhaskar@ArchLinux_20:10:21_Mon Apr 06:~/Downloads> ls
docker-git.tar.gz
bhaskar@ArchLinux_20:10:22_Mon Apr 06:~/Downloads> tar -xvzf docker-git.tar.gz
docker-git/
docker-git/PKGBUILD
docker-git/.SRCINFO
docker-git/docker.service
docker-git/docker.install
docker-git/docker.conf
bhaskar@ArchLinux_20:10:29_Mon Apr 06:~/Downloads> cd docker-git
bhaskar@ArchLinux_20:10:34_Mon Apr 06:~/Downloads/docker-git> ls
docker.conf docker.install docker.service PKGBUILD
bhaskar@ArchLinux_20:10:35_Mon Apr 06:~/Downloads/docker-git> makepkg
==> Making package: docker-git 1:1.5.0.dev.13153.99ca215-1 (Mon Apr 6 20:10:48 IST 2015)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Missing dependencies:
-> go
-> btrfs-progs
==> ERROR: Could not resolve all dependencies.


Ooops! it doesn't have the prerequisite in the system ,so I need to get them beforehand ...here we go..


bhaskar@ArchLinux_20:10:49_Mon Apr 06:~/Downloads/docker-git> sudo pacman -S go
[sudo] password for bhaskar:
resolving dependencies...
looking for conflicting packages...

Packages (1) go-2:1.4.2-2

Total Download Size: 48.02 MiB
Total Installed Size: 304.34 MiB

:: Proceed with installation? [Y/n] n
bhaskar@ArchLinux_20:11:14_Mon Apr 06:~/Downloads/docker-git> sudo pacman -S go btrfs-progs
resolving dependencies...
looking for conflicting packages...

Packages (2) btrfs-progs-3.19-1 go-2:1.4.2-2

Total Download Size: 48.54 MiB
Total Installed Size: 308.42 MiB

:: Proceed with installation? [Y/n] y
:: Retrieving packages ...
btrfs-progs-3.19-1-i686 533.6 KiB 337K/s 00:02 [######################################################################] 100%
go-2:1.4.2-2-i686 48.0 MiB 476K/s 01:43 [######################################################################] 100%
(2/2) checking keys in keyring [######################################################################] 100%
(2/2) checking package integrity [######################################################################] 100%
(2/2) loading package files [######################################################################] 100%
(2/2) checking for file conflicts [######################################################################] 100%
(2/2) checking available disk space [######################################################################] 100%
(1/2) installing go [######################################################################] 100%

The "liteide" package provides an IDE for editing and building Go projects.

An example use of the "go" tool:

mkdir ~/go
export GOPATH=~/go
export PATH=$PATH:~/go/bin
go get golang.org/x/tour/gotour

Optional dependencies for go
mercurial: for fetching sources from mercurial repositories
git: for fetching sources from git repositories [installed]
bzr: for fetching sources from bazaar repositories
subversion: for fetching sources from subversion repositories [installed]
(2/2) installing btrfs-progs [######################################################################] 100%
bhaskar@ArchLinux_20:13:29_Mon Apr 06:~/Downloads/docker-git> makepkg
==> Making package: docker-git 1:1.5.0.dev.13153.99ca215-1 (Mon Apr 6 20:14:04 IST 2015)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
-> Cloning docker git repo...
Cloning into bare repository '/home/bhaskar/Downloads/docker-git/docker'...
remote: Counting objects: 114972, done.
remote: Compressing objects: 100% (82/82), done.
remote: Total 114972 (delta 25), reused 1 (delta 1), pack-reused 114889
Receiving objects: 100% (114972/114972), 62.49 MiB | 476.00 KiB/s, done.
Resolving deltas: 100% (75706/75706), done.
Checking connectivity... done.
-> Found docker.service
-> Found docker.install
-> Found docker.conf
==> Validating source files with md5sums...
docker ... Skipped
docker.service ... Passed
docker.install ... Passed
docker.conf ... Passed
==> Extracting sources...
-> Creating working copy of docker git repo...
Cloning into 'docker'...
done.
==> Starting pkgver()...
==> Updated version: docker-git 1:1.5.0.dev.14431.58390b6-1
==> Starting prepare()...
==> Starting build()...
# WARNING! I don't seem to be running in the Docker container.
# The result of this command might be an incorrect build, and will not be
# officially supported.
#
# Try this instead: make all
#

---> Making bundle: dynbinary (in bundles/1.5.0-dev/dynbinary)
Created binary: /home/bhaskar/Downloads/docker-git/src/docker/bundles/1.5.0-dev/dynbinary/dockerinit-1.5.0-dev
Created binary: /home/bhaskar/Downloads/docker-git/src/docker/bundles/1.5.0-dev/dynbinary/docker-1.5.0-dev

==> Entering fakeroot environment...
==> Starting package()...
==> Tidying install...
-> Purging unwanted files...
-> Removing libtool files...
#
-> Removing static library files...
-> Compressing man and info pages...
==> Creating package "docker-git"...
-> Generating .PKGINFO file...
-> Adding install file...
-> Generating .MTREE file...
-> Compressing package...
==> Leaving fakeroot environment.
==> Finished making: docker-git 1:1.5.0.dev.14431.58390b6-1 (Mon Apr 6 20:17:08 IST 2015)



That's done..next..


bhaskar@ArchLinux_20:17:08_Mon Apr 06:~/Downloads/docker-git> ls
docker docker.conf docker-git-1:1.5.0.dev.14431.58390b6-1-i686.pkg.tar.xz docker.install docker.service pkg PKGBUILD src
bhaskar@ArchLinux_20:18:13_Mon Apr 06:~/Downloads/docker-git> sudo pkginstall docker-git-1\:1.5.0.dev.14431.58390b6-1-i686.pkg.tar.xz
[sudo] password for bhaskar:
sudo: pkginstall: command not found
bhaskar@ArchLinux_20:18:41_Mon Apr 06:~/Downloads/docker-git> sudo pacman -U docker-git-1\:1.5.0.dev.14431.58390b6-1-i686.pkg.tar.xz
loading packages...
resolving dependencies...
looking for conflicting packages...

Packages (1) docker-git-1:1.5.0.dev.14431.58390b6-1

Total Installed Size: 16.34 MiB

:: Proceed with installation? [Y/n] y
(1/1) checking keys in keyring [######################################################################] 100%
(1/1) checking package integrity [######################################################################] 100%
(1/1) loading package files [######################################################################] 100%
(1/1) checking for file conflicts [######################################################################] 100%
(1/1) checking available disk space [######################################################################] 100%
(1/1) installing docker-git [######################################################################] 100%
To make Docker fully functional, consider performing the following actions:
+ Start the docker daemon:
$ sudo systemctl start docker
+ (OPTIONAL) Start the docker daemon at boot:
$ sudo systemctl enable docker
+ Add your user to the docker group to run the docker client without sudo:
$ sudo usermod -a -G docker
Login again for the change to take effect or run the following command
for a change affecting only the current shell:
$ newgrp docker
+ Enable IPv4 forwarding to allow internet connections inside the containers.
See /etc/sysctl.d/docker.conf for WARNING and instructions.


Okay,installed the docker-git now.Few rudimentary things left...



bhaskar@ArchLinux_20:19:07_Mon Apr 06:~/Downloads/docker-git> sudo usermod -a -G docker bhaskar
bhaskar@ArchLinux_20:19:59_Mon Apr 06:~/Downloads/docker-git> newgrp docker
bhaskar@ArchLinux_20:20:22_Mon Apr 06:~/Downloads/docker-git> sudo vim /etc/sysctl.conf
bhaskar@ArchLinux_20:20:58_Mon Apr 06:~/Downloads/docker-git>


BTW, I have edited the /etc/sysctl.conf file and change the value "0" to "1" for packet forwarding to the container!

Next,start the service and check the status :


bhaskar@ArchLinux_20:23:57_Mon Apr 06:~/Downloads/docker-git> sudo systemctl start docker
bhaskar@ArchLinux_20:24:09_Mon Apr 06:~/Downloads/docker-git> sudo systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: active (running) since Mon 2015-04-06 20:24:09 IST; 18s ago
Docs: http://docs.docker.io
Process: 7330 ExecStartPre=/usr/bin/mount --make-rprivate / (code=exited, status=0/SUCCESS)
Main PID: 7333 (docker)
CGroup: /system.slice/docker.service
└─7333 /usr/bin/docker -d

Apr 06 20:24:09 ArchLinux docker[7333]: time="2015-04-06T20:24:09.810967350+05:30" level=info msg="Listening for HTTP on unix (/var/run/docker.sock)"
Apr 06 20:24:16 ArchLinux docker[7333]: time="2015-04-06T20:24:16.865655559+05:30" level=info msg="+job init_networkdriver()"
Apr 06 20:24:20 ArchLinux docker[7333]: time="2015-04-06T20:24:20.906197291+05:30" level=info msg="-job init_networkdriver() OK"
Apr 06 20:24:21 ArchLinux docker[7333]: time="2015-04-06T20:24:21.205879523+05:30" level=warning msg="Your kernel does not support cgroup swap limit."
Apr 06 20:24:21 ArchLinux docker[7333]: time="2015-04-06T20:24:21.212245232+05:30" level=info msg="Loading containers: start."
Apr 06 20:24:21 ArchLinux docker[7333]: time="2015-04-06T20:24:21.212644699+05:30" level=info msg="Loading containers: done."
Apr 06 20:24:21 ArchLinux docker[7333]: time="2015-04-06T20:24:21.212761269+05:30" level=info msg="docker daemon: 1.5.0-dev 58390b6; execdriver: native-0.2; graphdriver: devicemapper"
Apr 06 20:24:21 ArchLinux docker[7333]: time="2015-04-06T20:24:21.212927536+05:30" level=info msg="+job acceptconnections()"
Apr 06 20:24:21 ArchLinux docker[7333]: time="2015-04-06T20:24:21.212979193+05:30" level=info msg="-job acceptconnections() OK"
Apr 06 20:24:21 ArchLinux docker[7333]: time="2015-04-06T20:24:21.223993507+05:30" level=info msg="Daemon has completed initialization"


Now pulling CentOS 7 from DockerHub registry to local machine.


bhaskar@ArchLinux_21:04:55_Mon Apr 06:~/Downloads/docker-git> docker pull centos:7
Pulling repository centos
2b8d6139a545: Download complete
511136ea3c5a: Download complete
5b12ef8fd570: Download complete
5c5681003a50: Download complete
Status: Downloaded newer image for centos:7


Now,here is some info about the docker environment:



bhaskar@ArchLinux_21:30:56_Mon Apr 06:~/Downloads/docker-git> docker info
Containers: 3
Images: 4
Storage Driver: devicemapper
Pool Name: docker-8:1-163302-pool
Pool Blocksize: 65.54 kB
Backing Filesystem: extfs
Data file: /dev/loop0
Metadata file: /dev/loop1
Data Space Used: 567.5 MB
Data Space Total: 107.4 GB
Data Space Available: 3.412 GB
Metadata Space Used: 1.081 MB
Metadata Space Total: 2.147 GB
Metadata Space Available: 2.146 GB
Udev Sync Supported: true
Data loop file: /var/lib/docker/devicemapper/devicemapper/data
Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
Library Version: 1.02.93 (2015-01-30)
Execution Driver: native-0.2
Kernel Version: 3.19.2-1-ARCH
Operating System: Arch Linux
CPUs: 4
Total Memory: -2.147e+09 B
Name: ArchLinux
ID: LST5:5QDH:OO7W:F24Z:DSM7:2RLW:SMZM:2EJX:MABR:AT2C:J6LR:KIQE
WARNING: No swap limit support



Cool!!