Skip to content

Commit

Permalink
Merge branch 'maint'
Browse files Browse the repository at this point in the history
* maint: (35 commits)
  config.c: guard config parser from value=NULL
  builtin-log.c: guard config parser from value=NULL
  imap-send.c: guard config parser from value=NULL
  wt-status.c: guard config parser from value=NULL
  setup.c: guard config parser from value=NULL
  remote.c: guard config parser from value=NULL
  merge-recursive.c: guard config parser from value=NULL
  http.c: guard config parser from value=NULL
  help.c: guard config parser from value=NULL
  git.c: guard config parser from value=NULL
  diff.c: guard config parser from value=NULL
  convert.c: guard config parser from value=NULL
  connect.c: guard config parser from value=NULL
  builtin-tag.c: guard config parser from value=NULL
  builtin-show-branch.c: guard config parser from value=NULL
  builtin-reflog.c: guard config parser from value=NULL
  builtin-log.c: guard config parser from value=NULL
  builtin-config.c: guard config parser from value=NULL
  builtin-commit.c: guard config parser from value=NULL
  builtin-branch.c: guard config parser from value=NULL
  ...
  • Loading branch information
Junio C Hamano committed Feb 11, 2008
2 parents 94bf9f7 + 6c47d0e commit 04f32cf
Show file tree
Hide file tree
Showing 34 changed files with 255 additions and 59 deletions.
2 changes: 1 addition & 1 deletion Documentation/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ branch.autosetupmerge::
so that linkgit:git-pull[1] will appropriately merge from that
remote branch. Note that even if this option is not set,
this behavior can be chosen per-branch using the `--track`
and `--no-track` options. This option defaults to false.
and `--no-track` options. This option defaults to true.

branch.<name>.remote::
When in branch <name>, it tells `git fetch` which remote to fetch.
Expand Down
15 changes: 8 additions & 7 deletions Documentation/git-branch.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ Note that this will create the new branch, but it will not switch the
working tree to it; use "git checkout <newbranch>" to switch to the
new branch.

When a local branch is started off a remote branch, git can setup the
When a local branch is started off a remote branch, git sets up the
branch so that linkgit:git-pull[1] will appropriately merge from that
remote branch. If this behavior is desired, it is possible to make it
the default using the global `branch.autosetupmerge` configuration
flag. Otherwise, it can be chosen per-branch using the `--track`
remote branch. If this behavior is not desired, it is possible to
disable it using the global `branch.autosetupmerge` configuration
flag. That setting can be overridden by using the `--track`
and `--no-track` options.

With a '-m' or '-M' option, <oldbranch> will be renamed to <newbranch>.
Expand Down Expand Up @@ -108,10 +108,11 @@ OPTIONS
Set up configuration so that git-pull will automatically
retrieve data from the remote branch. Use this if you always
pull from the same remote branch into the new branch, or if you
don't want to use "git pull <repository> <refspec>" explicitly. Set the
branch.autosetupmerge configuration variable to true if you
don't want to use "git pull <repository> <refspec>" explicitly.
This behavior is the default. Set the
branch.autosetupmerge configuration variable to false if you
want git-checkout and git-branch to always behave as if
'--track' were given.
'--no-track' were given.

--no-track::
When a branch is created off a remote branch,
Expand Down
7 changes: 4 additions & 3 deletions Documentation/git-checkout.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ OPTIONS
set up configuration so that git-pull will automatically
retrieve data from the remote branch. Use this if you always
pull from the same remote branch into the new branch, or if you
don't want to use "git pull <repository> <refspec>" explicitly. Set the
branch.autosetupmerge configuration variable to true if you
don't want to use "git pull <repository> <refspec>" explicitly.
This behavior is the default. Set the
branch.autosetupmerge configuration variable to false if you
want git-checkout and git-branch to always behave as if
'--track' were given.
'--no-track' were given.

--no-track::
When -b is given and a branch is created off a remote branch,
Expand Down
10 changes: 5 additions & 5 deletions Documentation/git-pull.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ include::merge-strategies.txt[]
there is a remote ref for the upstream branch, and this branch
was rebased since last fetched, the rebase uses that information
to avoid rebasing non-local changes.

*NOTE:* This is a potentially _dangerous_ mode of operation.
It rewrites history, which does not bode well when you
published that history already. Do *not* use this option
unless you have read linkgit:git-rebase[1] carefully.
+
*NOTE:* This is a potentially _dangerous_ mode of operation.
It rewrites history, which does not bode well when you
published that history already. Do *not* use this option
unless you have read linkgit:git-rebase[1] carefully.

