Git Review Changes

Source: Internet
Author: User

However, after reviewing the submission details, the length of the string could not be negative, so he decided to change the return type of the My_strlen function.

Jerry uses the git log command to view the log information.

[[email protected] project]$ git log

The above command produces the following results.

Commit cbe1249b140dad24b2c35b15cc7e26a6f02d2277 Author:jerry Mouse <[email protected]> date:wed Sep 11 08:05:26 20 +0530 implemented My_strlen function

Jerry uses the git show command to see the details of the commit. The SHA-1 commit ID of the GIT show command as a parameter.

[[email protected] project]$ git show cbe1249b140dad24b2c35b15cc7e26a6f02d2277

The above command produces the following results.

Commit cbe1249b140dad24b2c35b15cc7e26a6f02d2277 Author:jerry Mouse <[email protected]> date:wed Sep 11 08:05:26 20 +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 @@ -0,0 #include <stdio.h> + +int My_strlen (char *s) +{+ char *p = s; + + while (*p) + ++p; + RETURN (p-s); +} +

He changed the return type of the function from int to size_t. after testing the code, he looks at its changes to run the git diff command.

[[email protected] project]$ git diff

The above command produces the following results.

Diff–git a/string.c b/string.c Index 187AFB9. 7da2992 100644-a/string.c + + + b/string.c @@ -1,6 +1,6 @@ -1,6 <stdio.h>-int my_strlen (char *s) +size_t my_str Len (char *s) {char *p = s; @@ -18,7 +18,7 @@ -18,7 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; }

The Git diff shows the + sign forward, which is newly added, and the display symbol is deleted.

PS: If you want to communicate with the industry technology Daniel, please add QQ Group (521249302) or pay attention to the public number (askharries), thank you!

Git Review Changes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.