Skip to content

Commit 069b312

Browse files
committed
Add all git documentation for convenience
taken from 'git/technical/*'
1 parent 2309329 commit 069b312

31 files changed

+9044
-0
lines changed

doc/api-error-handling.txt

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
Error reporting in git
2+
======================
3+
4+
`die`, `usage`, `error`, and `warning` report errors of various
5+
kinds.
6+
7+
- `die` is for fatal application errors. It prints a message to
8+
the user and exits with status 128.
9+
10+
- `usage` is for errors in command line usage. After printing its
11+
message, it exits with status 129. (See also `usage_with_options`
12+
in the link:api-parse-options.html[parse-options API].)
13+
14+
- `error` is for non-fatal library errors. It prints a message
15+
to the user and returns -1 for convenience in signaling the error
16+
to the caller.
17+
18+
- `warning` is for reporting situations that probably should not
19+
occur but which the user (and Git) can continue to work around
20+
without running into too many problems. Like `error`, it
21+
returns -1 after reporting the situation to the caller.
22+
23+
Customizable error handlers
24+
---------------------------
25+
26+
The default behavior of `die` and `error` is to write a message to
27+
stderr and then exit or return as appropriate. This behavior can be
28+
overridden using `set_die_routine` and `set_error_routine`. For
29+
example, "git daemon" uses set_die_routine to write the reason `die`
30+
was called to syslog before exiting.
31+
32+
Library errors
33+
--------------
34+
35+
Functions return a negative integer on error. Details beyond that
36+
vary from function to function:
37+
38+
- Some functions return -1 for all errors. Others return a more
39+
specific value depending on how the caller might want to react
40+
to the error.
41+
42+
- Some functions report the error to stderr with `error`,
43+
while others leave that for the caller to do.
44+
45+
- errno is not meaningful on return from most functions (except
46+
for thin wrappers for system calls).
47+
48+
Check the function's API documentation to be sure.
49+
50+
Caller-handled errors
51+
---------------------
52+
53+
An increasing number of functions take a parameter 'struct strbuf *err'.
54+
On error, such functions append a message about what went wrong to the
55+
'err' strbuf. The message is meant to be complete enough to be passed
56+
to `die` or `error` as-is. For example:
57+
58+
if (ref_transaction_commit(transaction, &err))
59+
die("%s", err.buf);
60+
61+
The 'err' parameter will be untouched if no error occurred, so multiple
62+
function calls can be chained:
63+
64+
t = ref_transaction_begin(&err);
65+
if (!t ||
66+
ref_transaction_update(t, "HEAD", ..., &err) ||
67+
ret_transaction_commit(t, &err))
68+
die("%s", err.buf);
69+
70+
The 'err' parameter must be a pointer to a valid strbuf. To silence
71+
a message, pass a strbuf that is explicitly ignored:
72+
73+
if (thing_that_can_fail_in_an_ignorable_way(..., &err))
74+
/* This failure is okay. */
75+
strbuf_reset(&err);

doc/api-index-skel.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Git API Documents
2+
=================
3+
4+
Git has grown a set of internal API over time. This collection
5+
documents them.
6+
7+
////////////////////////////////////////////////////////////////
8+
// table of contents begin
9+
////////////////////////////////////////////////////////////////
10+
11+
////////////////////////////////////////////////////////////////
12+
// table of contents end
13+
////////////////////////////////////////////////////////////////

doc/api-index.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/sh
2+
3+
(
4+
c=////////////////////////////////////////////////////////////////
5+
skel=api-index-skel.txt
6+
sed -e '/^\/\/ table of contents begin/q' "$skel"
7+
echo "$c"
8+
9+
ls api-*.txt |
10+
while read filename
11+
do
12+
case "$filename" in
13+
api-index-skel.txt | api-index.txt) continue ;;
14+
esac
15+
title=$(sed -e 1q "$filename")
16+
html=${filename%.txt}.html
17+
echo "* link:$html[$title]"
18+
done
19+
echo "$c"
20+
sed -n -e '/^\/\/ table of contents end/,$p' "$skel"
21+
) >api-index.txt+
22+
23+
if test -f api-index.txt && cmp api-index.txt api-index.txt+ >/dev/null
24+
then
25+
rm -f api-index.txt+
26+
else
27+
mv api-index.txt+ api-index.txt
28+
fi

doc/api-merge.txt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
merge API
2+
=========
3+
4+
The merge API helps a program to reconcile two competing sets of
5+
improvements to some files (e.g., unregistered changes from the work
6+
tree versus changes involved in switching to a new branch), reporting
7+
conflicts if found. The library called through this API is
8+
responsible for a few things.
9+
10+
* determining which trees to merge (recursive ancestor consolidation);
11+
12+
* lining up corresponding files in the trees to be merged (rename
13+
detection, subtree shifting), reporting edge cases like add/add
14+
and rename/rename conflicts to the user;
15+
16+
* performing a three-way merge of corresponding files, taking
17+
path-specific merge drivers (specified in `.gitattributes`)
18+
into account.
19+
20+
Data structures
21+
---------------
22+
23+
* `mmbuffer_t`, `mmfile_t`
24+
25+
These store data usable for use by the xdiff backend, for writing and
26+
for reading, respectively. See `xdiff/xdiff.h` for the definitions
27+
and `diff.c` for examples.
28+
29+
* `struct ll_merge_options`
30+
31+
Check ll-merge.h for details.
32+
33+
Low-level (single file) merge
34+
-----------------------------
35+
36+
Check ll-merge.h for details.

0 commit comments

Comments
 (0)