Skip to content

Commit c44820c

Browse files
committed
A few formatting changes for rocco
I'm not too happy about manually inserting < and > but those get output as html tags otherwise.
1 parent 7612086 commit c44820c

File tree

4 files changed

+31
-8
lines changed

4 files changed

+31
-8
lines changed

examples/cat-file.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@ static void print_signature(const char *header, const git_signature *sig)
3131
sign, hours, minutes);
3232
}
3333

34+
/** Printint out a blob is simple, get the contents and print */
3435
static void show_blob(const git_blob *blob)
3536
{
3637
/* ? Does this need crlf filtering? */
3738
fwrite(git_blob_rawcontent(blob), git_blob_rawsize(blob), 1, stdout);
3839
}
3940

41+
/** Show each entry with its type, id and attributes */
4042
static void show_tree(const git_tree *tree)
4143
{
4244
size_t i, max_i = (int)git_tree_entrycount(tree);
@@ -55,6 +57,9 @@ static void show_tree(const git_tree *tree)
5557
}
5658
}
5759

60+
/**
61+
* Commits and tags have a few interesting fields in their header.
62+
*/
5863
static void show_commit(const git_commit *commit)
5964
{
6065
unsigned int i, max_i;
@@ -107,6 +112,7 @@ struct opts {
107112
static void parse_opts(struct opts *o, int argc, char *argv[]);
108113

109114

115+
/** Entry point for this command */
110116
int main(int argc, char *argv[])
111117
{
112118
git_repository *repo;
@@ -182,6 +188,7 @@ int main(int argc, char *argv[])
182188
return 0;
183189
}
184190

191+
/** Print out usage information */
185192
static void usage(const char *message, const char *arg)
186193
{
187194
if (message && arg)
@@ -194,6 +201,7 @@ static void usage(const char *message, const char *arg)
194201
exit(1);
195202
}
196203

204+
/** Parse the command-line options taken from git */
197205
static void parse_opts(struct opts *o, int argc, char *argv[])
198206
{
199207
struct args_info args = ARGS_INFO_INIT;

examples/diff.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ struct opts {
3838
const char *dir;
3939
};
4040

41+
/** These functions are implemented at the end */
4142
static void parse_opts(struct opts *o, int argc, char *argv[]);
4243
static int color_printer(
4344
const git_diff_delta*, const git_diff_hunk*, const git_diff_line*, void*);
@@ -62,13 +63,13 @@ int main(int argc, char *argv[])
6263
/**
6364
* Possible argument patterns:
6465
*
65-
* * <sha1> <sha2>
66-
* * <sha1> --cached
67-
* * <sha1>
66+
* * &lt;sha1&gt; &lt;sha2&gt;
67+
* * &lt;sha1&gt; --cached
68+
* * &lt;sha1&gt;
6869
* * --cached
6970
* * nothing
7071
*
71-
* Currently ranged arguments like <sha1>..<sha2> and <sha1>...<sha2>
72+
* Currently ranged arguments like &lt;sha1&gt;..&lt;sha2&gt; and &lt;sha1&gt;...&lt;sha2&gt;
7273
* are not supported in this example
7374
*/
7475

@@ -174,11 +175,11 @@ static int color_printer(
174175
return diff_output(delta, hunk, line, stdout);
175176
}
176177

178+
/** Parse arguments as copied from git-diff. */
177179
static void parse_opts(struct opts *o, int argc, char *argv[])
178180
{
179181
struct args_info args = ARGS_INFO_INIT;
180182

181-
/* Parse arguments as copied from git-diff. */
182183

183184
for (args.pos = 1; args.pos < argc; ++args.pos) {
184185
const char *a = argv[args.pos];

examples/network/fetch.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ static void *download(void *ptr)
4747
return &data->ret;
4848
}
4949

50+
/**
51+
* This function gets called for each remote-trackinb branch that gets
52+
* updated. The message we output depends on whether it's a new one or
53+
* an update.
54+
*/
5055
static int update_cb(const char *refname, const git_oid *a, const git_oid *b, void *data)
5156
{
5257
char a_str[GIT_OID_HEXSZ+1], b_str[GIT_OID_HEXSZ+1];
@@ -66,6 +71,7 @@ static int update_cb(const char *refname, const git_oid *a, const git_oid *b, vo
6671
return 0;
6772
}
6873

74+
/** Entry point for this command */
6975
int fetch(git_repository *repo, int argc, char **argv)
7076
{
7177
git_remote *remote = NULL;
@@ -130,6 +136,11 @@ int fetch(git_repository *repo, int argc, char **argv)
130136
pthread_join(worker, NULL);
131137
#endif
132138

139+
/**
140+
* If there are local objects (we got a thin pack), then tell
141+
* the use how many objets we saved from having to cross the
142+
* network.
143+
*/
133144
if (stats->local_objects > 0) {
134145
printf("\rReceived %d/%d objects in %zu bytes (used %d local objects)\n",
135146
stats->indexed_objects, stats->total_objects, stats->received_bytes, stats->local_objects);

examples/network/ls-remote.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <string.h>
55
#include "common.h"
66

7+
/** Callback to show each item */
78
static int show_ref__cb(git_remote_head *head, void *payload)
89
{
910
char oid[GIT_OID_HEXSZ + 1] = {0};
@@ -28,6 +29,10 @@ static int use_remote(git_repository *repo, char *name)
2829
goto cleanup;
2930
}
3031

32+
/**
33+
* Connect to the remote and call the printing function for
34+
* each of the remote references.
35+
*/
3136
callbacks.credentials = cred_acquire_cb;
3237
git_remote_set_callbacks(remote, &callbacks);
3338

@@ -42,9 +47,7 @@ static int use_remote(git_repository *repo, char *name)
4247
return error;
4348
}
4449

45-
// This gets called to do the work. The remote can be given either as
46-
// the name of a configured remote or an URL.
47-
50+
/** Entry point for this command */
4851
int ls_remote(git_repository *repo, int argc, char **argv)
4952
{
5053
int error;

0 commit comments

Comments
 (0)