diff options
-rw-r--r-- | Documentation/SubmittingPatches | 13 | ||||
-rw-r--r-- | Documentation/config.txt | 12 | ||||
-rw-r--r-- | Documentation/git-config.txt | 17 | ||||
-rw-r--r-- | Documentation/git-status.txt | 5 | ||||
-rw-r--r-- | builtin-branch.c | 3 | ||||
-rw-r--r-- | builtin-name-rev.c | 4 | ||||
-rw-r--r-- | daemon.c | 4 | ||||
-rw-r--r-- | diff.c | 6 | ||||
-rw-r--r-- | fast-import.c | 67 | ||||
-rwxr-xr-x | git-cvsimport.perl | 10 | ||||
-rwxr-xr-x | git-cvsserver.perl | 8 | ||||
-rw-r--r-- | git.c | 2 | ||||
-rw-r--r-- | object.c | 1 | ||||
-rwxr-xr-x | t/t1300-repo-config.sh | 34 | ||||
-rwxr-xr-x | t/t3001-ls-files-others-exclude.sh | 20 | ||||
-rwxr-xr-x | t/t9300-fast-import.sh | 29 | ||||
-rw-r--r-- | unpack-trees.c | 4 | ||||
-rw-r--r-- | wt-status.c | 9 |
18 files changed, 188 insertions, 60 deletions
diff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches index 6a4da2ddd..b94d9a816 100644 --- a/Documentation/SubmittingPatches +++ b/Documentation/SubmittingPatches @@ -65,6 +65,19 @@ in templates/hooks--pre-commit. To help ensure this does not happen, run git diff --check on your changes before you commit. +(1a) Try to be nice to older C compilers + +We try to support wide range of C compilers to compile +git with. That means that you should not use C99 initializers, even +if a lot of compilers grok it. + +Also, variables have to be declared at the beginning of the block +(you can check this with gcc, using the -Wdeclaration-after-statement +option). + +Another thing: NULL pointers shall be written as NULL, not as 0. + + (2) Generate your patch using git tools out of your commits. git based diff tools (git, Cogito, and StGIT included) generate diff --git a/Documentation/config.txt b/Documentation/config.txt index ea434af9d..fdb71de9f 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -263,6 +263,11 @@ You probably do not need to adjust this value. + Common unit suffixes of 'k', 'm', or 'g' are supported. +core.excludeFile:: + In addition to '.gitignore' (per-directory) and + '.git/info/exclude', git looks into this file for patterns + of files which are not meant to be tracked. + alias.*:: Command aliases for the gitlink:git[1] command wrapper - e.g. after defining "alias.last = cat-file commit HEAD", the invocation @@ -282,6 +287,13 @@ apply.whitespace:: Tells `git-apply` how to handle whitespaces, in the same way as the '--whitespace' option. See gitlink:git-apply[1]. +branch.autosetupmerge:: + Tells `git-branch` and `git-checkout` to setup new branches + so that gitlink: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. + branch.<name>.remote:: When in branch <name>, it tells `git fetch` which remote to fetch. If this option is not given, `git fetch` defaults to remote "origin". diff --git a/Documentation/git-config.txt b/Documentation/git-config.txt index 280ef2058..827a49970 100644 --- a/Documentation/git-config.txt +++ b/Documentation/git-config.txt @@ -9,15 +9,15 @@ git-config - Get and set repository or global options SYNOPSIS -------- [verse] -'git-config' [--system | --global] [type] name [value [value_regex]] -'git-config' [--system | --global] [type] --add name value -'git-config' [--system | --global] [type] --replace-all name [value [value_regex]] +'git-config' [--system | --global] name [value [value_regex]] +'git-config' [--system | --global] --add name value +'git-config' [--system | --global] --replace-all name [value [value_regex]] 'git-config' [--system | --global] [type] --get name [value_regex] 'git-config' [--system | --global] [type] --get-all name [value_regex] -'git-config' [--system | --global] [type] --unset name [value_regex] -'git-config' [--system | --global] [type] --unset-all name [value_regex] -'git-config' [--system | --global] [type] --rename-section old_name new_name -'git-config' [--system | --global] [type] --remove-section name +'git-config' [--system | --global] --unset name [value_regex] +'git-config' [--system | --global] --unset-all name [value_regex] +'git-config' [--system | --global] --rename-section old_name new_name +'git-config' [--system | --global] --remove-section name 'git-config' [--system | --global] -l | --list DESCRIPTION @@ -36,7 +36,8 @@ prepend a single exclamation mark in front (see EXAMPLES). The type specifier can be either '--int' or '--bool', which will make 'git-config' ensure that the variable(s) are of the given type and convert the value to the canonical form (simple decimal number for int, -a "true" or "false" string for bool). If no type specifier is passed, +a "true" or "false" string for bool). Type specifiers currently only +take effect for reading operations. If no type specifier is passed, no checks or transformations are performed on the value. This command will fail if: diff --git a/Documentation/git-status.txt b/Documentation/git-status.txt index e9e193f00..d7015387b 100644 --- a/Documentation/git-status.txt +++ b/Documentation/git-status.txt @@ -42,6 +42,11 @@ mean the same thing and the latter is kept for backward compatibility) and `color.status.<slot>` configuration variables to colorize its output. +As for gitlink:git-add[1], the configuration variable +'core.excludesfile' can indicate a path to a file containing patterns +of file names to exclude, in addition to patterns given in +'info/exclude' and '.gitignore'. + Author ------ diff --git a/builtin-branch.c b/builtin-branch.c index 740828505..8956d0f84 100644 --- a/builtin-branch.c +++ b/builtin-branch.c @@ -623,9 +623,10 @@ int cmd_branch(int argc, const char **argv, const char *prefix) (rename && force_create)) usage(builtin_branch_usage); - head = xstrdup(resolve_ref("HEAD", head_sha1, 0, NULL)); + head = resolve_ref("HEAD", head_sha1, 0, NULL); if (!head) die("Failed to resolve HEAD as a valid ref."); + head = xstrdup(head); if (!strcmp(head, "HEAD")) { detached = 1; } diff --git a/builtin-name-rev.c b/builtin-name-rev.c index ef1638590..2d94eaaa6 100644 --- a/builtin-name-rev.c +++ b/builtin-name-rev.c @@ -4,6 +4,8 @@ #include "tag.h" #include "refs.h" +#define CUTOFF_DATE_SLOP 86400 /* one day */ + static const char name_rev_usage[] = "git-name-rev [--tags | --refs=<pattern>] ( --all | --stdin | committish [committish...] )\n"; @@ -208,6 +210,8 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) add_object_array((struct object *)commit, *argv, &revs); } + if (cutoff) + cutoff = cutoff - CUTOFF_DATE_SLOP; for_each_ref(name_ref, &data); if (transform_stdin) { @@ -970,8 +970,8 @@ static void store_pid(const char *path) FILE *f = fopen(path, "w"); if (!f) die("cannot open pid file %s: %s", path, strerror(errno)); - fprintf(f, "%d\n", getpid()); - fclose(f); + if (fprintf(f, "%d\n", getpid()) < 0 || fclose(f) != 0) + die("failed to write pid file %s: %s", path, strerror(errno)); } static int serve(char *listen_addr, int listen_port, struct passwd *pass, gid_t gid) @@ -186,13 +186,11 @@ static const char *external_diff(void) return external_diff_cmd; } -#define TEMPFILE_PATH_LEN 50 - static struct diff_tempfile { const char *name; /* filename external diff should read from */ char hex[41]; char mode[10]; - char tmp_path[TEMPFILE_PATH_LEN]; + char tmp_path[PATH_MAX]; } diff_temp[2]; static int count_lines(const char *data, int size) @@ -1561,7 +1559,7 @@ static void prep_temp_blob(struct diff_tempfile *temp, { int fd; - fd = git_mkstemp(temp->tmp_path, TEMPFILE_PATH_LEN, ".diff_XXXXXX"); + fd = git_mkstemp(temp->tmp_path, PATH_MAX, ".diff_XXXXXX"); if (fd < 0) die("unable to create temp-file"); if (write_in_full(fd, blob, size) != size) diff --git a/fast-import.c b/fast-import.c index 3a2d5ed8e..17554f684 100644 --- a/fast-import.c +++ b/fast-import.c @@ -1013,7 +1013,7 @@ static void load_tree(struct tree_entry *root) return; myoe = find_object(sha1); - if (myoe) { + if (myoe && myoe->pack_id != MAX_PACK_ID) { if (myoe->type != OBJ_TREE) die("Not a tree: %s", sha1_to_hex(sha1)); t->delta_depth = 0; @@ -1122,6 +1122,7 @@ static void store_tree(struct tree_entry *root) || le->pack_id != pack_id) { lo.data = NULL; lo.depth = 0; + lo.no_free = 0; } else { mktree(t, 0, &lo.len, &old_tree); lo.data = old_tree.buffer; @@ -1656,6 +1657,33 @@ static void file_change_deleteall(struct branch *b) load_tree(&b->branch_tree); } +static void cmd_from_commit(struct branch *b, char *buf, unsigned long size) +{ + if (!buf || size < 46) + die("Not a valid commit: %s", sha1_to_hex(b->sha1)); + if (memcmp("tree ", buf, 5) + || get_sha1_hex(buf + 5, b->branch_tree.versions[1].sha1)) + die("The commit %s is corrupt", sha1_to_hex(b->sha1)); + hashcpy(b->branch_tree.versions[0].sha1, + b->branch_tree.versions[1].sha1); +} + +static void cmd_from_existing(struct branch *b) +{ + if (is_null_sha1(b->sha1)) { + hashclr(b->branch_tree.versions[0].sha1); + hashclr(b->branch_tree.versions[1].sha1); + } else { + unsigned long size; + char *buf; + + buf = read_object_with_reference(b->sha1, + commit_type, &size, b->sha1); + cmd_from_commit(b, buf, size); + free(buf); + } +} + static void cmd_from(struct branch *b) { const char *from; @@ -1681,40 +1709,19 @@ static void cmd_from(struct branch *b) } else if (*from == ':') { uintmax_t idnum = strtoumax(from + 1, NULL, 10); struct object_entry *oe = find_mark(idnum); - unsigned long size; - char *buf; if (oe->type != OBJ_COMMIT) die("Mark :%" PRIuMAX " not a commit", idnum); hashcpy(b->sha1, oe->sha1); - buf = gfi_unpack_entry(oe, &size); - if (!buf || size < 46) - die("Not a valid commit: %s", from); - if (memcmp("tree ", buf, 5) - || get_sha1_hex(buf + 5, b->branch_tree.versions[1].sha1)) - die("The commit %s is corrupt", sha1_to_hex(b->sha1)); - free(buf); - hashcpy(b->branch_tree.versions[0].sha1, - b->branch_tree.versions[1].sha1); - } else if (!get_sha1(from, b->sha1)) { - if (is_null_sha1(b->sha1)) { - hashclr(b->branch_tree.versions[0].sha1); - hashclr(b->branch_tree.versions[1].sha1); - } else { + if (oe->pack_id != MAX_PACK_ID) { unsigned long size; - char *buf; - - buf = read_object_with_reference(b->sha1, - commit_type, &size, b->sha1); - if (!buf || size < 46) - die("Not a valid commit: %s", from); - if (memcmp("tree ", buf, 5) - || get_sha1_hex(buf + 5, b->branch_tree.versions[1].sha1)) - die("The commit %s is corrupt", sha1_to_hex(b->sha1)); + char *buf = gfi_unpack_entry(oe, &size); + cmd_from_commit(b, buf, size); free(buf); - hashcpy(b->branch_tree.versions[0].sha1, - b->branch_tree.versions[1].sha1); - } - } else + } else + cmd_from_existing(b); + } else if (!get_sha1(from, b->sha1)) + cmd_from_existing(b); + else die("Invalid ref name or SHA1 expression: %s", from); read_next_command(); diff --git a/git-cvsimport.perl b/git-cvsimport.perl index ac74bc51b..f68afe78a 100755 --- a/git-cvsimport.perl +++ b/git-cvsimport.perl @@ -559,11 +559,6 @@ unless (-d $git_dir) { $last_branch = $opt_o; $orig_branch = ""; } else { - -f "$git_dir/refs/heads/$opt_o" - or die "Branch '$opt_o' does not exist.\n". - "Either use the correct '-o branch' option,\n". - "or import to a new repository.\n"; - open(F, "git-symbolic-ref HEAD |") or die "Cannot run git-symbolic-ref: $!\n"; chomp ($last_branch = <F>); @@ -588,6 +583,11 @@ unless (-d $git_dir) { $branch_date{$head} = $1; } close(H); + if (!exists $branch_date{$opt_o}) { + die "Branch '$opt_o' does not exist.\n". + "Either use the correct '-o branch' option,\n". + "or import to a new repository.\n"; + } } -d $git_dir diff --git a/git-cvsserver.perl b/git-cvsserver.perl index fcfb99db6..1de517791 100755 --- a/git-cvsserver.perl +++ b/git-cvsserver.perl @@ -192,11 +192,9 @@ sub req_Root } } - unless ( ($cfg->{gitcvs}{$state->{method}}{enabled} - and $cfg->{gitcvs}{$state->{method}}{enabled} =~ /^\s*(1|true|yes)\s*$/i) - or ($cfg->{gitcvs}{enabled} - and $cfg->{gitcvs}{enabled} =~ /^\s*(1|true|yes)\s*$/i) ) - { + my $enabled = ($cfg->{gitcvs}{$state->{method}}{enabled} + || $cfg->{gitcvs}{enabled}); + unless ($enabled && $enabled =~ /^\s*(1|true|yes)\s*$/i) { print "E GITCVS emulation needs to be enabled on this repo\n"; print "E the repo config file needs a [gitcvs] section added, and the parameter 'enabled' set to 1\n"; print "E \n"; @@ -225,7 +225,7 @@ static void handle_internal_command(int argc, const char **argv, char **envp) int option; } commands[] = { { "add", cmd_add, RUN_SETUP | NOT_BARE }, - { "annotate", cmd_annotate, USE_PAGER }, + { "annotate", cmd_annotate, RUN_SETUP | USE_PAGER }, { "apply", cmd_apply }, { "archive", cmd_archive }, { "blame", cmd_blame, RUN_SETUP }, @@ -176,6 +176,7 @@ struct object *parse_object(const unsigned char *sha1) if (buffer) { struct object *obj; if (check_sha1_signature(sha1, buffer, size, typename(type)) < 0) { + free(buffer); error("sha1 mismatch %s\n", sha1_to_hex(sha1)); return NULL; } diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh index a1d777ca8..3f3fd2d7f 100755 --- a/t/t1300-repo-config.sh +++ b/t/t1300-repo-config.sh @@ -436,6 +436,40 @@ test_expect_success numbers ' test z1048576 = "z$m" ' +cat > expect << EOF +true +false +true +false +true +false +true +false +EOF + +test_expect_success bool ' + + git-config bool.true1 01 && + git-config bool.true2 -1 && + git-config bool.true3 YeS && + git-config bool.true4 true && + git-config bool.false1 000 && + git-config bool.false2 "" && + git-config bool.false3 nO && + git-config bool.false4 FALSE && + rm -f result && + for i in 1 2 3 4 + do + git-config --bool --get bool.true$i >>result + git-config --bool --get bool.false$i >>result + done && + cmp expect result' + +test_expect_failure 'invalid bool' ' + + git-config bool.nobool foobar && + git-config --bool --get bool.nobool' + rm .git/config git-config quote.leading " test" diff --git a/t/t3001-ls-files-others-exclude.sh b/t/t3001-ls-files-others-exclude.sh index db7a847a5..fcfcfbba7 100755 --- a/t/t3001-ls-files-others-exclude.sh +++ b/t/t3001-ls-files-others-exclude.sh @@ -79,4 +79,24 @@ test_expect_success \ >output && git diff expect output' +cat > excludes-file << EOF +*.[1-8] +e* +EOF + +git-config core.excludesFile excludes-file + +git-runstatus | grep "^# " > output + +cat > expect << EOF +# .gitignore +# a.6 +# one/ +# output +# three/ +EOF + +test_expect_success 'git-status honours core.excludesfile' \ + 'diff -u expect output' + test_done diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh index 8e958da53..72e49f5d3 100755 --- a/t/t9300-fast-import.sh +++ b/t/t9300-fast-import.sh @@ -119,6 +119,35 @@ test_expect_success \ </dev/null && git diff -u expect marks.new' +test_tick +cat >input <<INPUT_END +commit refs/heads/verify--import-marks +committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE +data <<COMMIT +recreate from :5 +COMMIT + +from :5 +M 755 :2 copy-of-file2 + +INPUT_END +test_expect_success \ + 'A: verify marks import does not crash' \ + 'git-fast-import --import-marks=marks.out <input && + git-whatchanged verify--import-marks' +test_expect_success \ + 'A: verify pack' \ + 'for p in .git/objects/pack/*.pack;do git-verify-pack $p||exit;done' +cat >expect <<EOF +:000000 100755 0000000000000000000000000000000000000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 A copy-of-file2 +EOF +git-diff-tree -M -r master verify--import-marks >actual +test_expect_success \ + 'A: verify diff' \ + 'compare_diff_raw expect actual && + test `git-rev-parse --verify master:file2` \ + = `git-rev-parse --verify verify--import-marks:copy-of-file2`' + ### ### series B ### diff --git a/unpack-trees.c b/unpack-trees.c index 906ce69ea..cac2411b9 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -414,10 +414,6 @@ static void verify_uptodate(struct cache_entry *ce, return; errno = 0; } - if (o->reset) { - ce->ce_flags |= htons(CE_UPDATE); - return; - } if (errno == ENOENT) return; die("Entry '%s' not uptodate. Cannot merge.", ce->name); diff --git a/wt-status.c b/wt-status.c index a0559905a..4bfe8f15d 100644 --- a/wt-status.c +++ b/wt-status.c @@ -22,6 +22,7 @@ static const char use_add_rm_msg[] = "use \"git add/rm <file>...\" to update what will be committed"; static const char use_add_to_include_msg[] = "use \"git add <file>...\" to include in what will be committed"; +static const char *excludes_file; static int parse_status_slot(const char *var, int offset) { @@ -259,6 +260,8 @@ static void wt_status_print_untracked(struct wt_status *s) x = git_path("info/exclude"); if (file_exists(x)) add_excludes_from_file(&dir, x); + if (excludes_file && file_exists(excludes_file)) + add_excludes_from_file(&dir, excludes_file); read_directory(&dir, ".", "", 0, NULL); for(i = 0; i < dir.nr; i++) { @@ -356,5 +359,11 @@ int git_status_config(const char *k, const char *v) int slot = parse_status_slot(k, 13); color_parse(v, k, wt_status_colors[slot]); } + if (!strcmp(k, "core.excludesfile")) { + if (!v) + die("core.excludesfile without value"); + excludes_file = xstrdup(v); + return 0; + } return git_default_config(k, v); } |