Skip to content

Commit

Permalink
Merge branch 'lt/setup' into __/setup-n-mv
Browse files Browse the repository at this point in the history
This merges the new built-in calling convention code into Johannes's
builtin-mv topic in order to resolve their conflicts early on.

Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Junio C Hamano committed Jul 29, 2006
2 parents ac64a72 + a633fca commit 7061cf0
Show file tree
Hide file tree
Showing 60 changed files with 585 additions and 326 deletions.
13 changes: 12 additions & 1 deletion Documentation/git-daemon.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ SYNOPSIS
'git-daemon' [--verbose] [--syslog] [--inetd | --port=n] [--export-all]
[--timeout=n] [--init-timeout=n] [--strict-paths]
[--base-path=path] [--user-path | --user-path=path]
[directory...]
[--reuseaddr] [--detach] [--pid-file=file] [directory...]

DESCRIPTION
-----------
Expand Down Expand Up @@ -82,6 +82,17 @@ OPTIONS
--verbose::
Log details about the incoming connections and requested files.

--reuseaddr::
Use SO_REUSEADDR when binding the listening socket.
This allows the server to restart without waiting for
old connections to time out.

--detach::
Detach from the shell. Implies --syslog.

--pid-file=file::
Save the process id in 'file'.

<directory>::
A directory to add to the whitelist of allowed directories. Unless
--strict-paths is specified this will also include subdirectories
Expand Down
8 changes: 7 additions & 1 deletion Documentation/git-http-fetch.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ git-http-fetch - downloads a remote git repository via HTTP

SYNOPSIS
--------
'git-http-fetch' [-c] [-t] [-a] [-d] [-v] [-w filename] [--recover] <commit> <url>
'git-http-fetch' [-c] [-t] [-a] [-d] [-v] [-w filename] [--recover] [--stdin] <commit> <url>

DESCRIPTION
-----------
Expand All @@ -33,6 +33,12 @@ commit-id::
Writes the commit-id into the filename under $GIT_DIR/refs/<filename> on
the local end after the transfer is complete.

--stdin::
Instead of a commit id on the commandline (which is not expected in this
case), 'git-http-fetch' expects lines on stdin in the format

<commit-id>['\t'<filename-as-in--w>]

Author
------
Written by Linus Torvalds <torvalds@osdl.org>
Expand Down
6 changes: 6 additions & 0 deletions Documentation/git-local-fetch.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ OPTIONS
Writes the commit-id into the filename under $GIT_DIR/refs/<filename> on
the local end after the transfer is complete.

--stdin::
Instead of a commit id on the commandline (which is not expected in this
case), 'git-local-fetch' expects lines on stdin in the format

<commit-id>['\t'<filename-as-in--w>]

Author
------
Written by Junio C Hamano <junkio@cox.net>
Expand Down
12 changes: 11 additions & 1 deletion Documentation/git.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ git - the stupid content tracker

SYNOPSIS
--------
'git' [--version] [--exec-path[=GIT_EXEC_PATH]] [--help] COMMAND [ARGS]
'git' [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate]
[--bare] [--git-dir=GIT_DIR] [--help] COMMAND [ARGS]

DESCRIPTION
-----------
Expand Down Expand Up @@ -41,6 +42,15 @@ OPTIONS
environment variable. If no path is given 'git' will print
the current setting and then exit.

-p|--paginate::
Pipe all output into 'less' (or if set, $PAGER).

--git-dir=<path>::
Set the path to the repository. This can also be controlled by
setting the GIT_DIR environment variable.

--bare::
Same as --git-dir=`pwd`.

FURTHER DOCUMENTATION
---------------------
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,8 @@ $(SIMPLE_PROGRAMS) : git-%$X : %.o
$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
$(LIB_FILE) $(SIMPLE_LIB)

ssh-pull.o: ssh-fetch.c
ssh-push.o: ssh-upload.c
git-local-fetch$X: fetch.o
git-ssh-fetch$X: rsh.o fetch.o
git-ssh-upload$X: rsh.o
Expand Down
2 changes: 1 addition & 1 deletion blame.c
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ int main(int argc, const char **argv)
}


init_revisions(&rev);
init_revisions(&rev, setup_git_directory());
rev.remove_empty_trees = 1;
rev.topo_order = 1;
rev.prune_fn = simplify_commit;
Expand Down
3 changes: 1 addition & 2 deletions builtin-add.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,10 @@ static void fill_directory(struct dir_struct *dir, const char **pathspec)

static struct lock_file lock_file;