\--no-rebase::
Override earlier \--rebase.
Expand Down
2 changes: 1 addition & 1 deletion archive-tar.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ static void write_global_extended_header(const unsigned char *sha1)
static int git_tar_config(const char *var, const char *value)
{
if (!strcmp(var, "tar.umask")) {
if (!strcmp(value, "user")) {
if (value && !strcmp(value, "user")) {
tar_umask = umask(0);
umask(tar_umask);
} else {
Expand Down
2 changes: 2 additions & 0 deletions builtin-apply.c
Original file line number Diff line number Diff line change
Expand Up @@ -2746,6 +2746,8 @@ static int apply_patch(int fd, const char *filename, int inaccurate_eof)
static int git_apply_config(const char *var, const char *value)
{
if (!strcmp(var, "apply.whitespace")) {
if (!value)
return config_error_nonbool(var);
apply_default_whitespace = xstrdup(value);
return 0;
}
Expand Down
9 changes: 6 additions & 3 deletions builtin-branch.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,15 @@ static int git_branch_config(const char *var, const char *value)
}
if (!prefixcmp(var, "color.branch.")) {
int slot = parse_branch_color_slot(var, 13);
if (!value)
return config_error_nonbool(var);
color_parse(value, var, branch_colors[slot]);
return 0;
}
if (!strcmp(var, "branch.autosetupmerge"))
branch_track = git_config_bool(var, value);

if (!strcmp(var, "branch.autosetupmerge")) {
branch_track = git_config_bool(var, value);
return 0;
}
return git_default_config(var, value);
}

Expand Down
3 changes: 3 additions & 0 deletions builtin-commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,8 @@ static void print_summary(const char *prefix, const unsigned char *sha1)
int git_commit_config(const char *k, const char *v)
{
if (!strcmp(k, "commit.template")) {
if (!v)
return config_error_nonbool(v);
template_file = xstrdup(v);
return 0;
}
Expand Down Expand Up @@ -929,6 +931,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)

unlink(git_path("MERGE_HEAD"));
unlink(git_path("MERGE_MSG"));
unlink(git_path("SQUASH_MSG"));

if (commit_index_files())
die ("Repository has been updated, but unable to write\n"
Expand Down
2 changes: 2 additions & 0 deletions builtin-config.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ static char parsed_color[COLOR_MAXLEN];
static int git_get_color_config(const char *var, const char *value)
{
if (!strcmp(var, get_color_slot)) {
if (!value)
config_error_nonbool(var);
color_parse(value, var, parsed_color);
get_color_found = 1;
}
Expand Down
2 changes: 1 addition & 1 deletion builtin-gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static const char *argv_rerere[] = {"rerere", "gc", NULL};
static int gc_config(const char *var, const char *value)
{
if (!strcmp(var, "gc.packrefs")) {
if (!strcmp(value, "notbare"))
if (value && !strcmp(value, "notbare"))
pack_refs = -1;
else
pack_refs = git_config_bool(var, value);
Expand Down
7 changes: 3 additions & 4 deletions builtin-log.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ static int git_log_config(const char *var, const char *value)
{
if (!strcmp(var, "format.subjectprefix")) {
if (!value)
die("format.subjectprefix without value");
config_error_nonbool(var);
fmt_patch_subject_prefix = xstrdup(value);
return 0;
}
Expand Down Expand Up @@ -432,19 +432,18 @@ static int git_format_config(const char *var, const char *value)
}
if (!strcmp(var, "format.suffix")) {
if (!value)
die("format.suffix without value");
return config_error_nonbool(var);
fmt_patch_suffix = xstrdup(value);
return 0;
}
if (!strcmp(var, "diff.color") || !strcmp(var, "color.diff")) {
return 0;
}
if (!strcmp(var, "format.numbered")) {
if (!strcasecmp(value, "auto")) {
if (value && !strcasecmp(value, "auto")) {
auto_number = 1;
return 0;
}

numbered = git_config_bool(var, value);
return 0;
}
Expand Down
13 changes: 11 additions & 2 deletions builtin-pack-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -1464,7 +1464,7 @@ static unsigned int check_delta_limit(struct object_entry *me, unsigned int n)
return m;
}

static unsigned long free_unpacked(struct unpacked *n)
static unsigned long free_unpacked_data(struct unpacked *n)
{
unsigned long freed_mem = sizeof_delta_index(n->index);
free_delta_index(n->index);
Expand All @@ -1474,6 +1474,12 @@ static unsigned long free_unpacked(struct unpacked *n)
free(n->data);
n->data = NULL;
}
return freed_mem;
}

static unsigned long free_unpacked(struct unpacked *n)
{
unsigned long freed_mem = free_unpacked_data(n);
n->entry = NULL;
n->depth = 0;
return freed_mem;
Expand Down Expand Up @@ -1514,7 +1520,7 @@ static void find_deltas(struct object_entry **list, unsigned *list_size,
mem_usage > window_memory_limit &&
count > 1) {
uint32_t tail = (idx + window - count) % window;
mem_usage -= free_unpacked(array + tail);
mem_usage -= free_unpacked_data(array + tail);
count--;
}

Expand Down Expand Up @@ -1547,6 +1553,9 @@ static void find_deltas(struct object_entry **list, unsigned *list_size,
if (!m->entry)
break;
ret = try_delta(n, m, max_depth, &mem_usage);
if (window_memory_limit &&
mem_usage > window_memory_limit)
mem_usage -= free_unpacked_data(m);
if (ret < 0)
break;
else if (ret > 0)
Expand Down
39 changes: 39 additions & 0 deletions builtin-prune.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,44 @@ static void prune_object_dir(const char *path)
}
}

/*
* Write errors (particularly out of space) can result in
* failed temporary packs (and more rarely indexes and other
* files begining with "tmp_") accumulating in the
* object directory.
*/
static void remove_temporary_files(void)
{
DIR *dir;
struct dirent *de;
char* dirname=get_object_directory();

dir = opendir(dirname);
if (!dir) {
fprintf(stderr, "Unable to open object directory %s\n",
dirname);
return;
}
while ((de = readdir(dir)) != NULL) {
if (!prefixcmp(de->d_name, "tmp_")) {
char name[PATH_MAX];
int c = snprintf(name, PATH_MAX, "%s/%s",
dirname, de->d_name);
if (c < 0 || c >= PATH_MAX)
continue;
if (expire) {
struct stat st;
if (stat(name, &st) != 0 || st.st_mtime >= expire)
continue;
}
printf("Removing stale temporary file %s\n", name);
if (!show_only)
unlink(name);
}
}
closedir(dir);
}

int cmd_prune(int argc, const char **argv, const char *prefix)
{
int i;
Expand Down Expand Up @@ -115,5 +153,6 @@ int cmd_prune(int argc, const char **argv, const char *prefix)

sync();
prune_packed_objects(show_only);
remove_temporary_files();
return 0;
}
16 changes: 11 additions & 5 deletions builtin-reflog.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,19 @@ static int collect_reflog(const char *ref, const unsigned char *sha1, int unused

static int reflog_expire_config(const char *var, const char *value)
{
if (!strcmp(var, "gc.reflogexpire"))
if (!strcmp(var, "gc.reflogexpire")) {
if (!value)
config_error_nonbool(var);
default_reflog_expire = approxidate(value);
else if (!strcmp(var, "gc.reflogexpireunreachable"))
return 0;
}
if (!strcmp(var, "gc.reflogexpireunreachable")) {
if (!value)
config_error_nonbool(var);
default_reflog_expire_unreachable = approxidate(value);
else
return git_default_config(var, value);
return 0;
return 0;
}
return git_default_config(var, value);
}

static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
Expand Down
2 changes: 2 additions & 0 deletions builtin-show-branch.c
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,8 @@ static void append_one_rev(const char *av)
static int git_show_branch_config(const char *var, const char *value)
{
if (!strcmp(var, "showbranch.default")) {
if (!value)
return config_error_nonbool(var);
if (default_alloc <= default_num + 1) {
default_alloc = default_alloc * 3 / 2 + 20;
default_arg = xrealloc(default_arg, sizeof *default_arg * default_alloc);
Expand Down
2 changes: 1 addition & 1 deletion builtin-tag.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ static int git_tag_config(const char *var, const char *value)
{
if (!strcmp(var, "user.signingkey")) {
if (!value)
die("user.signingkey without value");
return config_error_nonbool(value);
set_signingkey(value);
return 0;
}
Expand Down
1 change: 1 addition & 0 deletions cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@ extern int git_config_set_multivar(const char *, const char *, const char *, int
extern int git_config_rename_section(const char *, const char *);
extern const char *git_etc_gitconfig(void);
extern int check_repository_format_version(const char *var, const char *value);
extern int config_error_nonbool(const char *);

#define MAX_GITNAME (1000)
extern char git_default_email[MAX_GITNAME];
Expand Down
Loading

0 comments on commit 04f32cf

Please sign in to comment.