Review changes in Git

After rechecking the deposit details, Jerry realizes that the string length cannot be negative, so he decides to change the type of my_strlen function.

After rechecking the deposit details, Jerry realizes that the string length cannot be negative, so he decides to change the type of my_strlen function.

Jerry uses the git log command to observe the log details.

 [jerry @ CentOS project] $ git log 

The above command will produce the following result:

 commit cbe1249b140dad24b2c35b15cc7e26a6f02d2277 
Author: Jerry Mouse
Date: Wed Sep 11 08:05:26 2013 +0530

Implemented my_strlen function

Jerry uses the git show command to check the deposit details. Git specifies the command to be taken from the SHA-1 deposit ID as a parameter.

 [jerry @ CentOS project] $ git show cbe1249b140dad24b2c35b15cc7e26a6f02d2277 

The above command will produce the following result:

 commit cbe1249b140dad24b2c35b15cc7e26a6f02d2277 
Author: Jerry Mouse
Date: Wed Sep 11 08:05:26 2013 +0530

Implemented my_strlen function


diff --git a / string.cb / string.c
new file mode 100644
index 0000000.187afb9
--- / dev / null
+++ b / string.c
@@ -0,0 +1,24 @@
+ # include
+
+ int my_strlen (char * s)
+ {
+
char * p = s;
+
+
while (* p)
+ ++ p;
+ return (p -s);
+
}
+

He changes the type of function from int to size_t. After checking the code, he reviews the changes by running git diff.

 [jerry @ CentOS project] $ git diff 

The above command will produce the following result:

 diff --git a / string.cb / string.c 
index 187afb9.7da2992 100644
--- a / string.c
+++ b / string.c
@@ -1,6 +1,6 @@
#include

-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 =% dn", s [i], my_strlen (s [i]));
+ printf ("string lenght of% s =% lun", s [i], my_strlen (s [i]));
return 0;
}

Git diff indicates the '+' symbol before the lines that add new and adds '-' to the deleted lines.

According to Tutorialspoint

Previous article: Make changes in Git

Next article: Commit in Git

4 ★ | 1 Vote