码迷,mamicode.com
首页 > 其他好文 > 详细

Git 审查更改

时间:2016-11-02 01:32:16      阅读:194      评论:0      收藏:0      [点我收藏+]

标签:view   string   font   style   ++   sha-1   str   stdio.h   void   

但查看提交详细资料后,Jerry 实现字符串的长度不能为负数,所以他决定改变my_strlen函数的返回类型。

Jerry 使用git日志命令来查看日志信息。

[jerry@CentOS project]$ git log

上面的命令会产生以下结果。

commit cbe1249b140dad24b2c35b15cc7e26a6f02d2277 Author: Jerry Mouse <jerry@yiibai.com> Date: Wed Sep 11 08:05:26 2013 +0530 Implemented my_strlen function

Jerry 使用git show命令查看提交的细节。 Git的show命令的SHA-1提交ID作为参数

[jerry@CentOS project]$ git show cbe1249b140dad24b2c35b15cc7e26a6f02d2277

上面的命令会产生以下结果。

commit cbe1249b140dad24b2c35b15cc7e26a6f02d2277 Author: Jerry Mouse <jerry@yiibai.com> Date: Wed Sep 11 08:05:26 2013 +0530 Implemented my_strlen function diff –git a/string.c b/string.c new file mode 100644 index 0000000..187afb9 — /dev/null +++ b/string.c @@ -0,0 +1,24 @@ +#include <stdio.h> + +int my_strlen(char *s) +{ + char *p = s; + + while (*p) + ++p; + return (p -s ); +} +

他改变了函数的返回类型 从int 修改为 size_t。测试代码后,他查看其变化运行git diff命令。

[jerry@CentOS project]$ git diff

上面的命令会产生以下结果。

diff –git a/string.c b/string.c index 187afb9..7da2992 100644 — a/string.c +++ b/string.c @@ -1,6 +1,6 @@ #include <stdio.h> -int my_strlen(char *s) +size_t my_strlen(char *s) { char *p = s; @@ -18,7 +18,7 @@ int main(void) }; for (i = 0; i < 2; ++i) – printf(“string lenght of %s = %d/n”, s[i], my_strlen(s[i])); + printf(“string lenght of %s = %lu/n”, s[i], my_strlen(s[i])); return 0; }

Git 的差异显示+号前行,这是新增加的,并显示符号被删除。

 

PS:如果您想和业内技术大牛交流的话,请加qq群(521249302)或者关注微信公众 号(AskHarries),谢谢!

Git 审查更改

标签:view   string   font   style   ++   sha-1   str   stdio.h   void   

原文地址:http://www.cnblogs.com/kluan/p/6021350.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!