Git-review-changes

提供:Dev Guides
移動先:案内検索

Git-変更のレビュー

コミットの詳細を表示した後、Jerryは文字列の長さを負にできないことを認識しているため、my_strlen関数の戻り値の型を変更することにしました。

Jerryは git log コマンドを使用してログの詳細を表示します。

[jerry@CentOS project]$ git log

上記のコマンドは、次の結果を生成します。

commit cbe1249b140dad24b2c35b15cc7e26a6f02d2277
Author: Jerry Mouse <[email protected]>
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 <[email protected]>
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 diffでは、新しく追加される行の前に '+' 記号が表示され、削除された行には '-' が表示されます。