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.

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

May be interested

  • Commit in GitPhoto of Commit in Git
    jerry commits (deposits) the changes and he wants to correct them for his recent commits. in this case, the function git commit -a will help do this. this function changes the last commit including your commit message; it creates a new commit id.
  • Push operation in HTMLPhoto of Push operation in HTML
    jerry modifies the previous commits using the git commit -a operation (signing changes) and he is ready to push the changes. push operation saves permanent data to git repository. after a successful push operation, other programmers can observe jerry's changes.
  • Update activity in GitPhoto of Update activity in Git
    tom performs the simulation operation and sees a new file string.c. he wants to know who added this file to the repository and for what purpose, so he runs the git log command.
  • Stash operation in GitPhoto of Stash operation in Git
    suppose you are implementing a new feature of your product. your code is in progress, suddenly a visitor. because of this, you have to go out for a few hours. you cannot commit this code and cannot throw it away at your changes. so you need some temporary space, where you can keep these local changes and then return to commit it.
  • Online Repository in GitPhoto of Online Repository in Git
    github is a social network for programmers for software development projects using git revision management system. it also has a standard gui application for direct download (windows, mac, gnu / linux) to your computer from web sites. but in this tutorial, we only consider the cli section.
  • Operating Rename in GitPhoto of Operating Rename in Git
    so far, both tom and jerry are using manual commands to compile their projects. now, jerry decided to create a makefile for the project and also put a name for the file string.c.