Skip to content
Open

Help #10

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
all: git-help

git-help: git-help.o

.PHONY: clean
clean:
-rm -f git-help git-help.o
35 changes: 20 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
# Welcome the git tutorial Introduction!
This tutorial aims to teach you how to use `git` in an efficient manner for
your projects. This guide does not focus on `git` commands, but rather on
the things you need to do in order to write code in an easy to maintain
fashion.
# Welcome the git help tutorial!
The `git-help` tool found in this repository can be ran to find out more
information about git commands.

## Identity
When using `git` for the first time, the first step you need to do is to
identify yourself, so that whoever is interested in the portion of code you
wrote, they can easily reach you for further questions. In order to identify
yourself, you need to specify your name and email address to the `git` engine.
This is intuitively done using the `git config` command:
## Compile
You can compile the program using the `Makefile` in this project:
```
git config --global user.name "YOUR NAME"
git config --global user.email "YOUR@EMAIL.ADDRESS"
make
```
will generate the `git-help` executable.

## Usage
When ran without parameters, the program returns the man page of the main git
command:
```
./git-help
```

The program can also receive a parameter that indicates which command we want
to get more information about:
```
./git-help commit
```
Run these commands on your local computer; make sure you use a valid name and
email address!
41 changes: 41 additions & 0 deletions git-help.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
char *cmd;
if (argc > 2) {
fprintf(stderr, "Usage: %s [command]\n", argv[0]);
exit(-1);
}

if (argc == 1)
system("man git");
else {
cmd = malloc(9 + strlen(argv[argc]));
if (!cmd) {
fprintf(stderr, "not enought memory to create command!\n");
exit(-1);
}
strcpy(cmd, "man git-");
strcat(cmd, argv[argc]);
system(cmd);
}

return 0;
}