int cmd_add(int argc, const char **argv, char **envp)
int cmd_add(int argc, const char **argv, const char *prefix)
{
int i, newfd;
int verbose = 0, show_only = 0;
const char *prefix = setup_git_directory();
const char **pathspec;
struct dir_struct dir;

Expand Down
73 changes: 62 additions & 11 deletions builtin-apply.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ struct fragment {
struct patch {
char *new_name, *old_name, *def_name;
unsigned int old_mode, new_mode;
int is_rename, is_copy, is_new, is_delete, is_binary;
int is_rename, is_copy, is_new, is_delete, is_binary, is_reverse;
#define BINARY_DELTA_DEFLATED 1
#define BINARY_LITERAL_DEFLATED 2
unsigned long deflate_origlen;
Expand Down Expand Up @@ -1119,6 +1119,34 @@ static int parse_chunk(char *buffer, unsigned long size, struct patch *patch)
return offset + hdrsize + patchsize;
}

#define swap(a,b) myswap((a),(b),sizeof(a))

#define myswap(a, b, size) do { \
unsigned char mytmp[size]; \
memcpy(mytmp, &a, size); \
memcpy(&a, &b, size); \
memcpy(&b, mytmp, size); \
} while (0)

static void reverse_patches(struct patch *p)
{
for (; p; p = p->next) {
struct fragment *frag = p->fragments;

swap(p->new_name, p->old_name);
swap(p->new_mode, p->old_mode);
swap(p->is_new, p->is_delete);
swap(p->lines_added, p->lines_deleted);
swap(p->old_sha1_prefix, p->new_sha1_prefix);

for (; frag; frag = frag->next) {
swap(frag->newpos, frag->oldpos);
swap(frag->newlines, frag->oldlines);
}
p->is_reverse = !p->is_reverse;
}
}

static const char pluses[] = "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++";
static const char minuses[]= "----------------------------------------------------------------------";

Expand Down Expand Up @@ -1336,7 +1364,7 @@ static int apply_line(char *output, const char *patch, int plen)
}

