Browse Source
... to contain the RPM workaround. Signed-off-by: Junio C Hamano <junkio@cox.net>maint v0.99.9a
Junio C Hamano
19 years ago
197 changed files with 8143 additions and 1876 deletions
@ -0,0 +1,90 @@ |
|||||||
|
git-am(1) |
||||||
|
========= |
||||||
|
|
||||||
|
NAME |
||||||
|
---- |
||||||
|
git-am - Apply a series of patches in a mailbox |
||||||
|
|
||||||
|
|
||||||
|
SYNOPSIS |
||||||
|
-------- |
||||||
|
'git-am' [--signoff] [--dotest=<dir>] [--utf8] [--3way] <mbox>... |
||||||
|
'git-am' [--skip] |
||||||
|
|
||||||
|
DESCRIPTION |
||||||
|
----------- |
||||||
|
Splits mail messages in a mailbox into commit log message, |
||||||
|
authorship information and patches, and applies them to the |
||||||
|
current branch. |
||||||
|
|
||||||
|
OPTIONS |
||||||
|
------- |
||||||
|
--signoff:: |
||||||
|
Add `Signed-off-by:` line to the commit message, using |
||||||
|
the committer identity of yourself. |
||||||
|
|
||||||
|
--dotest=<dir>:: |
||||||
|
Instead of `.dotest` directory, use <dir> as a working |
||||||
|
area to store extracted patches. |
||||||
|
|
||||||
|
--utf8, --keep:: |
||||||
|
Pass `--utf8` and `--keep` flags to `git-mailinfo` (see |
||||||
|
gitlink:git-mailinfo[1]). |
||||||
|
|
||||||
|
--3way:: |
||||||
|
When the patch does not apply cleanly, fall back on |
||||||
|
3-way merge, if the patch records the identity of blobs |
||||||
|
it is supposed to apply to, and we have those blobs |
||||||
|
locally. |
||||||
|
|
||||||
|
--skip:: |
||||||
|
Skip the current patch. This is only meaningful when |
||||||
|
restarting an aborted patch. |
||||||
|
|
||||||
|
--interactive:: |
||||||
|
Run interactively, just like git-applymbox. |
||||||
|
|
||||||
|
|
||||||
|
DISCUSSION |
||||||
|
---------- |
||||||
|
|
||||||
|
When initially invoking it, you give it names of the mailboxes |
||||||
|
to crunch. Upon seeing the first patch that does not apply, it |
||||||
|
aborts in the middle, just like 'git-applymbox' does. You can |
||||||
|
recover from this in one of two ways: |
||||||
|
|
||||||
|
. skip the current one by re-running the command with '--skip' |
||||||
|
option. |
||||||
|
|
||||||
|
. hand resolve the conflict in the working directory, run 'git |
||||||
|
diff HEAD' to extract the merge result into a patch form and |
||||||
|
replacing the patch in .dotest/patch file. After doing this, |
||||||
|
run `git-reset --hard HEAD` to bring the working tree to the |
||||||
|
state before half-applying the patch, then re-run the command |
||||||
|
without any options. |
||||||
|
|
||||||
|
The command refuses to process new mailboxes while `.dotest` |
||||||
|
directory exists, so if you decide to start over from scratch, |
||||||
|
run `rm -f .dotest` before running the command with mailbox |
||||||
|
names. |
||||||
|
|
||||||
|
|
||||||
|
SEE ALSO |
||||||
|
-------- |
||||||
|
gitlink:git-applymbox[1], gitlink:git-applypatch[1]. |
||||||
|
|
||||||
|
|
||||||
|
Author |
||||||
|
------ |
||||||
|
Written by Junio C Hamano <junkio@cox.net> |
||||||
|
|
||||||
|
Documentation |
||||||
|
-------------- |
||||||
|
Documentation by Petr Baudis, Junio C Hamano and the git-list <git@vger.kernel.org>. |
||||||
|
|
||||||
|
This manual page is a stub. You can help the git documentation by expanding it. |
||||||
|
|
||||||
|
GIT |
||||||
|
--- |
||||||
|
Part of the gitlink:git[7] suite |
||||||
|
|
@ -0,0 +1,50 @@ |
|||||||
|
git-check-ref-format(1) |
||||||
|
======================= |
||||||
|
|
||||||
|
NAME |
||||||
|
---- |
||||||
|
git-check-ref-format - Make sure ref name is well formed. |
||||||
|
|
||||||
|
SYNOPSIS |
||||||
|
-------- |
||||||
|
'git-check-ref-format' <refname> |
||||||
|
|
||||||
|
DESCRIPTION |
||||||
|
----------- |
||||||
|
Checks if a given 'refname' is acceptable, and exits non-zero if |
||||||
|
it is not. |
||||||
|
|
||||||
|
A reference is used in git to specify branches and tags. A |
||||||
|
branch head is stored under `$GIT_DIR/refs/heads` directory, and |
||||||
|
a tag is stored under `$GIT_DIR/refs/tags` directory. git |
||||||
|
imposes the following rules on how refs are named: |
||||||
|
|
||||||
|
. It could be named hierarchically (i.e. separated with slash |
||||||
|
`/`), but each of its component cannot begin with a dot `.`; |
||||||
|
|
||||||
|
. It cannot have two consecutive dots `..` anywhere; |
||||||
|
|
||||||
|
. It cannot have ASCII control character (i.e. bytes whose |
||||||
|
values are lower than \040, or \177 `DEL`), space, tilde `~`, |
||||||
|
caret `{caret}`, or colon `:` anywhere; |
||||||
|
|
||||||
|
. It cannot end with a slash `/`. |
||||||
|
|
||||||
|
These rules makes it easy for shell script based tools to parse |
||||||
|
refnames, and also avoids ambiguities in certain refname |
||||||
|
expressions (see gitlink:git-rev-parse[1]). Namely: |
||||||
|
|
||||||
|
. double-dot `..` are often used as in `ref1..ref2`, and in some |
||||||
|
context this notation means `{caret}ref1 ref2` (i.e. not in |
||||||
|
ref1 and in ref2). |
||||||
|
|
||||||
|
. tilde `~` and caret `{caret}` are used to introduce postfix |
||||||
|
'nth parent' and 'peel onion' operation. |
||||||
|
|
||||||
|
. colon `:` is used as in `srcref:dstref` to mean "use srcref\'s |
||||||
|
value and store it in dstref" in fetch and push operations. |
||||||
|
|
||||||
|
|
||||||
|
GIT |
||||||
|
--- |
||||||
|
Part of the gitlink:git[7] suite |
@ -0,0 +1,44 @@ |
|||||||
|
git-index-pack(1) |
||||||
|
================= |
||||||
|
|
||||||
|
NAME |
||||||
|
---- |
||||||
|
git-index-pack - Build pack index file for an existing packed archive |
||||||
|
|
||||||
|
|
||||||
|
SYNOPSIS |
||||||
|
-------- |
||||||
|
'git-index-pack' [-o <index-file>] <pack-file> |
||||||
|
|
||||||
|
|
||||||
|
DESCRIPTION |
||||||
|
----------- |
||||||
|
Reads a packed archive (.pack) from the specified file, and |
||||||
|
builds a pack index file (.idx) for it. The packed archive |
||||||
|
together with the pack index can then be placed in the |
||||||
|
objects/pack/ directory of a git repository. |
||||||
|
|
||||||
|
|
||||||
|
OPTIONS |
||||||
|
------- |
||||||
|
-o <index-file>:: |
||||||
|
Write the generated pack index into the specified |
||||||
|
file. Without this option the name of pack index |
||||||
|
file is constructed from the name of packed archive |
||||||
|
file by replacing .pack with .idx (and the program |
||||||
|
fails if the name of packed archive does not end |
||||||
|
with .pack). |
||||||
|
|
||||||
|
|
||||||
|
Author |
||||||
|
------ |
||||||
|
Written by Sergey Vlasov <vsu@altlinux.ru> |
||||||
|
|
||||||
|
Documentation |
||||||
|
------------- |
||||||
|
Documentation by Sergey Vlasov |
||||||
|
|
||||||
|
GIT |
||||||
|
--- |
||||||
|
Part of the gitlink:git[7] suite |
||||||
|
|
@ -0,0 +1,51 @@ |
|||||||
|
git-mv(1) |
||||||
|
========= |
||||||
|
|
||||||
|
NAME |
||||||
|
---- |
||||||
|
git-mv - Script used to move or rename a file, directory or symlink. |
||||||
|
|
||||||
|
|
||||||
|
SYNOPSIS |
||||||
|
-------- |
||||||
|
'git-mv' [-f] [-n] <source> <destination> |
||||||
|
'git-mv' [-f] [-k] [-n] <source> ... <destination directory> |
||||||
|
|
||||||
|
DESCRIPTION |
||||||
|
----------- |
||||||
|
This script is used to move or rename a file, directory or symlink. |
||||||
|
In the first form, it renames <source>, which must exist and be either |
||||||
|
a file, symlink or directory, to <destination>, which must not exist. |
||||||
|
In the second form, the last argument has to be an existing |
||||||
|
directory; the given sources will be moved into this directory. |
||||||
|
|
||||||
|
The index is updated after successful completion, but the change must still be |
||||||
|
committed. |
||||||
|
|
||||||
|
OPTIONS |
||||||
|
------- |
||||||
|
-f:: |
||||||
|
Force renaming or moving even targets exist |
||||||
|
-k:: |
||||||
|
Skip move or rename actions which would lead to an error |
||||||
|
condition. An error happens when a source is neither existing nor |
||||||
|
controlled by GIT, or when it would overwrite an existing |
||||||
|
file unless '-f' is given. |
||||||
|
-n:: |
||||||
|
Do nothing; only show what would happen |
||||||
|
|
||||||
|
|
||||||
|
Author |
||||||
|
------ |
||||||
|
Written by Linus Torvalds <torvalds@osdl.org> |
||||||
|
Rewritten by Ryan Anderson <ryan@michonline.com> |
||||||
|
Move functionality added by Josef Weidendorfer <Josef.Weidendorfer@gmx.de> |
||||||
|
|
||||||
|
Documentation |
||||||
|
-------------- |
||||||
|
Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>. |
||||||
|
|
||||||
|
GIT |
||||||
|
--- |
||||||
|
Part of the gitlink:git[7] suite |
||||||
|
|
@ -0,0 +1,66 @@ |
|||||||
|
git-name-rev(1) |
||||||
|
=============== |
||||||
|
|
||||||
|
NAME |
||||||
|
---- |
||||||
|
git-name-rev - Find symbolic names for given revs. |
||||||
|
|
||||||
|
|
||||||
|
SYNOPSIS |
||||||
|
-------- |
||||||
|
'git-name-rev' [--tags] ( --all | --stdin | <commitish>... ) |
||||||
|
|
||||||
|
DESCRIPTION |
||||||
|
----------- |
||||||
|
Finds symbolic names suitable for human digestion for revisions given in any |
||||||
|
format parsable by git-rev-parse. |
||||||
|
|
||||||
|
|
||||||
|
OPTIONS |
||||||
|
------- |
||||||
|
|
||||||
|
--tags:: |
||||||
|
Do not use branch names, but only tags to name the commits |
||||||
|
|
||||||
|
--all:: |
||||||
|
List all commits reachable from all refs |
||||||
|
|
||||||
|
--stdin:: |
||||||
|
Read from stdin, append "(<rev_name>)" to all sha1's of name'able |
||||||
|
commits, and pass to stdout |
||||||
|
|
||||||
|
EXAMPLE |
||||||
|
------- |
||||||
|
|
||||||
|
Given a commit, find out where it is relative to the local refs. Say somebody |
||||||
|
wrote you about that phantastic commit 33db5f4d9027a10e477ccf054b2c1ab94f74c85a. |
||||||
|
Of course, you look into the commit, but that only tells you what happened, but |
||||||
|
not the context. |
||||||
|
|
||||||
|
Enter git-name-rev: |
||||||
|
|
||||||
|
------------ |
||||||
|
% git name-rev 33db5f4d9027a10e477ccf054b2c1ab94f74c85a |
||||||
|
------------ |
||||||
|
|
||||||
|
Now you are wiser, because you know that it happened 940 revisions before v0.99. |
||||||
|
|
||||||
|
Another nice thing you can do is: |
||||||
|
|
||||||
|
------------ |
||||||
|
% git log | git name-rev --stdin |
||||||
|
------------ |
||||||
|
|
||||||
|
|
||||||
|
Author |
||||||
|
------ |
||||||
|
Written by Johannes Schindelin <Johannes.Schindelin@gmx.de> |
||||||
|
|
||||||
|
Documentation |
||||||
|
-------------- |
||||||
|
Documentation by Johannes Schindelin. |
||||||
|
|
||||||
|
GIT |
||||||
|
--- |
||||||
|
Part of the gitlink:git[7] suite |
||||||
|
|
@ -0,0 +1,35 @@ |
|||||||
|
git-shell(1) |
||||||
|
============ |
||||||
|
|
||||||
|
NAME |
||||||
|
---- |
||||||
|
git-shell - Restricted login shell for GIT over SSH only |
||||||
|
|
||||||
|
|
||||||
|
SYNOPSIS |
||||||
|
-------- |
||||||
|
'git-shell -c <command> <argument>' |
||||||
|
|
||||||
|
DESCRIPTION |
||||||
|
----------- |
||||||
|
This is meant to be used as a login shell for SSH accounts you want |
||||||
|
to restrict to GIT pull/push access only. It permits execution only |
||||||
|
of server-side GIT commands implementing the pull/push functionality. |
||||||
|
The commands can be executed only by the '-c' option; the shell is not |
||||||
|
interactive. |
||||||
|
|
||||||
|
Currently, only the `git-receive-pack` and `git-upload-pack` commands |
||||||
|
are permitted to be called, with a single required argument. |
||||||
|
|
||||||
|
Author |
||||||
|
------ |
||||||
|
Written by Linus Torvalds <torvalds@osdl.org> |
||||||
|
|
||||||
|
Documentation |
||||||
|
-------------- |
||||||
|
Documentation by Petr Baudis and the git-list <git@vger.kernel.org>. |
||||||
|
|
||||||
|
GIT |
||||||
|
--- |
||||||
|
Part of the gitlink:git[7] suite |
||||||
|
|
@ -0,0 +1,137 @@ |
|||||||
|
git-svnimport(1) |
||||||
|
================ |
||||||
|
v0.1, July 2005 |
||||||
|
|
||||||
|
NAME |
||||||
|
---- |
||||||
|
git-svnimport - Import a SVN repository into git |
||||||
|
|
||||||
|
|
||||||
|
SYNOPSIS |
||||||
|
-------- |
||||||
|
'git-svnimport' [ -o <branch-for-HEAD> ] [ -h ] [ -v ] [ -d | -D ] |
||||||
|
[ -C <GIT_repository> ] [ -i ] [ -u ] [-l limit_nr_changes] |
||||||
|
[ -b branch_subdir ] [ -t trunk_subdir ] [ -T tag_subdir ] |
||||||
|
[ -s start_chg ] [ -m ] [ -M regex ] |
||||||
|
<SVN_repository_URL> [ <path> ] |
||||||
|
|
||||||
|
|
||||||
|
DESCRIPTION |
||||||
|
----------- |
||||||
|
Imports a SVN repository into git. It will either create a new |
||||||
|
repository, or incrementally import into an existing one. |
||||||
|
|
||||||
|
SVN access is done by the SVN:: Perl module. |
||||||
|
|
||||||
|
git-svnimport assumes that SVN repositories are organized into one |
||||||
|
"trunk" directory where the main development happens, "branch/FOO" |
||||||
|
directories for branches, and "/tags/FOO" directories for tags. |
||||||
|
Other subdirectories are ignored. |
||||||
|
|
||||||
|
git-svnimport creates a file ".git/svn2git", which is required for |
||||||
|
incremental SVN imports. |
||||||
|
|
||||||
|
OPTIONS |
||||||
|
------- |
||||||
|
-C <target-dir>:: |
||||||
|
The GIT repository to import to. If the directory doesn't |
||||||
|
exist, it will be created. Default is the current directory. |
||||||
|
|
||||||
|
-s <start_rev>:: |
||||||
|
Start importing at this SVN change number. The default is 1. |
||||||
|
+ |
||||||
|
When importing incementally, you might need to edit the .git/svn2git file. |
||||||
|
|
||||||
|
-i:: |
||||||
|
Import-only: don't perform a checkout after importing. This option |
||||||
|
ensures the working directory and cache remain untouched and will |
||||||
|
not create them if they do not exist. |
||||||
|
|
||||||
|
-t <trunk_subdir>:: |
||||||
|
Name the SVN trunk. Default "trunk". |
||||||
|
|
||||||
|
-T <tag_subdir>:: |
||||||
|
Name the SVN subdirectory for tags. Default "tags". |
||||||
|
|
||||||
|
-b <branch_subdir>:: |
||||||
|
Name the SVN subdirectory for branches. Default "branches". |
||||||
|
|
||||||
|
-o <branch-for-HEAD>:: |
||||||
|
The 'trunk' branch from SVN is imported to the 'origin' branch within |
||||||
|
the git repository. Use this option if you want to import into a |
||||||
|
different branch. |
||||||
|
|
||||||
|
-m:: |
||||||
|
Attempt to detect merges based on the commit message. This option |
||||||
|
will enable default regexes that try to capture the name source |
||||||
|
branch name from the commit message. |
||||||
|
|
||||||
|
-M <regex>:: |
||||||
|
Attempt to detect merges based on the commit message with a custom |
||||||
|
regex. It can be used with -m to also see the default regexes. |
||||||
|
You must escape forward slashes. |
||||||
|
|
||||||
|
-l <max_num_changes>:: |
||||||
|
Limit the number of SVN changesets we pull before quitting. |
||||||
|
This option is necessary because the SVN library has serious memory |
||||||
|
leaks; the recommended value for nontrivial imports is 100. |
||||||
|
|
||||||
|
git-svnimport will still exit with a zero exit code. You can check |
||||||
|
the size of the file ".git/svn2git" to determine whether to call |
||||||
|
the importer again. |
||||||
|
|
||||||
|
-v:: |
||||||
|
Verbosity: let 'svnimport' report what it is doing. |
||||||
|
|
||||||
|
-d:: |
||||||
|
Use direct HTTP requests if possible. The "<path>" argument is used |
||||||
|
only for retrieving the SVN logs; the path to the contents is |
||||||
|
included in the SVN log. |
||||||
|
|
||||||
|
-D:: |
||||||
|
Use direct HTTP requests if possible. The "<path>" argument is used |
||||||
|
for retrieving the logs, as well as for the contents. |
||||||
|
+ |
||||||
|
There's no safe way to automatically find out which of these options to |
||||||
|
use, so you need to try both. Usually, the one that's wrong will die |
||||||
|
with a 40x error pretty quickly. |
||||||
|
|
||||||
|
<SVN_repository_URL>:: |
||||||
|
The URL of the SVN module you want to import. For local |
||||||
|
repositories, use "file:///absolute/path". |
||||||
|
+ |
||||||
|
If you're using the "-d" or "-D" option, this is the URL of the SVN |
||||||
|
repository itself; it usually ends in "/svn". |
||||||
|
|
||||||
|
<SVN_repository_URL>:: |
||||||
|
The URL of the SVN module you want to import. For local |
||||||
|
repositories, use "file:///absolute/path". |
||||||
|
|
||||||
|
<path> |
||||||
|
The path to the module you want to check out. |
||||||
|
|
||||||
|
-h:: |
||||||
|
Print a short usage message and exit. |
||||||
|
|
||||||
|
OUTPUT |
||||||
|
------ |
||||||
|
If '-v' is specified, the script reports what it is doing. |
||||||
|
|
||||||
|
Otherwise, success is indicated the Unix way, i.e. by simply exiting with |
||||||
|
a zero exit status. |
||||||
|
|
||||||
|
Author |
||||||
|
------ |
||||||
|
Written by Matthias Urlichs <smurf@smurf.noris.de>, with help from |
||||||
|
various participants of the git-list <git@vger.kernel.org>. |
||||||
|
|
||||||
|
Based on a cvs2git script by the same author. |
||||||
|
|
||||||
|
Documentation |
||||||
|
-------------- |
||||||
|
Documentation by Matthias Urlichs <smurf@smurf.noris.de>. |
||||||
|
|
||||||
|
GIT |
||||||
|
--- |
||||||
|
Part of the gitlink:git[7] suite |
||||||
|
|
@ -0,0 +1,50 @@ |
|||||||
|
#include <stdio.h> |
||||||
|
#include <stdlib.h> |
||||||
|
#include <unistd.h> |
||||||
|
#include <errno.h> |
||||||
|
#include "../cache.h" |
||||||
|
|
||||||
|
void *gitfakemmap(void *start, size_t length, int prot , int flags, int fd, off_t offset) |
||||||
|
{ |
||||||
|
int n = 0; |
||||||
|
|
||||||
|
if (start != NULL || !(flags & MAP_PRIVATE)) |
||||||
|
die("Invalid usage of gitfakemmap."); |
||||||
|
|
||||||
|
if (lseek(fd, offset, SEEK_SET) < 0) { |
||||||
|
errno = EINVAL; |
||||||
|
return MAP_FAILED; |
||||||
|
} |
||||||
|
|
||||||
|
start = xmalloc(length); |
||||||
|
if (start == NULL) { |
||||||
|
errno = ENOMEM; |
||||||
|
return MAP_FAILED; |
||||||
|
} |
||||||
|
|
||||||
|
while (n < length) { |
||||||
|
int count = read(fd, start+n, length-n); |
||||||
|
|
||||||
|
if (count == 0) { |
||||||
|
memset(start+n, 0, length-n); |
||||||
|
break; |
||||||
|
} |
||||||
|
|
||||||
|
if (count < 0) { |
||||||
|
free(start); |
||||||
|
errno = EACCES; |
||||||
|
return MAP_FAILED; |
||||||
|
} |
||||||
|
|
||||||
|
n += count; |
||||||
|
} |
||||||
|
|
||||||
|
return start; |
||||||
|
} |
||||||
|
|
||||||
|
int gitfakemunmap(void *start, size_t length) |
||||||
|
{ |
||||||
|
free(start); |
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
@ -0,0 +1,236 @@ |
|||||||
|
|
||||||
|
#include "cache.h" |
||||||
|
|
||||||
|
#define MAXNAME (256) |
||||||
|
|
||||||
|
static FILE *config_file; |
||||||
|
static int config_linenr; |
||||||
|
static int get_next_char(void) |
||||||
|
{ |
||||||
|
int c; |
||||||
|
FILE *f; |
||||||
|
|
||||||
|
c = '\n'; |
||||||
|
if ((f = config_file) != NULL) { |
||||||
|
c = fgetc(f); |
||||||
|
if (c == '\n') |
||||||
|
config_linenr++; |
||||||
|
if (c == EOF) { |
||||||
|
config_file = NULL; |
||||||
|
c = '\n'; |
||||||
|
} |
||||||
|
} |
||||||
|
return c; |
||||||
|
} |
||||||
|
|
||||||
|
static char *parse_value(void) |
||||||
|
{ |
||||||
|
static char value[1024]; |
||||||
|
int quote = 0, comment = 0, len = 0, space = 0; |
||||||
|
|
||||||
|
for (;;) { |
||||||
|
int c = get_next_char(); |
||||||
|
if (len >= sizeof(value)) |
||||||
|
return NULL; |
||||||
|
if (c == '\n') { |
||||||
|
if (quote) |
||||||
|
return NULL; |
||||||
|
value[len] = 0; |
||||||
|
return value; |
||||||
|
} |
||||||
|
if (comment) |
||||||
|
continue; |
||||||
|
if (isspace(c) && !quote) { |
||||||
|
space = 1; |
||||||
|
continue; |
||||||
|
} |
||||||
|
if (space) { |
||||||
|
if (len) |
||||||
|
value[len++] = ' '; |
||||||
|
space = 0; |
||||||
|
} |
||||||
|
if (c == '\\') { |
||||||
|
c = get_next_char(); |
||||||
|
switch (c) { |
||||||
|
case '\n': |
||||||
|
continue; |
||||||
|
case 't': |
||||||
|
c = '\t'; |
||||||
|
break; |
||||||
|
case 'b': |
||||||
|
c = '\b'; |
||||||
|
break; |
||||||
|
case 'n': |
||||||
|
c = '\n'; |
||||||
|
break; |
||||||
|
/* Some characters escape as themselves */ |
||||||
|
case '\\': case '"': |
||||||
|
break; |
||||||
|
/* Reject unknown escape sequences */ |
||||||
|
default: |
||||||
|
return NULL; |
||||||
|
} |
||||||
|
value[len++] = c; |
||||||
|
continue; |
||||||
|
} |
||||||
|
if (c == '"') { |
||||||
|
quote = 1-quote; |
||||||
|
continue; |
||||||
|
} |
||||||
|
if (!quote) { |
||||||
|
if (c == ';' || c == '#') { |
||||||
|
comment = 1; |
||||||
|
continue; |
||||||
|
} |
||||||
|
} |
||||||
|
value[len++] = c; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
static int get_value(config_fn_t fn, char *name, unsigned int len) |
||||||
|
{ |
||||||
|
int c; |
||||||
|
char *value; |
||||||
|
|
||||||
|
/* Get the full name */ |
||||||
|
for (;;) { |
||||||
|
c = get_next_char(); |
||||||
|
if (c == EOF) |
||||||
|
break; |
||||||
|
if (!isalnum(c)) |
||||||
|
break; |
||||||
|
name[len++] = tolower(c); |
||||||
|
if (len >= MAXNAME) |
||||||
|
return -1; |
||||||
|
} |
||||||
|
name[len] = 0; |
||||||
|
while (c == ' ' || c == '\t') |
||||||
|
c = get_next_char(); |
||||||
|
|
||||||
|
value = NULL; |
||||||
|
if (c != '\n') { |
||||||
|
if (c != '=') |
||||||
|
return -1; |
||||||
|
value = parse_value(); |
||||||
|
if (!value) |
||||||
|
return -1; |
||||||
|
} |
||||||
|
return fn(name, value); |
||||||
|
} |
||||||
|
|
||||||
|
static int get_base_var(char *name) |
||||||
|
{ |
||||||
|
int baselen = 0; |
||||||
|
|
||||||
|
for (;;) { |
||||||
|
int c = get_next_char(); |
||||||
|
if (c == EOF) |
||||||
|
return -1; |
||||||
|
if (c == ']') |
||||||
|
return baselen; |
||||||
|
if (!isalnum(c)) |
||||||
|
return -1; |
||||||
|
if (baselen > MAXNAME / 2) |
||||||
|
return -1; |
||||||
|
name[baselen++] = tolower(c); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
static int git_parse_file(config_fn_t fn) |
||||||
|
{ |
||||||
|
int comment = 0; |
||||||
|
int baselen = 0; |
||||||
|
static char var[MAXNAME]; |
||||||
|
|
||||||
|
for (;;) { |
||||||
|
int c = get_next_char(); |
||||||
|
if (c == '\n') { |
||||||
|
/* EOF? */ |
||||||
|
if (!config_file) |
||||||
|
return 0; |
||||||
|
comment = 0; |
||||||
|
continue; |
||||||
|
} |
||||||
|
if (comment || isspace(c)) |
||||||
|
continue; |
||||||
|
if (c == '#' || c == ';') { |
||||||
|
comment = 1; |
||||||
|
continue; |
||||||
|
} |
||||||
|
if (c == '[') { |
||||||
|
baselen = get_base_var(var); |
||||||
|
if (baselen <= 0) |
||||||
|
break; |
||||||
|
var[baselen++] = '.'; |
||||||
|
var[baselen] = 0; |
||||||
|
continue; |
||||||
|
} |
||||||
|
if (!isalpha(c)) |
||||||
|
break; |
||||||
|
var[baselen] = tolower(c); |
||||||
|
if (get_value(fn, var, baselen+1) < 0) |
||||||
|
break; |
||||||
|
} |
||||||
|
die("bad config file line %d", config_linenr); |
||||||
|
} |
||||||
|
|
||||||
|
int git_config_int(const char *name, const char *value) |
||||||
|
{ |
||||||
|
if (value && *value) { |
||||||
|
char *end; |
||||||
|
int val = strtol(value, &end, 0); |
||||||
|
if (!*end) |
||||||
|
return val; |
||||||
|
} |
||||||
|
die("bad config value for '%s'", name); |
||||||
|
} |
||||||
|
|
||||||
|
int git_config_bool(const char *name, const char *value) |
||||||
|
{ |
||||||
|
if (!value) |
||||||
|
return 1; |
||||||
|
if (!*value) |
||||||
|
return 0; |
||||||
|
if (!strcasecmp(value, "true")) |
||||||
|
return 1; |
||||||
|
if (!strcasecmp(value, "false")) |
||||||
|
return 0; |
||||||
|
return git_config_int(name, value) != 0; |
||||||
|
} |
||||||
|
|
||||||
|
int git_default_config(const char *var, const char *value) |
||||||
|
{ |
||||||
|
/* This needs a better name */ |
||||||
|
if (!strcmp(var, "core.filemode")) { |
||||||
|
trust_executable_bit = git_config_bool(var, value); |
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
if (!strcmp(var, "user.name")) { |
||||||
|
strncpy(git_default_name, value, sizeof(git_default_name)); |
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
if (!strcmp(var, "user.email")) { |
||||||
|
strncpy(git_default_email, value, sizeof(git_default_email)); |
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
/* Add other config variables here.. */ |
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
int git_config(config_fn_t fn) |
||||||
|
{ |
||||||
|
int ret; |
||||||
|
FILE *f = fopen(git_path("config"), "r"); |
||||||
|
|
||||||
|
ret = -1; |
||||||
|
if (f) { |
||||||
|
config_file = f; |
||||||
|
config_linenr = 1; |
||||||
|
ret = git_parse_file(fn); |
||||||
|
fclose(f); |
||||||
|
} |
||||||
|
return ret; |
||||||
|
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue