Merge branch 'lt/push-config' into next

* lt/push-config:
  git push: add verbose flag and allow overriding of default target repository
  Allow '-' in config variable names
  Move deny_non_fast_forwards handling completely into receive-pack.
  revision traversal: --unpacked does not limit commit list anymore.
  Continue traversal when rev-list --unpacked finds a packed commit.
  Use memmove instead of memcpy for overlapping areas
  Use memmove instead of memcpy for overlapping areas
  quote.c: ensure the same quoting across platforms.
  Surround "#define DEBUG 0" with "#ifndef DEBUG..#endif"
This commit is contained in:
Junio C Hamano
2006-10-30 19:46:24 -08:00
12 changed files with 52 additions and 22 deletions

View File

@@ -19,7 +19,9 @@
#include "xdiff-interface.h"
#include "quote.h"
#ifndef DEBUG
#define DEBUG 0
#endif
static const char blame_usage[] =
"git-blame [-c] [-l] [-t] [-f] [-n] [-p] [-S <revs-file>] [--] file [commit]\n"
@@ -232,6 +234,9 @@ static void print_map(struct commit *cmit, struct commit *other)
util2->num_lines ? util->num_lines : util2->num_lines;
int num;
if (print_map == NULL)
; /* to avoid "unused function" warning */
for (i = 0; i < max; i++) {
printf("i: %d ", i);
num = -1;

View File

@@ -10,7 +10,7 @@
static const char push_usage[] = "git-push [--all] [--tags] [-f | --force] <repository> [<refspec>...]";
static int all, tags, force, thin = 1;
static int all, tags, force, thin = 1, verbose;
static const char *execute;
#define BUF_SIZE (2084)
@@ -248,6 +248,8 @@ static int do_push(const char *repo)
while (dest_refspec_nr--)
argv[dest_argc++] = *dest_refspec++;
argv[dest_argc] = NULL;
if (verbose)
fprintf(stderr, "Pushing to %s\n", dest);
err = run_command_v(argc, argv);
if (!err)
continue;
@@ -281,6 +283,14 @@ int cmd_push(int argc, const char **argv, const char *prefix)
i++;
break;
}
if (!strcmp(arg, "-v")) {
verbose=1;
continue;
}
if (!strncmp(arg, "--repo=", 7)) {
repo = arg+7;
continue;
}
if (!strcmp(arg, "--all")) {
all = 1;
continue;

View File

@@ -22,7 +22,7 @@ static SHA_CTX ctx;
* Make sure at least "min" bytes are available in the buffer, and
* return the pointer to the buffer.
*/
static void * fill(int min)
static void *fill(int min)
{
if (min <= len)
return buffer + offset;
@@ -30,7 +30,7 @@ static void * fill(int min)
die("cannot fill %d bytes", min);
if (offset) {
SHA1_Update(&ctx, buffer, offset);
memcpy(buffer, buffer + offset, len);
memmove(buffer, buffer + offset, len);
offset = 0;
}
do {

View File

@@ -2,7 +2,9 @@
#include "tree.h"
#include "cache-tree.h"
#ifndef DEBUG
#define DEBUG 0
#endif
struct cache_tree *cache_tree(void)
{

View File

@@ -189,7 +189,6 @@ extern int prefer_symlink_refs;
extern int log_all_ref_updates;
extern int warn_ambiguous_refs;
extern int shared_repository;
extern int deny_non_fast_forwards;
extern const char *apply_default_whitespace;
extern int zlib_compression_level;

View File

@@ -103,6 +103,11 @@ static char *parse_value(void)
}
}
static inline int iskeychar(int c)
{
return isalnum(c) || c == '-';
}
static int get_value(config_fn_t fn, char *name, unsigned int len)
{
int c;
@@ -113,7 +118,7 @@ static int get_value(config_fn_t fn, char *name, unsigned int len)
c = get_next_char();
if (c == EOF)
break;
if (!isalnum(c))
if (!iskeychar(c))
break;
name[len++] = tolower(c);
if (len >= MAXNAME)
@@ -181,7 +186,7 @@ static int get_base_var(char *name)
return baselen;
if (isspace(c))
return get_extended_base_var(name, baselen, c);
if (!isalnum(c) && c != '.')
if (!iskeychar(c) && c != '.')
return -1;
if (baselen > MAXNAME / 2)
return -1;
@@ -573,7 +578,7 @@ int git_config_set_multivar(const char* key, const char* value,
dot = 1;
/* Leave the extended basename untouched.. */
if (!dot || i > store.baselen) {
if (!isalnum(c) || (i == store.baselen+1 && !isalpha(c))) {
if (!iskeychar(c) || (i == store.baselen+1 && !isalpha(c))) {
fprintf(stderr, "invalid key: %s\n", key);
free(store.key);
ret = 1;

View File

@@ -20,7 +20,6 @@ int warn_ambiguous_refs = 1;
int repository_format_version;
char git_commit_encoding[MAX_ENCODING_LENGTH] = "utf-8";
int shared_repository = PERM_UMASK;
int deny_non_fast_forwards = 0;
const char *apply_default_whitespace;
int zlib_compression_level = Z_DEFAULT_COMPRESSION;
int pager_in_use;

View File

@@ -272,7 +272,7 @@ buffer_gets( buffer_t * b, char **s )
n = b->bytes - start;
if (n)
memcpy( b->buf, b->buf + start, n );
memmove(b->buf, b->buf + start, n);
b->offset -= start;
b->bytes = n;
start = 0;

View File

@@ -209,7 +209,7 @@ static int quote_c_style_counted(const char *name, int namelen,
if (!ch)
break;
if ((ch < ' ') || (ch == '"') || (ch == '\\') ||
(ch == 0177)) {
(ch >= 0177)) {
needquote = 1;
switch (ch) {
case '\a': EMITQ(); ch = 'a'; break;

View File

@@ -12,12 +12,26 @@ static const char *keep_packer[] = {
"index-pack", "--stdin", "--fix-thin", NULL
};
static int deny_non_fast_forwards = 0;
static int report_status;
static int keep_pack;
static char capabilities[] = "report-status keep-pack";
static int capabilities_sent;
static int receive_pack_config(const char *var, const char *value)
{
git_default_config(var, value);
if (strcmp(var, "receive.denynonfastforwards") == 0)
{
deny_non_fast_forwards = git_config_bool(var, value);
return 0;
}
return 0;
}
static int show_ref(const char *path, const unsigned char *sha1, int flag, void *cb_data)
{
if (capabilities_sent)
@@ -292,7 +306,7 @@ int main(int argc, char **argv)
die("'%s': unable to chdir or not a git archive", dir);
setup_ident();
git_config(git_default_config);
git_config(receive_pack_config);
write_head_info();

View File

@@ -418,9 +418,6 @@ static void limit_list(struct rev_info *revs)
if (revs->max_age != -1 && (commit->date < revs->max_age))
obj->flags |= UNINTERESTING;
if (revs->unpacked &&
has_sha1_pack(obj->sha1, revs->ignore_packed))
obj->flags |= UNINTERESTING;
add_parents_to_list(revs, commit, &list);
if (obj->flags & UNINTERESTING) {
mark_parents_uninteresting(commit);
@@ -1015,7 +1012,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
add_pending_object(revs, object, def);
}
if (revs->topo_order || revs->unpacked)
if (revs->topo_order)
revs->limited = 1;
if (revs->prune_data) {
@@ -1149,17 +1146,18 @@ struct commit *get_revision(struct rev_info *revs)
* that we'd otherwise have done in limit_list().
*/
if (!revs->limited) {
if ((revs->unpacked &&
has_sha1_pack(commit->object.sha1,
revs->ignore_packed)) ||
(revs->max_age != -1 &&
(commit->date < revs->max_age)))
if (revs->max_age != -1 &&
(commit->date < revs->max_age))
continue;
add_parents_to_list(revs, commit, &revs->commits);
}
if (commit->object.flags & SHOWN)
continue;
if (revs->unpacked && has_sha1_pack(commit->object.sha1,
revs->ignore_packed))
continue;
/* We want to show boundary commits only when their
* children are shown. When path-limiter is in effect,
* rewrite_parents() drops some commits from getting shown,

View File

@@ -244,8 +244,6 @@ int check_repository_format_version(const char *var, const char *value)
repository_format_version = git_config_int(var, value);
else if (strcmp(var, "core.sharedrepository") == 0)
shared_repository = git_config_perm(var, value);
else if (strcmp(var, "receive.denynonfastforwards") == 0)
deny_non_fast_forwards = git_config_bool(var, value);
return 0;
}