static int apply_one_fragment(struct buffer_desc *desc, struct fragment *frag,
int inaccurate_eof)
int reverse, int inaccurate_eof)
{
int match_beginning, match_end;
char *buf = desc->buffer;
Expand All @@ -1350,6 +1378,7 @@ static int apply_one_fragment(struct buffer_desc *desc, struct fragment *frag,
int pos, lines;

while (size > 0) {
char first;
int len = linelen(patch, size);
int plen;

Expand All @@ -1366,16 +1395,23 @@ static int apply_one_fragment(struct buffer_desc *desc, struct fragment *frag,
plen = len-1;
if (len < size && patch[len] == '\\')
plen--;
switch (*patch) {
first = *patch;
if (reverse) {
if (first == '-')
first = '+';
else if (first == '+')
first = '-';
}
switch (first) {
case ' ':
case '-':
memcpy(old + oldsize, patch + 1, plen);
oldsize += plen;
if (*patch == '-')
if (first == '-')
break;
/* Fall-through for ' ' */
case '+':
if (*patch != '+' || !no_add)
if (first != '+' || !no_add)
newsize += apply_line(new + newsize, patch,
plen);
break;
Expand Down Expand Up @@ -1499,6 +1535,12 @@ static int apply_binary_fragment(struct buffer_desc *desc, struct patch *patch)
void *data;
void *result;

/* Binary patch is irreversible */
if (patch->is_reverse)
return error("cannot reverse-apply a binary patch to '%s'",
patch->new_name
? patch->new_name : patch->old_name);

data = inflate_it(fragment->patch, fragment->size,
patch->deflate_origlen);
if (!data)
Expand Down Expand Up @@ -1615,7 +1657,8 @@ static int apply_fragments(struct buffer_desc *desc, struct patch *patch)
return apply_binary(desc, patch);

while (frag) {
if (apply_one_fragment(desc, frag, patch->inaccurate_eof) < 0)
if (apply_one_fragment(desc, frag, patch->is_reverse,
patch->inaccurate_eof) < 0)
return error("patch failed: %s:%ld",
name, frag->oldpos);
frag = frag->next;
Expand Down Expand Up @@ -2142,7 +2185,8 @@ static int use_patch(struct patch *p)
return 1;
}

static int apply_patch(int fd, const char *filename, int inaccurate_eof)
static int apply_patch(int fd, const char *filename,
int reverse, int inaccurate_eof)
{
unsigned long offset, size;
char *buffer = read_patch_file(fd, &size);
Expand All @@ -2162,6 +2206,8 @@ static int apply_patch(int fd, const char *filename, int inaccurate_eof)
nr = parse_chunk(buffer + offset, size, patch);
if (nr < 0)
break;
if (reverse)
reverse_patches(patch);
if (use_patch(patch)) {
patch_stats(patch);
*listp = patch;
Expand Down Expand Up @@ -2222,10 +2268,11 @@ static int git_apply_config(const char *var, const char *value)
}


int cmd_apply(int argc, const char **argv, char **envp)
int cmd_apply(int argc, const char **argv, const char *prefix)
{
int i;
int read_stdin = 1;
int reverse = 0;
int inaccurate_eof = 0;

const char *whitespace_option = NULL;
Expand All @@ -2236,7 +2283,7 @@ int cmd_apply(int argc, const char **argv, char **envp)
int fd;

if (!strcmp(arg, "-")) {
apply_patch(0, "<stdin>", inaccurate_eof);
apply_patch(0, "<stdin>", reverse, inaccurate_eof);
read_stdin = 0;
continue;
}
Expand Down Expand Up @@ -2313,6 +2360,10 @@ int cmd_apply(int argc, const char **argv, char **envp)
parse_whitespace_option(arg + 13);
continue;
}
if (!strcmp(arg, "-R") || !strcmp(arg, "--reverse")) {
reverse = 1;
continue;
}
if (!strcmp(arg, "--inaccurate-eof")) {
inaccurate_eof = 1;
continue;
Expand All @@ -2333,12 +2384,12 @@ int cmd_apply(int argc, const char **argv, char **envp)
usage(apply_usage);
read_stdin = 0;
set_default_whitespace_mode(whitespace_option);
apply_patch(fd, arg, inaccurate_eof);
apply_patch(fd, arg, reverse, inaccurate_eof);
close(fd);
}
set_default_whitespace_mode(whitespace_option);
if (read_stdin)
apply_patch(0, "<stdin>", inaccurate_eof);
apply_patch(0, "<stdin>", reverse, inaccurate_eof);
if (whitespace_error) {
if (squelch_whitespace_errors &&
squelch_whitespace_errors < whitespace_error) {
Expand Down
3 changes: 1 addition & 2 deletions builtin-cat-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,14 @@ static int pprint_tag(const unsigned char *sha1, const char *buf, unsigned long
return 0;
}

int cmd_cat_file(int argc, const char **argv, char **envp)
int cmd_cat_file(int argc, const char **argv, const char *prefix)
{
unsigned char sha1[20];
char type[20];
void *buf;
unsigned long size;
int opt;

setup_git_directory();
git_config(git_default_config);
if (argc != 3)
usage("git-cat-file [-t|-s|-e|-p|<type>] <sha1>");
Expand Down
2 changes: 1 addition & 1 deletion builtin-check-ref-format.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "refs.h"
#include "builtin.h"

int cmd_check_ref_format(int argc, const char **argv, char **envp)
int cmd_check_ref_format(int argc, const char **argv, const char *prefix)
{
if (argc != 2)
usage("git check-ref-format refname");
Expand Down
4 changes: 1 addition & 3 deletions builtin-commit-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ static int new_parent(int idx)
return 1;
}

int cmd_commit_tree(int argc, const char **argv, char **envp)
int cmd_commit_tree(int argc, const char **argv, const char *prefix)
{
int i;
int parents = 0;
Expand All @@ -88,8 +88,6 @@ int cmd_commit_tree(int argc, const char **argv, char **envp)
unsigned int size;

setup_ident();
setup_git_directory();

git_config(git_default_config);

if (argc < 2)
Expand Down
2 changes: 1 addition & 1 deletion builtin-count.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static void count_objects(DIR *d, char *path, int len, int verbose,
}
}

int cmd_count_objects(int ac, const char **av, char **ep)
int cmd_count_objects(int ac, const char **av, const char *prefix)
{
int i;
int verbose = 0;
Expand Down
4 changes: 2 additions & 2 deletions builtin-diff-files.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ static const char diff_files_usage[] =
"git-diff-files [-q] [-0/-1/2/3 |-c|--cc] [<common diff options>] [<path>...]"
COMMON_DIFF_OPTIONS_HELP;

int cmd_diff_files(int argc, const char **argv, char **envp)
int cmd_diff_files(int argc, const char **argv, const char *prefix)
{
struct rev_info rev;
int silent = 0;

init_revisions(&rev, prefix);
git_config(git_default_config); /* no "diff" UI options */
init_revisions(&rev);
rev.abbrev = 0;

argc = setup_revisions(argc, argv, &rev, NULL);
Expand Down
4 changes: 2 additions & 2 deletions builtin-diff-index.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ static const char diff_cache_usage[] =
"[<common diff options>] <tree-ish> [<path>...]"
COMMON_DIFF_OPTIONS_HELP;

int cmd_diff_index(int argc, const char **argv, char **envp)
int cmd_diff_index(int argc, const char **argv, const char *prefix)
{
struct rev_info rev;
int cached = 0;
int i;

init_revisions(&rev, prefix);
git_config(git_default_config); /* no "diff" UI options */
init_revisions(&rev);
rev.abbrev = 0;

argc = setup_revisions(argc, argv, &rev, NULL);
Expand Down
3 changes: 1 addition & 2 deletions builtin-diff-stages.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,9 @@ static void diff_stages(int stage1, int stage2, const char **pathspec)
}
}

int cmd_diff_stages(int ac, const char **av, char **envp)
int cmd_diff_stages(int ac, const char **av, const char *prefix)
{
int stage1, stage2;
const char *prefix = setup_git_directory();
const char **pathspec = NULL;

git_config(git_default_config); /* no "diff" UI options */
Expand Down
Loading

0 comments on commit 7061cf0

Please sign in to comment.