分类: LINUX
2013-02-05 16:31:36
description Linus' kernel tree owner Linus Torvalds last change Sun, 19 Apr 2009 17:58:20 +0000 URL git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git使用git工具下载内核源代码时,可以使用git://... 的URL和 的URL,两者只是服务端口不一样而已,git的服务端口是9418。其它两者具体没有什么太大区别,主要有些公司或是个人网络可能会封闭一些不太用的端口。下面是使用git下载源代码的过程。
helight@Zhwen:linux$git-clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git Initialized empty Git repository in /home/helight/linux-2.6/.git/ remote: Counting objects: 1171309, done. remote: Compressing objects: 100% (189000/189000), done. Receiving objects: 0% (732/1171309), 275.99 KiB | 8 KiB/s ...
helight@Zhwen:linux-2.6$ git-pull remote: Counting objects: 522, done. remote: Compressing objects: 100% (68/68), done. remote: Total 325 (delta 260), reused 320 (delta 255) Receiving objects: 100% (325/325), 47.61 KiB | 10 KiB/s, done. Resolving deltas: 100% (260/260), completed with 90 local objects. From git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6 aefe647..d91dfbb master -> origin/master Updating aefe647..d91dfbb Fast forward .gitignore | 1 + Documentation/kbuild/makefiles.txt | 10 ++ Documentation/kernel-parameters.txt | 38 +++++++ Documentation/lguest/.gitignore | 1 + Documentation/lguest/lguest.txt | 11 +- MAINTAINERS | 5 + Makefile | 2 +- arch/x86/include/asm/lguest_hcall.h | 2 +- arch/x86/lguest/boot.c | 16 ++-- ... 50 files changed, 602 insertions(+), 388 deletions(-) create mode 100644 Documentation/lguest/.gitignore helight@Zhwen:linux-2.6$这里要注意的是:每次要更新都要在master分支上进行更新,以保证更新不会发生混乱。在master分支上更新之后再创建新的分支。
helight@Zhwen:linux-2.6$ git-branch * master helight@Zhwen:linux-2.6$刚刚下载的内核代码树只有一个分支就是“master”,这个分支我们一般不做修改,我们做的所有修改都是在自己新建的分支上,然后再针对于“master”分支作补丁。所以这个分支一般情况下最好不要修改。
helight@Zhwen:linux-2.6$ git-branch helight helight@Zhwen:linux-2.6$ git-branch helight * master helight@Zhwen:linux-2.6$这里可以看出在master这个分支的前面有一个“*”号,这表示但前我们工作在master这个分支上,就是说我们这个时候对内核代码做的所有修改都记录保存在这个分支的数据库中。但是前面已经说过了这个分支上最好不要作修改。
helight@Zhwen:linux-2.6$ git-branch xxx helight@Zhwen:linux-2.6$ git-branch helight * master xxx helight@Zhwen:linux-2.6$ git-branch -D xxx Deleted branch xux. helight@Zhwen:linux-2.6$ git-branch helight * master helight@Zhwen:linux-2.6$这个主要是用于删除不需要的分支。
helight@Zhwen:linux-2.6$ git-checkout helight Switched to branch "helight" helight@Zhwen:linux-2.6$ git-branch * helight master helight@Zhwen:linux-2.6$切换分支后可以看到在你切换后的分支标签前面就会出现“*”号。
helight@Zhwen:linux-2.6$ vim samples/tracepoints/tracepoint-sample.c helight@Zhwen:linux-2.6$ git-commit -m "clean up code style on samples/tracepoints/tracepoint-sample.c" ./* Created commit 048f96f: clean up code style on samples/tracepoints/tracepoint-sample.c 1 files changed, 1 insertions(+), 2 deletions(-) helight@Zhwen:linux-2.6$提交之后可以看出其改变的文件个数和行术等信息。接下来就是制作补丁了。
helight@Zhwen:linux-2.6$ git-format-patch master 0001-clean-up-code-style-on-samples-tracepoints-tracepoin.patch helight@Zhwen:linux-2.6$ cat 0001-clean-up-code-style-on-samples-tracepoints-tracepoin.patch From 048f96f08d2e1d3bb776560a7d1b34cf82e5ea1a Mon Sep 17 00:00:00 2001 From: Zhenwen Xu Date: Mon, 20 Apr 2009 16:07:00 +0800 Subject: [PATCH] clean up code style on samples/tracepoints/tracepoint-sample.c --- samples/tracepoints/tracepoint-sample.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/samples/tracepoints/tracepoint-sample.c b/samples/tracepoints/tracepoint-sample.c index 9cf80a1..7a3865c 100644 --- a/samples/tracepoints/tracepoint-sample.c +++ b/samples/tracepoints/tracepoint-sample.c @@ -35,8 +35,7 @@ static struct file_operations mark_ops = { static int __init sample_init(void) { printk(KERN_ALERT "sample init\n"); - pentry_sample = proc_create("tracepoint-sample", 0444, NULL, - &mark_ops); + pentry_sample = proc_create("tracepoint-sample", 0444, NULL, &mark_ops); if (!pentry_sample) return -EPERM; return 0; -- 1.5.6.5 helight@Zhwen:linux-2.6$这个工具制作的补丁中一般不加“ Signed-off-by”这个标签,这个标签是标识这个补丁是誰发的或是誰转发的。这个不加也可能是我的git配置的问题。所以一般我是手动添加的,如果谁知道怎么可以自动添加请告诉我一下。
helight@Zhwen:linux-2.6$ vim 0001-clean-up-code-style-on-samples-tracepoints-tracepoin.patch helight@Zhwen:linux-2.6$ cat 0001-clean-up-code-style-on-samples-tracepoints-tracepoin.patch Signed-off-by: Zhenwen Xu --- samples/tracepoints/tracepoint-sample.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/samples/tracepoints/tracepoint-sample.c b/samples/tracepoints/tracepoint-sample.c index 9cf80a1..7a3865c 100644 --- a/samples/tracepoints/tracepoint-sample.c +++ b/samples/tracepoints/tracepoint-sample.c @@ -35,8 +35,7 @@ static struct file_operations mark_ops = { static int __init sample_init(void) { printk(KERN_ALERT "sample init\n"); - pentry_sample = proc_create("tracepoint-sample", 0444, NULL, - &mark_ops); + pentry_sample = proc_create("tracepoint-sample", 0444, NULL, &mark_ops); if (!pentry_sample) return -EPERM; return 0; -- 1.5.6.5 helight@Zhwen:linux-2.6$
helight@Zhwen:linux-2.6$ ./scripts/checkpatch.pl 0001-clean-up-code-style-on-samples-tracepoints-tracepoin.patch total: 0 errors, 0 warnings, 9 lines checked 0001-clean-up-code-style-on-samples-tracepoints-tracepoin.patch has no obvious style problems and is ready for submission. helight@Zhwen:linux-2.6$如果你认为你做的补丁有意义而且是正确的(这里只是为了演示,这个补丁并没有多大的实际意义,只是用于演示使用),而且也通过了这一步,那么你就可以发布你的补丁了。
补丁一般不要以附件发送,而是直接写到正文中。在修改原因等写完之后就附加补丁内容。在VIM中可以使用:r xxx.patch将补丁添加进邮件正文。(这里是说使用mutt来发送邮件)