Commit c44820c6 by Carlos Martín Nieto

A few formatting changes for rocco

I'm not too happy about manually inserting < and > but those get
output as html tags otherwise.
parent 76120863
...@@ -31,12 +31,14 @@ static void print_signature(const char *header, const git_signature *sig) ...@@ -31,12 +31,14 @@ static void print_signature(const char *header, const git_signature *sig)
sign, hours, minutes); sign, hours, minutes);
} }
/** Printint out a blob is simple, get the contents and print */
static void show_blob(const git_blob *blob) static void show_blob(const git_blob *blob)
{ {
/* ? Does this need crlf filtering? */ /* ? Does this need crlf filtering? */
fwrite(git_blob_rawcontent(blob), git_blob_rawsize(blob), 1, stdout); fwrite(git_blob_rawcontent(blob), git_blob_rawsize(blob), 1, stdout);
} }
/** Show each entry with its type, id and attributes */
static void show_tree(const git_tree *tree) static void show_tree(const git_tree *tree)
{ {
size_t i, max_i = (int)git_tree_entrycount(tree); size_t i, max_i = (int)git_tree_entrycount(tree);
...@@ -55,6 +57,9 @@ static void show_tree(const git_tree *tree) ...@@ -55,6 +57,9 @@ static void show_tree(const git_tree *tree)
} }
} }
/**
* Commits and tags have a few interesting fields in their header.
*/
static void show_commit(const git_commit *commit) static void show_commit(const git_commit *commit)
{ {
unsigned int i, max_i; unsigned int i, max_i;
...@@ -107,6 +112,7 @@ struct opts { ...@@ -107,6 +112,7 @@ struct opts {
static void parse_opts(struct opts *o, int argc, char *argv[]); static void parse_opts(struct opts *o, int argc, char *argv[]);
/** Entry point for this command */
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
git_repository *repo; git_repository *repo;
...@@ -182,6 +188,7 @@ int main(int argc, char *argv[]) ...@@ -182,6 +188,7 @@ int main(int argc, char *argv[])
return 0; return 0;
} }
/** Print out usage information */
static void usage(const char *message, const char *arg) static void usage(const char *message, const char *arg)
{ {
if (message && arg) if (message && arg)
...@@ -194,6 +201,7 @@ static void usage(const char *message, const char *arg) ...@@ -194,6 +201,7 @@ static void usage(const char *message, const char *arg)
exit(1); exit(1);
} }
/** Parse the command-line options taken from git */
static void parse_opts(struct opts *o, int argc, char *argv[]) static void parse_opts(struct opts *o, int argc, char *argv[])
{ {
struct args_info args = ARGS_INFO_INIT; struct args_info args = ARGS_INFO_INIT;
......
...@@ -38,6 +38,7 @@ struct opts { ...@@ -38,6 +38,7 @@ struct opts {
const char *dir; const char *dir;
}; };
/** These functions are implemented at the end */
static void parse_opts(struct opts *o, int argc, char *argv[]); static void parse_opts(struct opts *o, int argc, char *argv[]);
static int color_printer( static int color_printer(
const git_diff_delta*, const git_diff_hunk*, const git_diff_line*, void*); const git_diff_delta*, const git_diff_hunk*, const git_diff_line*, void*);
...@@ -62,13 +63,13 @@ int main(int argc, char *argv[]) ...@@ -62,13 +63,13 @@ int main(int argc, char *argv[])
/** /**
* Possible argument patterns: * Possible argument patterns:
* *
* * <sha1> <sha2> * * &lt;sha1&gt; &lt;sha2&gt;
* * <sha1> --cached * * &lt;sha1&gt; --cached
* * <sha1> * * &lt;sha1&gt;
* * --cached * * --cached
* * nothing * * nothing
* *
* Currently ranged arguments like <sha1>..<sha2> and <sha1>...<sha2> * Currently ranged arguments like &lt;sha1&gt;..&lt;sha2&gt; and &lt;sha1&gt;...&lt;sha2&gt;
* are not supported in this example * are not supported in this example
*/ */
...@@ -174,11 +175,11 @@ static int color_printer( ...@@ -174,11 +175,11 @@ static int color_printer(
return diff_output(delta, hunk, line, stdout); return diff_output(delta, hunk, line, stdout);
} }
/** Parse arguments as copied from git-diff. */
static void parse_opts(struct opts *o, int argc, char *argv[]) static void parse_opts(struct opts *o, int argc, char *argv[])
{ {
struct args_info args = ARGS_INFO_INIT; struct args_info args = ARGS_INFO_INIT;
/* Parse arguments as copied from git-diff. */
for (args.pos = 1; args.pos < argc; ++args.pos) { for (args.pos = 1; args.pos < argc; ++args.pos) {
const char *a = argv[args.pos]; const char *a = argv[args.pos];
......
...@@ -47,6 +47,11 @@ exit: ...@@ -47,6 +47,11 @@ exit:
return &data->ret; return &data->ret;
} }
/**
* This function gets called for each remote-trackinb branch that gets
* updated. The message we output depends on whether it's a new one or
* an update.
*/
static int update_cb(const char *refname, const git_oid *a, const git_oid *b, void *data) static int update_cb(const char *refname, const git_oid *a, const git_oid *b, void *data)
{ {
char a_str[GIT_OID_HEXSZ+1], b_str[GIT_OID_HEXSZ+1]; 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 ...@@ -66,6 +71,7 @@ static int update_cb(const char *refname, const git_oid *a, const git_oid *b, vo
return 0; return 0;
} }
/** Entry point for this command */
int fetch(git_repository *repo, int argc, char **argv) int fetch(git_repository *repo, int argc, char **argv)
{ {
git_remote *remote = NULL; git_remote *remote = NULL;
...@@ -130,6 +136,11 @@ int fetch(git_repository *repo, int argc, char **argv) ...@@ -130,6 +136,11 @@ int fetch(git_repository *repo, int argc, char **argv)
pthread_join(worker, NULL); pthread_join(worker, NULL);
#endif #endif
/**
* If there are local objects (we got a thin pack), then tell
* the use how many objets we saved from having to cross the
* network.
*/
if (stats->local_objects > 0) { if (stats->local_objects > 0) {
printf("\rReceived %d/%d objects in %zu bytes (used %d local objects)\n", printf("\rReceived %d/%d objects in %zu bytes (used %d local objects)\n",
stats->indexed_objects, stats->total_objects, stats->received_bytes, stats->local_objects); stats->indexed_objects, stats->total_objects, stats->received_bytes, stats->local_objects);
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <string.h> #include <string.h>
#include "common.h" #include "common.h"
/** Callback to show each item */
static int show_ref__cb(git_remote_head *head, void *payload) static int show_ref__cb(git_remote_head *head, void *payload)
{ {
char oid[GIT_OID_HEXSZ + 1] = {0}; char oid[GIT_OID_HEXSZ + 1] = {0};
...@@ -28,6 +29,10 @@ static int use_remote(git_repository *repo, char *name) ...@@ -28,6 +29,10 @@ static int use_remote(git_repository *repo, char *name)
goto cleanup; goto cleanup;
} }
/**
* Connect to the remote and call the printing function for
* each of the remote references.
*/
callbacks.credentials = cred_acquire_cb; callbacks.credentials = cred_acquire_cb;
git_remote_set_callbacks(remote, &callbacks); git_remote_set_callbacks(remote, &callbacks);
...@@ -42,9 +47,7 @@ cleanup: ...@@ -42,9 +47,7 @@ cleanup:
return error; return error;
} }
// This gets called to do the work. The remote can be given either as /** Entry point for this command */
// the name of a configured remote or an URL.
int ls_remote(git_repository *repo, int argc, char **argv) int ls_remote(git_repository *repo, int argc, char **argv)
{ {
int error; int error;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment