From 078f8380f65acfdffee077a642e982453277873a Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Sun, 20 May 2007 14:19:17 +0200 Subject: [PATCH 01/55] branch: fix segfault when resolving an invalid HEAD Caused by return value of resolve_ref being passed directly to xstrdup whereby the sanity checking was never reached. Signed-off-by: Jonas Fonseca Signed-off-by: Junio C Hamano --- builtin-branch.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/builtin-branch.c b/builtin-branch.c index 7408285050..8956d0f842 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; } From 1472966c04103874096fb786657459ea6628e451 Mon Sep 17 00:00:00 2001 From: "Fernando J. Pereda" Date: Sun, 20 May 2007 15:35:46 +0200 Subject: [PATCH 02/55] Use PATH_MAX instead of TEMPFILE_PATH_LEN Signed-off-by: Fernando J. Pereda Signed-off-by: Junio C Hamano --- diff.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/diff.c b/diff.c index b28933f870..3c15553710 100644 --- a/diff.c +++ b/diff.c @@ -137,13 +137,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) @@ -1507,7 +1505,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) From 0a76f6652459e4bbf5311347e9bf726e203e86d6 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sun, 20 May 2007 19:26:37 +0200 Subject: [PATCH 03/55] unpack-trees.c: verify_uptodate: remove dead code This code was killed by commit fcc387db9bc453dc7e07a262873481af2ee9e5c8. Signed-off-by: Sven Verdoolaege Signed-off-by: Junio C Hamano --- unpack-trees.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/unpack-trees.c b/unpack-trees.c index ee10eea24c..6d1f0d13a3 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -452,10 +452,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); From cab333cb6ac0ac857dcfb112989ea32aea5d0ec1 Mon Sep 17 00:00:00 2001 From: Frank Lichtenheld Date: Mon, 21 May 2007 00:12:57 +0200 Subject: [PATCH 04/55] t1300: Add tests for git-config --bool --get Noticed that there were only tests for --int, but not for --bool. Add some. Signed-off-by: Frank Lichtenheld Signed-off-by: Junio C Hamano --- t/t1300-repo-config.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh index a1d777ca81..3f3fd2d7f7 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" From 0cb21911f49176866ee5170e292d351f4697634e Mon Sep 17 00:00:00 2001 From: Frank Lichtenheld Date: Mon, 21 May 2007 00:12:58 +0200 Subject: [PATCH 05/55] git-config: Correct asciidoc documentation for --int/--bool The asciidoc documentation seemed to indicate that type specifiers are honoured on writing operations which they aren't. Make this more clear. Signed-off-by: Frank Lichtenheld Signed-off-by: Junio C Hamano --- Documentation/git-config.txt | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Documentation/git-config.txt b/Documentation/git-config.txt index 280ef2058c..827a49970d 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: From 5b6dedd6a0b7566f7e8466b6aefe8f019c52f5d3 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 20 May 2007 19:56:28 -0700 Subject: [PATCH 06/55] annotate: make it work from subdirectories. Signed-off-by: Junio C Hamano --- git.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git.c b/git.c index 7def319e60..3d0754cbaa 100644 --- a/git.c +++ b/git.c @@ -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 }, From 56d99c67d1ad95326902f3a739ab2a3c7bb2d6fe Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Sat, 19 May 2007 23:35:21 +0200 Subject: [PATCH 07/55] Update bash completion to ignore some more plumbing commands [sp: Modified Jonas' original patch to keep checkout-index as a a valid completion.] Signed-off-by: Jonas Fonseca Signed-off-by: Shawn O. Pearce --- contrib/completion/git-completion.bash | 3 +++ 1 file changed, 3 insertions(+) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 46356e8a27..35b1ff9157 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -262,6 +262,7 @@ __git_commands () applypatch) : ask gittus;; archimport) : import;; cat-file) : plumbing;; + check-attr) : plumbing;; check-ref-format) : plumbing;; commit-tree) : plumbing;; convert-objects) : plumbing;; @@ -271,8 +272,10 @@ __git_commands () daemon) : daemon;; fast-import) : import;; fsck-objects) : plumbing;; + fetch--tool) : plumbing;; fetch-pack) : plumbing;; fmt-merge-msg) : plumbing;; + for-each-ref) : plumbing;; hash-object) : plumbing;; http-*) : transport;; index-pack) : plumbing;; From bc4e7d035840539eb5aa13ab3d51ab43cc2c1b50 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Mon, 21 May 2007 09:58:01 +0200 Subject: [PATCH 08/55] git-daemon: don't ignore pid-file write failure Note: since the consequence of failure is to call die, I don't bother to close "f". Signed-off-by: Jim Meyering Signed-off-by: Junio C Hamano --- daemon.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/daemon.c b/daemon.c index e74ecac952..674e30dca3 100644 --- a/daemon.c +++ b/daemon.c @@ -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) From 243bfd33997484ee8ea2450f1910306f7138193b Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 21 May 2007 13:48:49 +0100 Subject: [PATCH 09/55] SubmittingPatches: mention older C compiler compatibility We do not appreciate C99 initializers, declarations after statements, or "0" instead of "NULL". Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- Documentation/SubmittingPatches | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches index 8cf5093dd9..1ba9041b5b 100644 --- a/Documentation/SubmittingPatches +++ b/Documentation/SubmittingPatches @@ -62,6 +62,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 From 0ba956d331e4c14fb1600a62044492c6c27af71a Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 22 May 2007 01:12:17 +0100 Subject: [PATCH 10/55] git-status: respect core.excludesFile git-add reads this variable, and honours the contents of that file if that exists. Match this behaviour in git-status, too. Noticed by Evan Carroll on IRC. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- Documentation/config.txt | 5 +++++ Documentation/git-status.txt | 5 +++++ t/t3001-ls-files-others-exclude.sh | 20 ++++++++++++++++++++ wt-status.c | 9 +++++++++ 4 files changed, 39 insertions(+) diff --git a/Documentation/config.txt b/Documentation/config.txt index a7daa08731..c3fc64acc7 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 diff --git a/Documentation/git-status.txt b/Documentation/git-status.txt index e9e193f008..d7015387b5 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.` 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/t/t3001-ls-files-others-exclude.sh b/t/t3001-ls-files-others-exclude.sh index db7a847a5d..fcfcfbba7d 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/wt-status.c b/wt-status.c index a25632bc87..f053c15ffe 100644 --- a/wt-status.c +++ b/wt-status.c @@ -22,6 +22,7 @@ static const char use_add_rm_msg[] = "use \"git add/rm ...\" to update what will be committed"; static const char use_add_to_include_msg[] = "use \"git add ...\" 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); 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); } From 523d12e5003eee0c2cb670b51e39d719cd56aacd Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 20 May 2007 17:57:27 -0700 Subject: [PATCH 11/55] git-cvsserver: fix disabling service via per-method config When the per-method enable logic disables the access, we should not even look at the global one. git-cvsserver.perl | 8 +++----- 1 files changed, 3 insertions(+), 5 deletions(-) Signed-off-by: Junio C Hamano --- git-cvsserver.perl | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/git-cvsserver.perl b/git-cvsserver.perl index fcfb99db65..1de517791f 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"; From 306fc124621657234b21dce542496440d53147a6 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Tue, 22 May 2007 03:22:51 -0400 Subject: [PATCH 12/55] git-gui: Tighten internal pattern match for lib/ directory Our GITGUI_LIBDIR macro was testing only for @@ at the start of the path, assuming nobody would ever find that to be a reasonable prefix for a directory to install our library into. That is most likely a valid assumption, but its even more unlikely they would have the start be @@GITGUI_ and the end be @@. Note that we cannot use the full string here because that would get expanded by the sed replacement in our Makefile. Signed-off-by: Shawn O. Pearce --- git-gui.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-gui.sh b/git-gui.sh index 0a471a5c7d..40f54e4dab 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA} ## configure our library set oguilib {@@GITGUI_LIBDIR@@} -if {[string match @@* $oguilib]} { +if {[string match @@GITGUI_*@@ $oguilib]} { set oguilib [file join [file dirname [file normalize $argv0]] lib] } set idx [file join $oguilib tclIndex] From 9902387d20e7a73662a97f5c4b66ba4ec80dc9ce Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 23 May 2007 07:07:54 +0200 Subject: [PATCH 13/55] Document branch.autosetupmerge. This patch documents the branch.autosetupmerge config option, added by commit 0746d19a. Signed-off-by: Paolo Bonzini Signed-off-by: Junio C Hamano --- Documentation/config.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/config.txt b/Documentation/config.txt index c3fc64acc7..6593f2e937 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -287,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..remote:: When in branch , it tells `git fetch` which remote to fetch. If this option is not given, `git fetch` defaults to remote "origin". From 7ca055f75ad7ffd2251d4b607fbb86d7bcfd77c7 Mon Sep 17 00:00:00 2001 From: Stephan Springl Date: Wed, 23 May 2007 12:13:21 +0100 Subject: [PATCH 14/55] Use git-for-each-ref to check whether the origin branch exists. This works in repositories that have their refs packed by "git-pack-refs --all --prune" whereas testing the file $git_dir/refs/heads/$opt_o does not. Acked-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- git-cvsimport.perl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/git-cvsimport.perl b/git-cvsimport.perl index ac74bc51b3..f68afe78a0 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 = ); @@ -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 From 5fdcf75c68d2c382de54af4e55713ca770bb9031 Mon Sep 17 00:00:00 2001 From: James Bowes Date: Wed, 23 May 2007 18:16:12 -0400 Subject: [PATCH 15/55] Documentation: fix git-config.xml generation Signed-off-by: James Bowes Signed-off-by: Junio C Hamano --- Documentation/config.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/config.txt b/Documentation/config.txt index 6593f2e937..65ed64a457 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -288,7 +288,7 @@ apply.whitespace:: as the '--whitespace' option. See gitlink:git-apply[1]. branch.autosetupmerge:: - Tells `git-branch' and `git-checkout' to setup new branches + 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` From b259157f3c8705e0f775a3df2b33198499aede4f Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 23 May 2007 23:00:22 +0200 Subject: [PATCH 16/55] fast-import: Fix uninitialized variable Fix uninitialized last_object->no_free variable that is accessed in store_object. Signed-off-by: Simon Hausmann Signed-off-by: Shawn O. Pearce --- fast-import.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fast-import.c b/fast-import.c index 3a2d5ed8e6..03f5ca7998 100644 --- a/fast-import.c +++ b/fast-import.c @@ -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; From 20f546a86c5c673fc49050479a12edfb9f8672bf Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 23 May 2007 23:01:49 +0200 Subject: [PATCH 17/55] fast-import: Fix crash when referencing already existing objects Commit a5c1780a0355a71b9fb70f1f1977ce726ee5b8d8 sets the pack_id of existing objects to MAX_PACK_ID. When the same object is referenced later again it is found in the local object hash. With such a pack_id fast-import should not try to locate that object in the newly created pack(s). Signed-off-by: Simon Hausmann Signed-off-by: Shawn O. Pearce --- fast-import.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fast-import.c b/fast-import.c index 03f5ca7998..f308db7630 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; From 654aaa37ab5c70650bdd16d57b56c2d0f9aa43cf Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 24 May 2007 00:05:19 -0400 Subject: [PATCH 18/55] Refactor fast-import branch creation from existing commit To resolve a corner case uncovered by Simon Hausmann I need to reuse the logic for the SHA-1 expression version of the 'from ' command within the mark version of the 'from ' command. This change doesn't alter any functionality, but is merely breaking the common code out to a function that I can reuse. Signed-off-by: Shawn O. Pearce --- fast-import.c | 58 +++++++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/fast-import.c b/fast-import.c index f308db7630..f5107df74d 100644 --- a/fast-import.c +++ b/fast-import.c @@ -1657,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; @@ -1688,34 +1715,11 @@ static void cmd_from(struct branch *b) 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)); + cmd_from_commit(b, buf, size); 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 { - 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)); - free(buf); - hashcpy(b->branch_tree.versions[0].sha1, - b->branch_tree.versions[1].sha1); - } - } else + } else if (!get_sha1(from, b->sha1)) + cmd_from_existing(b); + else die("Invalid ref name or SHA1 expression: %s", from); read_next_command(); From aac65ed1bc63619d32516079995f5cbe4bb46492 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 24 May 2007 00:32:31 -0400 Subject: [PATCH 19/55] Fix possible coredump with fast-import --import-marks When e8438420bb7d368bec3647b90c557b9931582267 allowed us to reload the marks table on subsequent runs of fast-import we really broke things, as we set pack_id to MAX_PACK_ID for any objects we imported into the marks table. Creating a branch from that mark should fail as we attempt to read the object through a non-existant packed_git pointer. Instead we have to use the normal Git object system to locate the older commit, as we ourselves do not have a reference to the packed_git it resides in. This bug only occurred because t9300 was not complete enough. When we added the --import-marks feature we didn't actually test its implementation enough to verify the function worked as intended. I have corrected that, and included the changes as part of this fix. Prior versions of fast-import fail the new test(s); this commit allows them to pass. Credit for this bug find goes to Simon Hausmann as he recently identified a similiar bug in the tree lazy-loading path. Signed-off-by: Shawn O. Pearce --- fast-import.c | 12 +++++++----- t/t9300-fast-import.sh | 29 +++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/fast-import.c b/fast-import.c index f5107df74d..17554f6849 100644 --- a/fast-import.c +++ b/fast-import.c @@ -1709,14 +1709,16 @@ 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); - cmd_from_commit(b, buf, size); - free(buf); + if (oe->pack_id != MAX_PACK_ID) { + unsigned long size; + char *buf = gfi_unpack_entry(oe, &size); + cmd_from_commit(b, buf, size); + free(buf); + } else + cmd_from_existing(b); } else if (!get_sha1(from, b->sha1)) cmd_from_existing(b); else diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh index 8e958da536..72e49f5d3b 100755 --- a/t/t9300-fast-import.sh +++ b/t/t9300-fast-import.sh @@ -119,6 +119,35 @@ test_expect_success \ input < $GIT_COMMITTER_DATE +data <expect <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 ### From 5cfb4fe525034b758ca39a32d05cc8b2a53d2a13 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 24 May 2007 01:01:02 -0400 Subject: [PATCH 20/55] Hide the plumbing diff-{files,index,tree} from bash completion The diff-* programs are meant to be plumbing for the diff frontend; most end users aren't invoking these commands directly. Consequently we should avoid showing them as possible completions. Signed-off-by: Shawn O. Pearce --- contrib/completion/git-completion.bash | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 35b1ff9157..9944745028 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -270,6 +270,9 @@ __git_commands () cvsimport) : import;; cvsserver) : daemon;; daemon) : daemon;; + diff-files) : plumbing;; + diff-index) : plumbing;; + diff-tree) : plumbing;; fast-import) : import;; fsck-objects) : plumbing;; fetch--tool) : plumbing;; @@ -950,7 +953,6 @@ _git () commit) _git_commit ;; config) _git_config ;; diff) _git_diff ;; - diff-tree) _git_diff_tree ;; fetch) _git_fetch ;; format-patch) _git_format_patch ;; gc) _git_gc ;; @@ -995,7 +997,6 @@ complete -o default -o nospace -F _git_cherry git-cherry complete -o default -o nospace -F _git_cherry_pick git-cherry-pick complete -o default -o nospace -F _git_commit git-commit complete -o default -o nospace -F _git_diff git-diff -complete -o default -o nospace -F _git_diff_tree git-diff-tree complete -o default -o nospace -F _git_fetch git-fetch complete -o default -o nospace -F _git_format_patch git-format-patch complete -o default -o nospace -F _git_gc git-gc @@ -1026,7 +1027,6 @@ complete -o default -o nospace -F _git git.exe complete -o default -o nospace -F _git_branch git-branch.exe complete -o default -o nospace -F _git_cherry git-cherry.exe complete -o default -o nospace -F _git_diff git-diff.exe -complete -o default -o nospace -F _git_diff_tree git-diff-tree.exe complete -o default -o nospace -F _git_format_patch git-format-patch.exe complete -o default -o nospace -F _git_log git-log.exe complete -o default -o nospace -F _git_ls_tree git-ls-tree.exe From 1fd6bec9bcb2d7fc710a9866bd53ea52f43d4428 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 24 May 2007 01:25:34 -0400 Subject: [PATCH 21/55] Teach bash completion about git-shortlog We've had completion for git-log for quite some time, but just today I noticed we don't have it for the new builtin shortlog that runs git-log internally. This is indeed a handy thing to have completion for, especially when your branch names are of the Very-Very-Long-and-Hard/To-Type/Variety/That-Some-Use. Signed-off-by: Shawn O. Pearce --- contrib/completion/git-completion.bash | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 9944745028..d75f47a1ac 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -896,6 +896,26 @@ _git_reset () __gitcomp "$(__git_refs)" } +_git_shortlog () +{ + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + --*) + __gitcomp " + --max-count= --max-age= --since= --after= + --min-age= --before= --until= + --no-merges + --author= --committer= --grep= + --all-match + --not --all + --numbered --summary + " + return + ;; + esac + __git_complete_revlist +} + _git_show () { local cur="${COMP_WORDS[COMP_CWORD]}" @@ -967,6 +987,7 @@ _git () rebase) _git_rebase ;; remote) _git_remote ;; reset) _git_reset ;; + shortlog) _git_shortlog ;; show) _git_show ;; show-branch) _git_log ;; whatchanged) _git_log ;; @@ -1012,6 +1033,7 @@ complete -o default -o nospace -F _git_rebase git-rebase complete -o default -o nospace -F _git_config git-config complete -o default -o nospace -F _git_remote git-remote complete -o default -o nospace -F _git_reset git-reset +complete -o default -o nospace -F _git_shortlog git-shortlog complete -o default -o nospace -F _git_show git-show complete -o default -o nospace -F _git_log git-show-branch complete -o default -o nospace -F _git_log git-whatchanged @@ -1034,6 +1056,7 @@ complete -o default -o nospace -F _git_merge_base git-merge-base.exe complete -o default -o nospace -F _git_name_rev git-name-rev.exe complete -o default -o nospace -F _git_push git-push.exe complete -o default -o nospace -F _git_config git-config +complete -o default -o nospace -F _git_shortlog git-shortlog.exe complete -o default -o nospace -F _git_show git-show.exe complete -o default -o nospace -F _git_log git-show-branch.exe complete -o default -o nospace -F _git_log git-whatchanged.exe From bfbd131f52ff8373ffabbb30f275b4af8213f5f0 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 24 May 2007 01:26:58 -0400 Subject: [PATCH 22/55] Remove a duplicate --not option in bash completion This was just me being silly; I put the --not option into the completion list twice. There's no duplicates shown in the shell as the shell removes them before showing them to the user. But we really don't need the duplicates in the source script either. Signed-off-by: Shawn O. Pearce --- contrib/completion/git-completion.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index d75f47a1ac..24b18183fd 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -579,7 +579,7 @@ _git_log () __gitcomp " --max-count= --max-age= --since= --after= --min-age= --before= --until= - --root --not --topo-order --date-order + --root --topo-order --date-order --no-merges --abbrev-commit --abbrev= --relative-date From c70680ce7cec72a465468c223d43c08f5254d31f Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 24 May 2007 01:36:46 -0400 Subject: [PATCH 23/55] Update bash completion header documentation 1) Added a note about supporting the long options for most commands, as we have been doing so for quite some time. 2) Include a notice that these routines are covered by the GPL, as that may not be obvious, even though they are distributed as part of the core Git distribution. 3) Added a short section on how to send patches to the routines, and to whom they should get sent to. Currently that is me, as I am the active maintainer. Signed-off-by: Shawn O. Pearce --- contrib/completion/git-completion.bash | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 24b18183fd..48ba3f8e81 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -1,8 +1,9 @@ # # bash completion support for core Git. # -# Copyright (C) 2006,2007 Shawn Pearce +# Copyright (C) 2006,2007 Shawn O. Pearce # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). +# Distributed under the GNU General Public License, version 2.0. # # The contained completion routines provide support for completing: # @@ -11,6 +12,7 @@ # *) .git/remotes file names # *) git 'subcommands' # *) tree paths within 'ref:path/to/file' expressions +# *) common --long-options # # To use these routines: # @@ -31,6 +33,17 @@ # are currently in a git repository. The %s token will be # the name of the current branch. # +# To submit patches: +# +# *) Read Documentation/SubmittingPatches +# *) Send all patches to the current maintainer: +# +# "Shawn O. Pearce" +# +# *) Always CC the Git mailing list: +# +# git@vger.kernel.org +# __gitdir () { From fb72759b7de504f077250fd5bd557e3b9e2a5682 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 24 May 2007 01:46:49 -0400 Subject: [PATCH 24/55] Teach bash completion about 'git remote update' Recently the git-remote command grew an update subcommand, which can be used to execute git-fetch across multiple repositories in a single step. These can be configured with the 'remotes.*' configuration options, so we can offer completion for any name that matches and appears to be useful to git-remote update. Signed-off-by: Shawn O. Pearce --- contrib/completion/git-completion.bash | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 48ba3f8e81..d6252068c4 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -877,13 +877,13 @@ _git_remote () while [ $c -lt $COMP_CWORD ]; do i="${COMP_WORDS[c]}" case "$i" in - add|show|prune) command="$i"; break ;; + add|show|prune|update) command="$i"; break ;; esac c=$((++c)) done if [ $c -eq $COMP_CWORD -a -z "$command" ]; then - __gitcomp "add show prune" + __gitcomp "add show prune update" return fi @@ -891,6 +891,18 @@ _git_remote () show|prune) __gitcomp "$(__git_remotes)" ;; + update) + local i c='' IFS=$'\n' + for i in $(git --git-dir="$(__gitdir)" config --list); do + case "$i" in + remotes.*) + i="${i#remotes.}" + c="$c ${i/=*/}" + ;; + esac + done + __gitcomp "$c" + ;; *) COMPREPLY=() ;; From 8f87fae6459b7d5b8058691911f1c18c59a5dcbd Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 24 May 2007 01:51:30 -0400 Subject: [PATCH 25/55] Teach bash completion about recent log long options (Somewhat) recently git-log learned about --reverse (to show commits in the opposite order) and a looong time ago I think it learned about --raw (to show the raw diff, rather than a unified diff). These are both useful options, so we should make them easy for the user to complete. Signed-off-by: Shawn O. Pearce --- contrib/completion/git-completion.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index d6252068c4..0b8cb5f0e6 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -592,13 +592,13 @@ _git_log () __gitcomp " --max-count= --max-age= --since= --after= --min-age= --before= --until= - --root --topo-order --date-order + --root --topo-order --date-order --reverse --no-merges --abbrev-commit --abbrev= --relative-date --author= --committer= --grep= --all-match - --pretty= --name-status --name-only + --pretty= --name-status --name-only --raw --not --all " return From 12977705b3da7eb63cdfd890f838b971e8d81485 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 24 May 2007 02:07:45 -0400 Subject: [PATCH 26/55] Update bash completion for git-config options A few new configuration options grew out of the woodwork during the 1.5.2 series. Most of these are pretty easy to support a completion of, so we do so. I wanted to also add completion support for the part of merge..name but to do that we have to look at all of the .gitattributes files and guess what the unique set of strings would be. Since this appears to be non-trivial I'm punting on it at this time. Signed-off-by: Shawn O. Pearce --- contrib/completion/git-completion.bash | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 0b8cb5f0e6..9e72f0f7b1 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -764,9 +764,11 @@ _git_config () case "$cur" in --*) __gitcomp " - --global --list --replace-all + --global --system + --list --replace-all --get --get-all --get-regexp --add --unset --unset-all + --remove-section --rename-section " return ;; @@ -785,7 +787,10 @@ _git_config () remote.*.*) local pfx="${cur%.*}." cur="${cur##*.}" - __gitcomp "url fetch push" "$pfx" "$cur" + __gitcomp " + url fetch push skipDefaultUpdate + receivepack uploadpack tagopt + " "$pfx" "$cur" return ;; remote.*) @@ -835,6 +840,9 @@ _git_config () format.headers gitcvs.enabled gitcvs.logfile + gitcvs.allbinary + gitcvs.dbname gitcvs.dbdriver gitcvs.dbuser gitcvs.dvpass + gc.packrefs gc.reflogexpire gc.reflogexpireunreachable gc.rerereresolved @@ -851,9 +859,11 @@ _git_config () i18n.commitEncoding i18n.logOutputEncoding log.showroot + merge.tool merge.summary merge.verbosity pack.window + pack.depth pull.octopus pull.twohead repack.useDeltaBaseOffset From 3d5793bf52223ccec40aff2839a3c5bad96bca8b Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 24 May 2007 02:33:13 -0400 Subject: [PATCH 27/55] Correct key bindings to Control- Alberto Bertogli reported on #git that git-gui was exiting with alt-q, while gitk on the same system was exiting with ctrl-q. That was not what I wanted. I really wanted M1B to be bound to the Control key on most non-Mac OS X platforms, but according to Sam Vilain M1 on most systems means alt. Since gitk always does control, I'm doing the same thing for all non-Mac OS X systems. Signed-off-by: Shawn O. Pearce --- git-gui.sh | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/git-gui.sh b/git-gui.sh index 40f54e4dab..cfc4c7f686 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -1206,15 +1206,12 @@ foreach class {Button Checkbutton Entry Label } unset class -if {[is_Windows]} { - set M1B Control - set M1T Ctrl -} elseif {[is_MacOSX]} { +if {[is_MacOSX]} { set M1B M1 set M1T Cmd } else { - set M1B M1 - set M1T M1 + set M1B Control + set M1T Ctrl } proc apply_config {} { From c075aea5da6c35edfe86da7d3edced67cdb009c8 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 24 May 2007 12:20:42 -0700 Subject: [PATCH 28/55] name-rev: tolerate clock skew in committer dates In git.git repository, "git-name-rev v1.3.0~158" cannot name the rev, while adjacent revs can be named. This was because it gives up traversal from the tips of existing refs as soon as it sees a commit that has older commit timestamp than what is being named. This is usually a good heuristics, but v1.3.0~158 has a slightly older commit timestamp than v1.3.0~157 (i.e. it's child), as these two were made in a separate repostiory (in fact, in a different continent). This adds a hardcoded slop value (1 day) to the cut-off heuristics to work this kind of problem around. The current algorithm essentially runs around from the available tips down to ancient commits and names every single rev available that are newer than cut-off date, so a single day slop would not add that much overhead in repositories with long enough history where the performance of name-rev matters. I think the algorithm could be made a bit smarter by deepening the graph on demand as a new commit is asked to be named (this would require rewriting of name_rev() function not to recurse itself but use a traversal list like revision.c traverser does), but that would be a separate issue. Acked-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- builtin-name-rev.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/builtin-name-rev.c b/builtin-name-rev.c index ef16385907..2d94eaaa6a 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=] ( --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) { From 0b1f113075aafb0c91a406d984d0152e55c981da Mon Sep 17 00:00:00 2001 From: Carlos Rica Date: Fri, 25 May 2007 03:46:22 +0200 Subject: [PATCH 29/55] fix memory leak in parse_object when check_sha1_signature fails When check_sha1_signature fails, program is not terminated: it prints an error message and returns NULL, so the buffer returned by read_sha1_file should be freed before. Signed-off-by: Carlos Rica Signed-off-by: Junio C Hamano --- object.c | 1 + 1 file changed, 1 insertion(+) diff --git a/object.c b/object.c index 78a44a6ef4..ccd7dd796e 100644 --- a/object.c +++ b/object.c @@ -185,6 +185,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; } From a58f3c01f7e6aecb486aadece040a6293eb43059 Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Sat, 26 May 2007 00:37:38 +0200 Subject: [PATCH 30/55] Documentation: Clean up links in GIT Glossary Ensure that the same link is not repeated in single glossary entry, and that there is no self-link i.e. link to current entry. Add links to other definitions in git glossary. Remove inappropriate (nonsense) links, or change link to link to correct definition (to correct term). Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano --- Documentation/glossary.txt | 58 +++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/Documentation/glossary.txt b/Documentation/glossary.txt index 489c3e9d5b..ba52618830 100644 --- a/Documentation/glossary.txt +++ b/Documentation/glossary.txt @@ -10,7 +10,7 @@ GIT Glossary A bare repository is normally an appropriately named <> with a `.git` suffix that does not have a locally checked-out copy of any of the files under - <> control. That is, all of the `git` + revision control. That is, all of the `git` administrative and control files that would normally be present in the hidden `.git` sub-directory are directly present in the `repository.git` directory instead, @@ -37,7 +37,7 @@ GIT Glossary [[def_chain]]chain:: A list of objects, where each <> in the list contains a reference to its successor (for example, the successor of a - <> could be one of its parents). + <> could be one of its <>). [[def_changeset]]changeset:: BitKeeper/cvsps speak for "<>". Since git does not @@ -77,10 +77,10 @@ to point at the new commit. [[def_commit_object]]commit object:: An <> which contains the information about a - particular <>, such as parents, committer, + particular <>, such as <>, committer, author, date and the <> which corresponds to the top <> of the stored - <>. + revision. [[def_core_git]]core git:: Fundamental data structures and utilities of git. Exposes only limited @@ -101,19 +101,19 @@ to point at the new commit. [[def_detached_HEAD]]detached HEAD:: Normally the <> stores the name of a - <>. However, git also allows you to check - out an arbitrary commit that isn't necessarily the tip of any + <>. However, git also allows you to <> + an arbitrary <> that isn't necessarily the tip of any particular branch. In this case HEAD is said to be "detached". [[def_dircache]]dircache:: - You are *waaaaay* behind. + You are *waaaaay* behind. See <>. [[def_directory]]directory:: The list you get with "ls" :-) [[def_dirty]]dirty:: A <> is said to be "dirty" if - it contains modifications which have not been committed to the current + it contains modifications which have not been <> to the current <>. [[def_ent]]ent:: @@ -149,7 +149,7 @@ to point at the new commit. [[def_grafts]]grafts:: Grafts enables two otherwise different lines of development to be joined together by recording fake ancestry information for commits. This way - you can make git pretend the set of parents a <> has + you can make git pretend the set of <> a <> has is different from what was recorded when the commit was created. Configured via the `.git/info/grafts` file. @@ -157,13 +157,13 @@ to point at the new commit. In git's context, synonym to <>. [[def_head]]head:: - A named reference to the <> at the tip of a + A <> to the <> at the tip of a <>. Heads are stored in `$GIT_DIR/refs/heads/`, except when using packed refs. (See gitlink:git-pack-refs[1].) [[def_HEAD]]HEAD:: - The current branch. In more detail: Your <>. In more detail: Your <> is normally derived from the state of the tree referred to by HEAD. HEAD is a reference to one of the <> in your repository, except when using a @@ -179,15 +179,15 @@ to point at the new commit. checking. Typically, the hooks allow for a command to be pre-verified and potentially aborted, and allow for a post-notification after the operation is done. The hook scripts are found in the - `$GIT_DIR/hooks/` <>, and are enabled by simply + `$GIT_DIR/hooks/` directory, and are enabled by simply making them executable. [[def_index]]index:: A collection of files with stat information, whose contents are stored - as objects. The index is a stored version of your working - <>. Truth be told, it can also contain a second, and even - a third version of a <>, which are used - when merging. + as objects. The index is a stored version of your + <>. Truth be told, it can also contain a second, and even + a third version of a working tree, which are used + when <>. [[def_index_entry]]index entry:: The information regarding a particular file, stored in the @@ -249,16 +249,16 @@ This commit is referred to as a "merge commit", or sometimes just a describing the type of an <>. [[def_octopus]]octopus:: - To <> more than two branches. Also denotes an + To <> more than two <>. Also denotes an intelligent predator. [[def_origin]]origin:: The default upstream <>. Most projects have at least one upstream project which they track. By default 'origin' is used for that purpose. New upstream updates - will be fetched into remote tracking branches named + will be fetched into remote <> named origin/name-of-upstream-branch, which you can see using - "git <> -r". + "`git branch -r`". [[def_pack]]pack:: A set of objects which have been compressed into one file (to save space @@ -327,7 +327,7 @@ This commit is referred to as a "merge commit", or sometimes just a `$GIT_DIR/refs/`. [[def_refspec]]refspec:: - A <> is used by <> and + A "refspec" is used by <> and <> to describe the mapping between remote <> and local ref. They are combined with a colon in the format :, preceded by an optional plus sign, +. @@ -340,11 +340,12 @@ This commit is referred to as a "merge commit", or sometimes just a gitlink:git-push[1] [[def_repository]]repository:: - A collection of refs together with an + A collection of <> together with an <> containing all objects which are <> from the refs, possibly - accompanied by meta data from one or more porcelains. A - repository can share an object database with other repositories. + accompanied by meta data from one or more <>. A + repository can share an object database with other repositories + via <>. [[def_resolve]]resolve:: The action of fixing up manually what a failed automatic @@ -366,8 +367,8 @@ This commit is referred to as a "merge commit", or sometimes just a Synonym for <>. [[def_shallow_repository]]shallow repository:: - A shallow repository has an incomplete - history some of whose commits have parents cauterized away (in other + A shallow <> has an incomplete + history some of whose <> have <> cauterized away (in other words, git is told to pretend that these commits do not have the parents, even though they are recorded in the <>). This is sometimes useful when you are interested only in the @@ -385,7 +386,7 @@ This commit is referred to as a "merge commit", or sometimes just a command. [[def_tag]]tag:: - A <> pointing to a tag or + A <> pointing to a <> or <>. In contrast to a <>, a tag is not changed by a <>. Tags (not <>) are stored in `$GIT_DIR/refs/tags/`. A @@ -398,8 +399,7 @@ This commit is referred to as a "merge commit", or sometimes just a An <> containing a <> pointing to another object, which can contain a message just like a <>. It can also contain a (PGP) - signature, in which case it is called a "signed <>". + signature, in which case it is called a "signed tag object". [[def_topic_branch]]topic branch:: A regular git <> that is used by a developer to @@ -418,7 +418,7 @@ This commit is referred to as a "merge commit", or sometimes just a [[def_tree]]tree:: Either a <>, or a <> together with the dependent blob and tree objects + object>> together with the dependent <> and tree objects (i.e. a stored representation of a working tree). [[def_tree_object]]tree object:: From 5adf317b31729707fad4967c1aef6cdba43d0dd3 Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Sat, 26 May 2007 00:37:40 +0200 Subject: [PATCH 31/55] Replace the last 'dircache's by 'index' Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano --- Documentation/git-ls-files.txt | 2 +- diff.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/git-ls-files.txt b/Documentation/git-ls-files.txt index 79e0b7b71a..b7c8ab5f7a 100644 --- a/Documentation/git-ls-files.txt +++ b/Documentation/git-ls-files.txt @@ -124,7 +124,7 @@ which case it outputs: detailed information on unmerged paths. For an unmerged path, instead of recording a single mode/SHA1 pair, -the dircache records up to three such pairs; one from tree O in stage +the index records up to three such pairs; one from tree O in stage 1, A in stage 2, and B in stage 3. This information can be used by the user (or the porcelain) to see what should eventually be recorded at the path. (see git-read-tree for more information on state) diff --git a/diff.c b/diff.c index 3c15553710..487168be40 100644 --- a/diff.c +++ b/diff.c @@ -1258,7 +1258,7 @@ void fill_filespec(struct diff_filespec *spec, const unsigned char *sha1, } /* - * Given a name and sha1 pair, if the dircache tells us the file in + * Given a name and sha1 pair, if the index tells us the file in * the work tree has that object contents, return true, so that * prepare_temp_file() does not have to inflate and extract. */ From c1bab2889eb71bf537497fc77a2fdb6a74bc92e6 Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Sat, 26 May 2007 00:37:39 +0200 Subject: [PATCH 32/55] Documentation: Add definition of "evil merge" to GIT Glossary Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano --- Documentation/glossary.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/glossary.txt b/Documentation/glossary.txt index ba52618830..e903abfeb8 100644 --- a/Documentation/glossary.txt +++ b/Documentation/glossary.txt @@ -121,6 +121,10 @@ to point at the new commit. `http://en.wikipedia.org/wiki/Ent_(Middle-earth)` for an in-depth explanation. Avoid this term, not to confuse people. +[[def_evil_merge]]evil merge:: + An evil merge is a <> that introduces changes that + do not appear in any <>. + [[def_fast_forward]]fast forward:: A fast-forward is a special type of <> where you have a <> and you are "merging" another From 4b7cc26a74b01ceab14a32ef66704557b26d5622 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Fri, 25 May 2007 23:42:36 -0400 Subject: [PATCH 33/55] git-am: use printf instead of echo on user-supplied strings Under some implementations of echo (such as that provided by dash), backslash escapes are recognized without any other options. This means that echo-ing user-supplied strings may cause any backslash sequences in them to be converted. Using printf resolves the ambiguity. This bug can be seen when using git-am to apply a patch whose subject contains the character sequence "\n"; the characters are converted to a literal newline. Noticed by Szekeres Istvan. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- git-am.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/git-am.sh b/git-am.sh index c9f66e2784..543efd0ad3 100755 --- a/git-am.sh +++ b/git-am.sh @@ -331,7 +331,7 @@ do ADD_SIGNOFF= fi { - echo "$SUBJECT" + printf '%s\n' "$SUBJECT" if test -s "$dotest/msg-clean" then echo @@ -394,7 +394,7 @@ do fi echo - echo "Applying '$SUBJECT'" + printf 'Applying %s\n' "$SUBJECT" echo case "$resolved" in From 293623edbc9488adbc71c2e0de1100b52cb193ac Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 25 May 2007 22:00:54 -0700 Subject: [PATCH 34/55] git-commit: use printf '%s\n' instead of echo on user-supplied strings This fixes the same issue git-am had, which was fixed by Jeff King in the previous commit. Cleverly enough, this commit's log message is a good test case at the same time. Signed-off-by: Junio C Hamano --- git-commit.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/git-commit.sh b/git-commit.sh index 292cf967e3..a1884fed25 100755 --- a/git-commit.sh +++ b/git-commit.sh @@ -376,12 +376,12 @@ t,) rm -f "$TMP_INDEX" fi || exit - echo "$commit_only" | + printf '%s\n' "$commit_only" | GIT_INDEX_FILE="$TMP_INDEX" \ git-update-index --add --remove --stdin && save_index && - echo "$commit_only" | + printf '%s\n' "$commit_only" | ( GIT_INDEX_FILE="$NEXT_INDEX" export GIT_INDEX_FILE @@ -432,7 +432,7 @@ fi if test "$log_message" != '' then - echo "$log_message" + printf '%s\n' "$log_message" elif test "$logfile" != "" then if test "$logfile" = - @@ -475,7 +475,7 @@ if test -f "$GIT_DIR/MERGE_HEAD" && test -z "$no_edit"; then echo "#" echo "# It looks like you may be committing a MERGE." echo "# If this is not correct, please remove the file" - echo "# $GIT_DIR/MERGE_HEAD" + printf '%s\n' "# $GIT_DIR/MERGE_HEAD" echo "# and try again" echo "#" fi >>"$GIT_DIR"/COMMIT_EDITMSG From 816366e23dfe366b938b427eac8ea1c8345ea339 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 26 May 2007 00:26:20 -0700 Subject: [PATCH 35/55] Add tests for the last two fixes. This updates t4014 to check the two fixes for git-am and git-commit we observed with "echo" that does backslash interpolation by default without being asked with -e option. Signed-off-by: Junio C Hamano --- t/t4014-format-patch.sh | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index 4795872a77..df969bb69c 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -16,16 +16,16 @@ test_expect_success setup ' for i in 1 2 5 6 A B C 7 8 9 10; do echo "$i"; done >file && git update-index file && - git commit -m "Side change #1" && + git commit -m "Side changes #1" && for i in D E F; do echo "$i"; done >>file && git update-index file && - git commit -m "Side change #2" && + git commit -m "Side changes #2" && git tag C2 && for i in 5 6 1 2 3 A 4 B C 7 8 9 10 D E F; do echo "$i"; done >file && git update-index file && - git commit -m "Side change #3" && + git commit -m "Side changes #3 with \\n backslash-n in it." && git checkout master && git diff-tree -p C2 | git apply --index && @@ -66,4 +66,23 @@ test_expect_success "format-patch --ignore-if-in-upstream result applies" ' test $cnt = 2 ' +test_expect_success 'commit did not screw up the log message' ' + + git cat-file commit side | grep "^Side .* with .* backslash-n" + +' + +test_expect_success 'format-patch did not screw up the log message' ' + + grep "^Subject: .*Side changes #3 with .* backslash-n" patch0 && + grep "^Subject: .*Side changes #3 with .* backslash-n" patch1 + +' + +test_expect_success 'replay did not screw up the log message' ' + + git cat-file commit rebuild-1 | grep "^Side .* with .* backslash-n" + +' + test_done From a23bfaed7da90ccdc75cbfd0099741080381f60a Mon Sep 17 00:00:00 2001 From: Jeff King Date: Sat, 26 May 2007 00:33:03 -0700 Subject: [PATCH 36/55] More echo "$user_message" fixes. Here are fixes to more uses of 'echo "$msg"' where $msg could contain backslashed sequence. Signed-off-by: Junio C Hamano --- git-am.sh | 4 ++-- git-merge.sh | 6 +++--- git-tag.sh | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/git-am.sh b/git-am.sh index 543efd0ad3..8b5712968e 100755 --- a/git-am.sh +++ b/git-am.sh @@ -18,7 +18,7 @@ stop_here () { stop_here_user_resolve () { if [ -n "$resolvemsg" ]; then - echo "$resolvemsg" + printf '%s\n' "$resolvemsg" stop_here $1 fi cmdline=$(basename $0) @@ -146,7 +146,7 @@ do git_apply_opt="$git_apply_opt $1"; shift ;; --resolvemsg=*) - resolvemsg=$(echo "$1" | sed -e "s/^--resolvemsg=//"); shift ;; + resolvemsg=${1#--resolvemsg=}; shift ;; --) shift; break ;; diff --git a/git-merge.sh b/git-merge.sh index fa4589173f..bf1fd4f06b 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -328,7 +328,7 @@ f,*) then echo "Wonderful." result_commit=$( - echo "$merge_msg" | + printf '%s\n' "$merge_msg" | git-commit-tree $result_tree -p HEAD -p "$1" ) || exit finish "$result_commit" "In-index merge" @@ -433,7 +433,7 @@ done if test '' != "$result_tree" then parents=$(git-show-branch --independent "$head" "$@" | sed -e 's/^/-p /') - result_commit=$(echo "$merge_msg" | git-commit-tree $result_tree $parents) || exit + result_commit=$(printf '%s\n' "$merge_msg" | git-commit-tree $result_tree $parents) || exit finish "$result_commit" "Merge made by $wt_strategy." dropsave exit 0 @@ -472,7 +472,7 @@ else do echo $remote done >"$GIT_DIR/MERGE_HEAD" - echo "$merge_msg" >"$GIT_DIR/MERGE_MSG" + printf '%s\n' "$merge_msg" >"$GIT_DIR/MERGE_MSG" fi if test "$merge_was_ok" = t diff --git a/git-tag.sh b/git-tag.sh index 4a0a7b6607..6f0b7a7219 100755 --- a/git-tag.sh +++ b/git-tag.sh @@ -126,7 +126,7 @@ if [ "$annotate" ]; then echo "#" ) > "$GIT_DIR"/TAG_EDITMSG ${VISUAL:-${EDITOR:-vi}} "$GIT_DIR"/TAG_EDITMSG || exit else - echo "$message" >"$GIT_DIR"/TAG_EDITMSG + printf '%s\n' "$message" >"$GIT_DIR"/TAG_EDITMSG fi grep -v '^#' <"$GIT_DIR"/TAG_EDITMSG | From c23290d528c208a25641f0fc278bac9bb9838265 Mon Sep 17 00:00:00 2001 From: Andy Parkins Date: Fri, 25 May 2007 11:50:08 +0100 Subject: [PATCH 37/55] Fix mishandling of $Id$ expanded in the repository copy in convert.c If the repository contained an expanded ident keyword (i.e. $Id:XXXX$), then the wrong bytes were discarded, and the Id keyword was not expanded. The fault was in convert.c:ident_to_worktree(). Previously, when a "$Id:" was found in the repository version, ident_to_worktree() would search for the next "$" after this, and discarded everything it found until then. That was done with the loop: do { ch = *cp++; if (ch == '$') break; rem--; } while (rem); The above loop left cp pointing one character _after_ the final "$" (because of ch = *cp++). This was different from the non-expanded case, were cp is left pointing at the "$", and was different from the comment which stated "discard up to but not including the closing $". This patch fixes that by making the loop: do { ch = *cp; if (ch == '$') break; cp++; rem--; } while (rem); That is, cp is tested _then_ incremented. This loop exits if it finds a "$" or if it runs out of bytes in the source. After this loop, if there was no closing "$" the expansion is skipped, and the outer loop is allowed to continue leaving this non-keyword as it was. However, when the "$" is found, size is corrected, before running the expansion: size -= (cp - src); This is wrong; size is going to be corrected anyway after the expansion, so there is no need to do it here. This patch removes that redundant correction. To help find this bug, I heavily commented the routine; those comments are included here as a bonus. Signed-off-by: Andy Parkins Signed-off-by: Junio C Hamano --- convert.c | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/convert.c b/convert.c index 4b26b1a9b9..21908b1039 100644 --- a/convert.c +++ b/convert.c @@ -509,36 +509,71 @@ static char *ident_to_worktree(const char *path, const char *src, unsigned long for (dst = buf; size; size--) { const char *cp; + /* Fetch next source character, move the pointer on */ char ch = *src++; + /* Copy the current character to the destination */ *dst++ = ch; + /* If the current character is "$" or there are less than three + * remaining bytes or the two bytes following this one are not + * "Id", then simply read the next character */ if ((ch != '$') || (size < 3) || memcmp("Id", src, 2)) continue; + /* + * Here when + * - There are more than 2 bytes remaining + * - The current three bytes are "$Id" + * with + * - ch == "$" + * - src[0] == "I" + */ + /* + * It's possible that an expanded Id has crept its way into the + * repository, we cope with that by stripping the expansion out + */ if (src[2] == ':') { + /* Expanded keywords have "$Id:" at the front */ + /* discard up to but not including the closing $ */ unsigned long rem = size - 3; + /* Point at first byte after the ":" */ cp = src + 3; + /* + * Throw away characters until either + * - we reach a "$" + * - we run out of bytes (rem == 0) + */ do { - ch = *cp++; + ch = *cp; if (ch == '$') break; + cp++; rem--; } while (rem); + /* If the above finished because it ran out of characters, then + * this is an incomplete keyword, so don't run the expansion */ if (!rem) continue; - size -= (cp - src); } else if (src[2] == '$') cp = src + 2; else + /* Anything other than "$Id:XXX$" or $Id$ and we skip the + * expansion */ continue; + /* cp is now pointing at the last $ of the keyword */ + memcpy(dst, "Id: ", 4); dst += 4; memcpy(dst, sha1_to_hex(sha1), 40); dst += 40; *dst++ = ' '; + + /* Adjust for the characters we've discarded */ size -= (cp - src); src = cp; + + /* Copy the final "$" */ *dst++ = *src++; size--; } From 20b3d206acbbb042c7ad5f42d36ff8d036a538c5 Mon Sep 17 00:00:00 2001 From: James Y Knight Date: Thu, 24 May 2007 00:37:06 -0400 Subject: [PATCH 38/55] Fix git-svn to handle svn not reporting the md5sum of a file, and test. Acked-by: Eric Wong Signed-off-by: Junio C Hamano --- git-svn.perl | 2 +- t/t9112-git-svn-md5less-file.sh | 45 +++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100755 t/t9112-git-svn-md5less-file.sh diff --git a/git-svn.perl b/git-svn.perl index eda9969f50..fa46236ae8 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -2477,7 +2477,7 @@ sub close_file { $md5->addfile($fh); my $got = $md5->hexdigest; die "Checksum mismatch: $path\n", - "expected: $exp\n got: $got\n" if ($got ne $exp); + "expected: $exp\n got: $got\n" if (defined $exp && $got ne $exp); sysseek($fh, 0, 0) or croak $!; if ($fb->{mode_b} == 120000) { sysread($fh, my $buf, 5) == 5 or croak $!; diff --git a/t/t9112-git-svn-md5less-file.sh b/t/t9112-git-svn-md5less-file.sh new file mode 100755 index 0000000000..08313bb545 --- /dev/null +++ b/t/t9112-git-svn-md5less-file.sh @@ -0,0 +1,45 @@ +test_description='test that git handles an svn repository with missing md5sums' + +. ./lib-git-svn.sh + +# Loading a node from a svn dumpfile without a Text-Content-Length +# field causes svn to neglect to store or report an md5sum. (it will +# calculate one if you had put Text-Content-Length: 0). This showed +# up in a repository creted with cvs2svn. + +cat > dumpfile.svn < Date: Sun, 27 May 2007 00:03:37 -0400 Subject: [PATCH 39/55] git-gui: Guess our share/git-gui/lib path at runtime if possible Johannes Sixt asked me to try to avoid embedding the runtime location of git-gui's library directory in the executable script. Not embedding it helps the MinGW to be relocatable to another directory should a user wish to install the programs in a directory other than the location the packager wanted them to be installed into. Most of this is a hack. We try to determine if the path of our master git-gui script will be able to locate the lib by ../share/git-gui/lib. This should be true if $(gitexecdir) and $(libdir) have the same prefix. If they do then we defer the assignment of $(libdir) until runtime, and we get it from $argv0 rather than embedding it into the script itself. Signed-off-by: Shawn O. Pearce --- Makefile | 12 ++++++++++-- git-gui.sh | 8 ++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index ee564219c0..3de0de1a23 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ ifndef gitexecdir endif ifndef sharedir - sharedir := $(dir $(gitexecdir))/share + sharedir := $(dir $(gitexecdir))share endif ifndef INSTALL @@ -53,12 +53,19 @@ TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH)) libdir ?= $(sharedir)/git-gui/lib libdir_SQ = $(subst ','\'',$(libdir)) +exedir = $(dir $(gitexecdir))share/git-gui/lib +exedir_SQ = $(subst ','\'',$(exedir)) + $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh $(QUIET_GEN)rm -f $@ $@+ && \ + if test '$(exedir_SQ)' = '$(libdir_SQ)'; then \ + GITGUI_RELATIVE=1; \ + fi && \ sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \ -e 's|^exec wish "$$0"|exec $(subst |,'\|',$(TCLTK_PATH_SQ)) "$$0"|' \ -e 's/@@GITGUI_VERSION@@/$(GITGUI_VERSION)/g' \ - -e 's|@@GITGUI_LIBDIR@@|$(libdir_SQ)|' \ + -e 's|@@GITGUI_RELATIVE@@|'$$GITGUI_RELATIVE'|' \ + -e $$GITGUI_RELATIVE's|@@GITGUI_LIBDIR@@|$(libdir_SQ)|' \ $@.sh >$@+ && \ chmod +x $@+ && \ mv $@+ $@ @@ -88,6 +95,7 @@ TRACK_VARS = \ $(subst ','\'',SHELL_PATH='$(SHELL_PATH_SQ)') \ $(subst ','\'',TCL_PATH='$(TCL_PATH_SQ)') \ $(subst ','\'',TCLTK_PATH='$(TCLTK_PATH_SQ)') \ + $(subst ','\'',gitexecdir='$(gitexecdir_SQ)') \ $(subst ','\'',libdir='$(libdir_SQ)') \ #end TRACK_VARS diff --git a/git-gui.sh b/git-gui.sh index cfc4c7f686..dba585111c 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -25,7 +25,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA} ## configure our library set oguilib {@@GITGUI_LIBDIR@@} -if {[string match @@GITGUI_*@@ $oguilib]} { +set oguirel {@@GITGUI_RELATIVE@@} +if {$oguirel eq {1}} { + set oguilib [file dirname [file dirname [file normalize $argv0]]] + set oguilib [file join $oguilib share git-gui lib] +} elseif {[string match @@* $oguirel]} { set oguilib [file join [file dirname [file normalize $argv0]] lib] } set idx [file join $oguilib tclIndex] @@ -55,7 +59,7 @@ if {$idx ne {}} { } else { set auto_path [concat [list $oguilib] $auto_path] } -unset -nocomplain fd idx +unset -nocomplain oguilib oguirel idx fd if {![catch {set _verbose $env(GITGUI_VERBOSE)}]} { unset _verbose From eb09626b94fb21c67f47f71f8bada0d4aed306f5 Mon Sep 17 00:00:00 2001 From: Johan Herland Date: Tue, 29 May 2007 01:21:25 +0200 Subject: [PATCH 40/55] Fix stupid typo in lookup_tag() Signed-off-by: Johan Herland Signed-off-by: Junio C Hamano --- tag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tag.c b/tag.c index 56a49f4fe1..e11a4cdc49 100644 --- a/tag.c +++ b/tag.c @@ -30,7 +30,7 @@ struct tag *lookup_tag(const unsigned char *sha1) if (!obj->type) obj->type = OBJ_TAG; if (obj->type != OBJ_TAG) { - error("Object %s is a %s, not a tree", + error("Object %s is a %s, not a tag", sha1_to_hex(sha1), typename(obj->type)); return NULL; } From 59d10247e444b752a993cf4aa2e0665bc633d32f Mon Sep 17 00:00:00 2001 From: Nguyen Thai Ngoc Duy Date: Mon, 28 May 2007 22:05:43 -0400 Subject: [PATCH 41/55] Makefile: Remove git-fsck and git-verify-pack from PROGRAMS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Those are builtins. Remove them from PROGRAMS variable Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 29243c6e8b..fb11fa1987 100644 --- a/Makefile +++ b/Makefile @@ -235,7 +235,7 @@ endif # ... and all the rest that could be moved out of bindir to gitexecdir PROGRAMS = \ - git-convert-objects$X git-fetch-pack$X git-fsck$X \ + git-convert-objects$X git-fetch-pack$X \ git-hash-object$X git-index-pack$X git-local-fetch$X \ git-fast-import$X \ git-merge-base$X \ @@ -246,7 +246,7 @@ PROGRAMS = \ git-show-index$X git-ssh-fetch$X \ git-ssh-upload$X git-unpack-file$X \ git-update-server-info$X \ - git-upload-pack$X git-verify-pack$X \ + git-upload-pack$X \ git-pack-redundant$X git-var$X \ git-merge-tree$X git-imap-send$X \ git-merge-recursive$X \ From 7faf068660f0a060066ccbc80f7debbba6bc2d76 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 27 May 2007 15:59:01 -0700 Subject: [PATCH 42/55] git-svn: avoid md5 calculation entirely if SVN doesn't provide one There's no point in calculating an MD5 if we're not going to use it. We'll also avoid the possibility of there being a bug in the Perl MD5 library not being able to handle zero-sized files. This is a followup to 20b3d206acbbb042c7ad5f42d36ff8d036a538c5, which allows us to track repositories that do not provide MD5 checksums. Signed-off-by: Eric Wong Signed-off-by: Junio C Hamano --- git-svn.perl | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/git-svn.perl b/git-svn.perl index fa46236ae8..e35006142a 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -2472,12 +2472,16 @@ sub close_file { my $hash; my $path = $self->git_path($fb->{path}); if (my $fh = $fb->{fh}) { - seek($fh, 0, 0) or croak $!; - my $md5 = Digest::MD5->new; - $md5->addfile($fh); - my $got = $md5->hexdigest; - die "Checksum mismatch: $path\n", - "expected: $exp\n got: $got\n" if (defined $exp && $got ne $exp); + if (defined $exp) { + seek($fh, 0, 0) or croak $!; + my $md5 = Digest::MD5->new; + $md5->addfile($fh); + my $got = $md5->hexdigest; + if ($got ne $exp) { + die "Checksum mismatch: $path\n", + "expected: $exp\n got: $got\n"; + } + } sysseek($fh, 0, 0) or croak $!; if ($fb->{mode_b} == 120000) { sysread($fh, my $buf, 5) == 5 or croak $!; From dfab71cb923d031715ebc3cf9f920d801250c552 Mon Sep 17 00:00:00 2001 From: Andy Parkins Date: Sun, 27 May 2007 11:52:11 +0100 Subject: [PATCH 43/55] Add test case for $Id$ expanded in the repository This test case would have caught the bug fixed by revision c23290d5. It puts various forms of $Id$ into a file in the repository, without allowing git to collapse them to uniformity. Then enables the $Id$ expansion on checkout, and checks that what is checked out has coped with the various forms. Signed-off-by: Andy Parkins Signed-off-by: Junio C Hamano --- t/t0021-conversion.sh | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/t/t0021-conversion.sh b/t/t0021-conversion.sh index 6c26fd829d..a839f4e074 100755 --- a/t/t0021-conversion.sh +++ b/t/t0021-conversion.sh @@ -45,4 +45,40 @@ test_expect_success check ' test "z$id" = "z$embedded" ' +# If an expanded ident ever gets into the repository, we want to make sure that +# it is collapsed before being expanded again on checkout +test_expect_success expanded_in_repo ' + { + echo "File with expanded keywords" + echo "\$Id\$" + echo "\$Id:\$" + echo "\$Id: 0000000000000000000000000000000000000000 \$" + echo "\$Id: NoSpaceAtEnd\$" + echo "\$Id:NoSpaceAtFront \$" + echo "\$Id:NoSpaceAtEitherEnd\$" + echo "\$Id: NoTerminatingSymbol" + } > expanded-keywords && + + { + echo "File with expanded keywords" + echo "\$Id: 4f21723e7b15065df7de95bd46c8ba6fb1818f4c \$" + echo "\$Id: 4f21723e7b15065df7de95bd46c8ba6fb1818f4c \$" + echo "\$Id: 4f21723e7b15065df7de95bd46c8ba6fb1818f4c \$" + echo "\$Id: 4f21723e7b15065df7de95bd46c8ba6fb1818f4c \$" + echo "\$Id: 4f21723e7b15065df7de95bd46c8ba6fb1818f4c \$" + echo "\$Id: 4f21723e7b15065df7de95bd46c8ba6fb1818f4c \$" + echo "\$Id: NoTerminatingSymbol" + } > expected-output && + + git add expanded-keywords && + git commit -m "File with keywords expanded" && + + echo "expanded-keywords ident" >> .gitattributes && + + rm -f expanded-keywords && + git checkout -- expanded-keywords && + cat expanded-keywords && + cmp expanded-keywords expected-output +' + test_done From c78974f7b6a6a0e9f848907620b4361ee088f7c2 Mon Sep 17 00:00:00 2001 From: Steffen Prohaska Date: Sat, 26 May 2007 21:16:27 +0200 Subject: [PATCH 44/55] user-manual: fixed typo in example Signed-off-by: Steffen Prohaska Signed-off-by: Junio C Hamano --- Documentation/user-manual.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/user-manual.txt b/Documentation/user-manual.txt index 52247aa713..4fabb8e2a9 100644 --- a/Documentation/user-manual.txt +++ b/Documentation/user-manual.txt @@ -872,7 +872,7 @@ Obviously, endless variations are possible; for example, to see all commits reachable from some head but not from any tag in the repository: ------------------------------------------------- -$ gitk ($ git show-ref --heads ) --not $( git show-ref --tags ) +$ gitk $( git show-ref --heads ) --not $( git show-ref --tags ) ------------------------------------------------- (See gitlink:git-rev-parse[1] for explanations of commit-selecting From 893c365abab7806354ab5b268e38e88ea81b8e38 Mon Sep 17 00:00:00 2001 From: Frank Lichtenheld Date: Sun, 27 May 2007 14:33:06 +0200 Subject: [PATCH 45/55] cvsserver: Correct inetd.conf example in asciidoc documentation While the given example worked, it made us look rather incompetent. Give the correct reason why one needs the more complex syntax and change the example to reflect that. Signed-off-by: Frank Lichtenheld Signed-off-by: Junio C Hamano --- Documentation/git-cvsserver.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Documentation/git-cvsserver.txt b/Documentation/git-cvsserver.txt index d22844ba49..9f0d990804 100644 --- a/Documentation/git-cvsserver.txt +++ b/Documentation/git-cvsserver.txt @@ -46,11 +46,13 @@ INSTALLATION cvspserver stream tcp nowait nobody git-cvsserver pserver ------ -Note: In some cases, you need to pass the 'pserver' argument twice for -git-cvsserver to see it. So the line would look like +Note: Some inetd servers let you specify the name of the executable +independently of the value of argv[0] (i.e. the name the program assumes +it was executed with). In this case the correct line in /etc/inetd.conf +looks like ------ - cvspserver stream tcp nowait nobody git-cvsserver pserver pserver + cvspserver stream tcp nowait nobody /usr/bin/git-cvsserver git-cvsserver pserver ------ No special setup is needed for SSH access, other than having GIT tools From 548428954aa088aecd88805aa5a8e64aee0d3e8b Mon Sep 17 00:00:00 2001 From: Frank Lichtenheld Date: Sun, 27 May 2007 14:33:07 +0200 Subject: [PATCH 46/55] cvsserver: Note that CVS_SERVER can also be specified as method variable Reasonably new versions of the cvs CLI client allow one to specifiy CVS_SERVER as a method variable directly in CVSROOT. This is way more convinient than using an environment variable since it gets saved in CVS/Root. Since I only discovered this by accident I guess there might be others out there that learnt CVS on the 1.11 series (or even earlier) and profit from such a note about cvs improvements in the last couple years. Signed-off-by: Frank Lichtenheld Signed-off-by: Junio C Hamano --- Documentation/git-cvsserver.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Documentation/git-cvsserver.txt b/Documentation/git-cvsserver.txt index 9f0d990804..ca7579d9f5 100644 --- a/Documentation/git-cvsserver.txt +++ b/Documentation/git-cvsserver.txt @@ -57,7 +57,17 @@ looks like ------ No special setup is needed for SSH access, other than having GIT tools in the PATH. If you have clients that do not accept the CVS_SERVER -env variable, you can rename git-cvsserver to cvs. +environment variable, you can rename git-cvsserver to cvs. + +Note: Newer cvs versions (>= 1.12.11) also support specifying +CVS_SERVER directly in CVSROOT like + +------ +cvs -d ":ext;CVS_SERVER=git-cvsserver:user@server/path/repo.git" co +------ +This has the advantage that it will be saved in your 'CVS/Root' files and +you don't need to worry about always setting the correct environment +variable. -- 2. For each repo that you want accessible from CVS you need to edit config in the repo and add the following section. From a192a909c0cdb8ea09b6513c4839fd6762989cb1 Mon Sep 17 00:00:00 2001 From: Frank Lichtenheld Date: Sun, 27 May 2007 14:33:08 +0200 Subject: [PATCH 47/55] cvsserver: Fix some typos in asciidoc documentation Signed-off-by: Frank Lichtenheld Signed-off-by: Junio C Hamano --- Documentation/git-cvsserver.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/git-cvsserver.txt b/Documentation/git-cvsserver.txt index ca7579d9f5..e5005f02f9 100644 --- a/Documentation/git-cvsserver.txt +++ b/Documentation/git-cvsserver.txt @@ -86,7 +86,7 @@ write access to the log file and to the database (see SSH, the users of course also need write access to the git repository itself. [[configaccessmethod]] -All configuration variables can also be overriden for a specific method of +All configuration variables can also be overridden for a specific method of access. Valid method names are "ext" (for SSH access) and "pserver". The following example configuration would disable pserver access while still allowing access over SSH. @@ -128,7 +128,7 @@ Database Backend git-cvsserver uses one database per git head (i.e. CVS module) to store information about the repository for faster access. The -database doesn't contain any persitent data and can be completly +database doesn't contain any persistent data and can be completely regenerated from the git repository at any time. The database needs to be updated (i.e. written to) after every commit. From 192a6be2a77ab3bf446237fdf6575b0aca863d9e Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Wed, 30 May 2007 10:32:19 -0700 Subject: [PATCH 48/55] fix signed range problems with hex conversions Make hexval_table[] "const". Also make sure that the accessor function hexval() does not access the table with out-of-range values by declaring its parameter "unsigned char", instead of "unsigned int". With this, gcc can just generate: movzbl (%rdi), %eax movsbl hexval_table(%rax),%edx movzbl 1(%rdi), %eax movsbl hexval_table(%rax),%eax sall $4, %edx orl %eax, %edx for the code to generate a byte from two hex characters. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- cache.h | 4 ++-- sha1_file.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cache.h b/cache.h index 7cedda684f..bea8cad5b2 100644 --- a/cache.h +++ b/cache.h @@ -302,8 +302,8 @@ extern int legacy_loose_object(unsigned char *); extern int has_pack_file(const unsigned char *sha1); extern int has_pack_index(const unsigned char *sha1); -extern signed char hexval_table[256]; -static inline unsigned int hexval(unsigned int c) +extern const signed char hexval_table[256]; +static inline unsigned int hexval(unsigned char c) { return hexval_table[c]; } diff --git a/sha1_file.c b/sha1_file.c index 523417027a..ae9bd1fc2f 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -32,7 +32,7 @@ const unsigned char null_sha1[20]; static unsigned int sha1_file_open_flag = O_NOATIME; -signed char hexval_table[256] = { +const signed char hexval_table[256] = { -1, -1, -1, -1, -1, -1, -1, -1, /* 00-07 */ -1, -1, -1, -1, -1, -1, -1, -1, /* 08-0f */ -1, -1, -1, -1, -1, -1, -1, -1, /* 10-17 */ From 86d14e1b1d1063fc943c71edc8b05e1ce32c1602 Mon Sep 17 00:00:00 2001 From: Jerald Fitzjerald Date: Wed, 30 May 2007 05:39:58 -0700 Subject: [PATCH 49/55] decode_85(): fix missing return. When the function detected an invalid base85 sequence, it issued an error message but forgot to return error status at that point and kept going. Signed-off-by: Jerald Fitzjerald Signed-off-by: Junio C Hamano --- base85.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base85.c b/base85.c index a6c41d597a..b88270f908 100644 --- a/base85.c +++ b/base85.c @@ -66,7 +66,7 @@ int decode_85(char *dst, const char *buffer, int len) */ if (0x03030303 < acc || 0xffffffff - de < (acc *= 85)) - error("invalid base85 sequence %.5s", buffer-5); + return error("invalid base85 sequence %.5s", buffer-5); acc += de; say1(" %08x", acc); From 90a36e581daa25949fd0ff68fc68ae5b705fc990 Mon Sep 17 00:00:00 2001 From: Frank Lichtenheld Date: Thu, 31 May 2007 02:35:36 +0200 Subject: [PATCH 50/55] git-config: Various small fixes to asciidoc documentation Add '' around the only mentioned commandline option that didn't have it. Make reference to section EXAMPLE a link and rename it to EXAMPLES because it actually contains a lot of examples. Signed-off-by: Frank Lichtenheld Signed-off-by: Junio C Hamano --- Documentation/git-config.txt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Documentation/git-config.txt b/Documentation/git-config.txt index 827a49970d..8f4149fd61 100644 --- a/Documentation/git-config.txt +++ b/Documentation/git-config.txt @@ -31,7 +31,7 @@ If you want to update or unset an option which can occur on multiple lines, a POSIX regexp `value_regex` needs to be given. Only the existing values that match the regexp are updated or unset. If you want to handle the lines that do *not* match the regex, just -prepend a single exclamation mark in front (see EXAMPLES). +prepend a single exclamation mark in front (see also <>). 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 @@ -48,7 +48,7 @@ This command will fail if: . the section or key is invalid, . you try to unset an option which does not exist, . you try to unset/set an option for which multiple lines match, or -. you use --global option without $HOME being properly set. +. you use '--global' option without $HOME being properly set. OPTIONS @@ -119,8 +119,10 @@ GIT_CONFIG_LOCAL:: from the global configuration file in addition to the given file. -EXAMPLE -------- + +[[EXAMPLES]] +EXAMPLES +-------- Given a .git/config like this: From 17014090036b9b996707dfca5af69f1e87bd2315 Mon Sep 17 00:00:00 2001 From: Frank Lichtenheld Date: Thu, 31 May 2007 02:35:37 +0200 Subject: [PATCH 51/55] git-config: Improve documentation of git-config file handling The description which files git-config uses and how the various command line options and environment variables affect its behaviour was incomplete, outdated and confusing. Signed-off-by: Frank Lichtenheld Signed-off-by: Junio C Hamano --- Documentation/git-config.txt | 66 ++++++++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 7 deletions(-) diff --git a/Documentation/git-config.txt b/Documentation/git-config.txt index 8f4149fd61..056b14724c 100644 --- a/Documentation/git-config.txt +++ b/Documentation/git-config.txt @@ -75,11 +75,22 @@ OPTIONS Like --get-all, but interprets the name as a regular expression. --global:: - Use global ~/.gitconfig file rather than the repository .git/config. + For writing options: write to global ~/.gitconfig file rather than + the repository .git/config. ++ +For reading options: read only from global ~/.gitconfig rather than +from all available files. ++ +See also <>. --system:: - Use system-wide $(prefix)/etc/gitconfig rather than the repository - .git/config. + For writing options: write to system-wide $(prefix)/etc/gitconfig + rather than the repository .git/config. ++ +For reading options: read only from system-wide $(prefix)/etc/gitconfig +rather than from all available files. ++ +See also <>. --remove-section:: Remove the given section from the configuration file. @@ -106,18 +117,59 @@ OPTIONS by 1024, 1048576, or 1073741824 prior to output. +[[FILES]] +FILES +----- + +There are three files where git-config will search for configuration +options: + +.git/config:: + Repository specific configuration file. (The filename is + of course relative to the repository root, not the working + directory.) + +~/.gitconfig:: + User-specific configuration file. Also called "global" + configuration file. + +$(prefix)/etc/gitconfig:: + System-wide configuration file. + +If no further options are given, all reading options will read all of these +files that are available. If the global or the system-wide configuration +file are not available they will be ignored. If the repository configuration +file is not available or readable, git-config will exit with a non-zero +error code. However, in neither case will an error message be issued. + +All writing options will per default write to the repository specific +configuration file. Note that this also affects options like '--replace-all' +and '--unset'. *git-config will only ever change one file at a time*. + +You can override these rules either by command line options or by environment +variables. The '--global' and the '--system' options will limit the file used +to the global or system-wide file respectively. The GIT_CONFIG environment +variable has a similar effect, but you can specify any filename you want. + +The GIT_CONFIG_LOCAL environment variable on the other hand only changes +the name used instead of the repository configuration file. The global and +the system-wide configuration files will still be read. (For writing options +this will obviously result in the same behavior as using GIT_CONFIG.) + + ENVIRONMENT ----------- GIT_CONFIG:: Take the configuration from the given file instead of .git/config. - Using the "--global" option forces this to ~/.gitconfig. + Using the "--global" option forces this to ~/.gitconfig. Using the + "--system" option forces this to $(prefix)/etc/gitconfig. GIT_CONFIG_LOCAL:: - Currently the same as $GIT_CONFIG; when Git will support global - configuration files, this will cause it to take the configuration - from the global configuration file in addition to the given file. + Take the configuration from the given file instead if .git/config. + Still read the global and the system-wide configuration files, though. +See also <>. [[EXAMPLES]] From 4159c5781303bb24d82be69b6a5de92d51d8d4f0 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Fri, 1 Jun 2007 05:10:30 -0400 Subject: [PATCH 52/55] Documentation: robustify asciidoc GIT_VERSION replacement Instead of using sed on the resulting file, we now have a git_version asciidoc attribute. This means that we don't pipe the output of asciidoc, which means we can detect build failures. Problem reported by Scott Lamb, solution suggested by Jonas Fonseca. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- Documentation/Makefile | 6 ++---- Documentation/asciidoc.conf | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Documentation/Makefile b/Documentation/Makefile index 3f92783d55..4064b38c44 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -112,8 +112,7 @@ clean: %.html : %.txt rm -f $@+ $@ $(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \ - $(ASCIIDOC_EXTRA) -o - $< | \ - sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' >$@+ + $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $< mv $@+ $@ %.1 %.5 %.7 : %.xml @@ -122,8 +121,7 @@ clean: %.xml : %.txt rm -f $@+ $@ $(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf \ - $(ASCIIDOC_EXTRA) -o - $< | \ - sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' >$@+ + $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $< mv $@+ $@ user-manual.xml: user-manual.txt user-manual.conf diff --git a/Documentation/asciidoc.conf b/Documentation/asciidoc.conf index fa7dc94845..60e15ba349 100644 --- a/Documentation/asciidoc.conf +++ b/Documentation/asciidoc.conf @@ -40,7 +40,7 @@ template::[header-declarations] {mantitle} {manvolnum} Git -@@GIT_VERSION@@ +{git_version} Git Manual From cedb8d5d33e6496cfc70493db841b3db886e8658 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Sat, 2 Jun 2007 10:08:54 -0700 Subject: [PATCH 53/55] Create a new manpage for the gitignore format, and reference it elsewhere Only git-ls-files(1) describes the gitignore format in detail, and it does so with reference to git-ls-files options. Most users don't use the plumbing command git-ls-files directly, and shouldn't have to look in its manpage for information on the gitignore format. Create a new manpage gitignore(5) (Documentation/gitignore.txt), and factor out the gitignore documentation into that file, changing it to refer to .gitignore and $GIT_DIR/info/exclude as used by porcelain commands. Reference gitignore(5) from other relevant manpages and documentation. Remove now-redundant information on exclude patterns from git-ls-files(1), leaving only information on how git-ls-files options specify exclude patterns and what precedence they have. Signed-off-by: Josh Triplett Signed-off-by: Junio C Hamano --- Documentation/Makefile | 2 +- Documentation/config.txt | 3 +- Documentation/git-ls-files.txt | 99 ++++-------------------- Documentation/git-read-tree.txt | 3 +- Documentation/git-status.txt | 8 +- Documentation/gitignore.txt | 116 ++++++++++++++++++++++++++++ Documentation/repository-layout.txt | 3 +- Documentation/user-manual.txt | 12 +-- 8 files changed, 145 insertions(+), 101 deletions(-) create mode 100644 Documentation/gitignore.txt diff --git a/Documentation/Makefile b/Documentation/Makefile index 4064b38c44..9cef4806d1 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -2,7 +2,7 @@ MAN1_TXT= \ $(filter-out $(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \ $(wildcard git-*.txt)) \ gitk.txt -MAN5_TXT=gitattributes.txt +MAN5_TXT=gitattributes.txt gitignore.txt MAN7_TXT=git.txt DOC_HTML=$(patsubst %.txt,%.html,$(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT)) diff --git a/Documentation/config.txt b/Documentation/config.txt index fdb71de9f6..7d9afe20f9 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -266,7 +266,8 @@ 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. + of files which are not meant to be tracked. See + gitlink:gitignore[5]. alias.*:: Command aliases for the gitlink:git[1] command wrapper - e.g. diff --git a/Documentation/git-ls-files.txt b/Documentation/git-ls-files.txt index 43e0d2266c..a78a9ff1b8 100644 --- a/Documentation/git-ls-files.txt +++ b/Documentation/git-ls-files.txt @@ -139,46 +139,24 @@ Exclude Patterns 'git-ls-files' can use a list of "exclude patterns" when traversing the directory tree and finding files to show when the -flags --others or --ignored are specified. +flags --others or --ignored are specified. gitlink:gitignore[5] +specifies the format of exclude patterns. -These exclude patterns come from these places: +These exclude patterns come from these places, in order: - 1. command line flag --exclude= specifies a single - pattern. + 1. The command line flag --exclude= specifies a + single pattern. Patterns are ordered in the same order + they appear in the command line. - 2. command line flag --exclude-from= specifies a list of - patterns stored in a file. + 2. The command line flag --exclude-from= specifies a + file containing a list of patterns. Patterns are ordered + in the same order they appear in the file. 3. command line flag --exclude-per-directory= specifies a name of the file in each directory 'git-ls-files' - examines, and if exists, its contents are used as an - additional list of patterns. - -An exclude pattern file used by (2) and (3) contains one pattern -per line. A line that starts with a '#' can be used as comment -for readability. - -There are three lists of patterns that are in effect at a given -time. They are built and ordered in the following way: - - * --exclude= from the command line; patterns are - ordered in the same order as they appear on the command line. - - * lines read from --exclude-from=; patterns are ordered - in the same order as they appear in the file. - - * When --exclude-per-directory= is specified, upon - entering a directory that has such a file, its contents are - appended at the end of the current "list of patterns". They - are popped off when leaving the directory. - -Each pattern in the pattern list specifies "a match pattern" and -optionally the fate; either a file that matches the pattern is -considered excluded or included. A filename is matched against -the patterns in the three lists; the --exclude-from list is -checked first, then the --exclude-per-directory list, and then -finally the --exclude list. The last match determines its fate. -If there is no match in the three lists, the fate is "included". + examines, normally `.gitignore`. Files in deeper + directories take precedence. Patterns are ordered in the + same order they appear in the files. A pattern specified on the command line with --exclude or read from the file specified with --exclude-from is relative to the @@ -186,58 +164,9 @@ top of the directory tree. A pattern read from a file specified by --exclude-per-directory is relative to the directory that the pattern file appears in. -An exclude pattern is of the following format: - - - an optional prefix '!' which means that the fate this pattern - specifies is "include", not the usual "exclude"; the - remainder of the pattern string is interpreted according to - the following rules. - - - if it does not contain a slash '/', it is a shell glob - pattern and used to match against the filename without - leading directories. - - - otherwise, it is a shell glob pattern, suitable for - consumption by fnmatch(3) with FNM_PATHNAME flag. I.e. a - slash in the pattern must match a slash in the pathname. - "Documentation/\*.html" matches "Documentation/git.html" but - not "ppc/ppc.html". As a natural exception, "/*.c" matches - "cat-file.c" but not "mozilla-sha1/sha1.c". - -An example: - --------------------------------------------------------------- - $ cat .git/info/exclude - # ignore objects and archives, anywhere in the tree. - *.[oa] - $ cat Documentation/.gitignore - # ignore generated html files, - *.html - # except foo.html which is maintained by hand - !foo.html - $ git-ls-files --ignored \ - --exclude='Documentation/*.[0-9]' \ - --exclude-from=.git/info/exclude \ - --exclude-per-directory=.gitignore --------------------------------------------------------------- - -Another example: - --------------------------------------------------------------- - $ cat .gitignore - vmlinux* - $ ls arch/foo/kernel/vm* - arch/foo/kernel/vmlinux.lds.S - $ echo '!/vmlinux*' >arch/foo/kernel/.gitignore --------------------------------------------------------------- - -The second .gitignore keeps `arch/foo/kernel/vmlinux.lds.S` file -from getting ignored. - - See Also -------- -gitlink:git-read-tree[1] +gitlink:git-read-tree[1], gitlink:gitignore[5] Author @@ -246,7 +175,7 @@ Written by Linus Torvalds Documentation -------------- -Documentation by David Greaves, Junio C Hamano and the git-list . +Documentation by David Greaves, Junio C Hamano, Josh Triplett, and the git-list . GIT --- diff --git a/Documentation/git-read-tree.txt b/Documentation/git-read-tree.txt index 019c8bef7a..acb57447a8 100644 --- a/Documentation/git-read-tree.txt +++ b/Documentation/git-read-tree.txt @@ -341,7 +341,8 @@ have finished your work-in-progress), attempt the merge again. See Also -------- -gitlink:git-write-tree[1]; gitlink:git-ls-files[1] +gitlink:git-write-tree[1]; gitlink:git-ls-files[1]; +gitlink:gitignore[5] Author diff --git a/Documentation/git-status.txt b/Documentation/git-status.txt index d7015387b5..1fd1af102a 100644 --- a/Documentation/git-status.txt +++ b/Documentation/git-status.txt @@ -42,11 +42,9 @@ mean the same thing and the latter is kept for backward compatibility) and `color.status.` 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'. - +See Also +-------- +gitlink:gitignore[5] Author ------ diff --git a/Documentation/gitignore.txt b/Documentation/gitignore.txt new file mode 100644 index 0000000000..ea79d74b88 --- /dev/null +++ b/Documentation/gitignore.txt @@ -0,0 +1,116 @@ +gitignore(5) +============ + +NAME +---- +gitignore - Specifies intentionally untracked files to ignore + +SYNOPSIS +-------- +$GIT_DIR/info/exclude, .gitignore + +DESCRIPTION +----------- + +A `gitignore` file specifies intentionally untracked files that +git should ignore. Each line in a `gitignore` file specifies a +pattern. + +When deciding whether to ignore a path, git normally checks +`gitignore` patterns from multiple sources, with the following +order of precedence: + + * Patterns read from the file specified by the configuration + variable 'core.excludesfile'. + + * Patterns read from `$GIT_DIR/info/exclude`. + + * Patterns read from a `.gitignore` file in the same directory + as the path, or in any parent directory, ordered from the + deepest such file to a file in the root of the repository. + These patterns match relative to the location of the + `.gitignore` file. A project normally includes such + `.gitignore` files in its repository, containing patterns for + files generated as part of the project build. + +The underlying git plumbing tools, such as +gitlink:git-ls-files[1] and gitlink:git-read-tree[1], read +`gitignore` patterns specified by command-line options, or from +files specified by command-line options. Higher-level git +tools, such as gitlink:git-status[1] and gitlink:git-add[1], +use patterns from the sources specified above. + +Patterns have the following format: + + - A blank line matches no files, so it can serve as a separator + for readability. + + - A line starting with # serves as a comment. + + - An optional prefix '!' which negates the pattern; any + matching file excluded by a previous pattern will become + included again. + + - If the pattern does not contain a slash '/', git treats it as + a shell glob pattern and checks for a match against the + pathname without leading directories. + + - Otherwise, git treats the pattern as a shell glob suitable + for consumption by fnmatch(3) with the FNM_PATHNAME flag: + wildcards in the pattern will not match a / in the pathname. + For example, "Documentation/\*.html" matches + "Documentation/git.html" but not + "Documentation/ppc/ppc.html". A leading slash matches the + beginning of the pathname; for example, "/*.c" matches + "cat-file.c" but not "mozilla-sha1/sha1.c". + +An example: + +-------------------------------------------------------------- + $ git-status + [...] + # Untracked files: + [...] + # Documentation/foo.html + # Documentation/gitignore.html + # file.o + # lib.a + # src/internal.o + [...] + $ cat .git/info/exclude + # ignore objects and archives, anywhere in the tree. + *.[oa] + $ cat Documentation/.gitignore + # ignore generated html files, + *.html + # except foo.html which is maintained by hand + !foo.html + $ git-status + [...] + # Untracked files: + [...] + # Documentation/foo.html + [...] +-------------------------------------------------------------- + +Another example: + +-------------------------------------------------------------- + $ cat .gitignore + vmlinux* + $ ls arch/foo/kernel/vm* + arch/foo/kernel/vmlinux.lds.S + $ echo '!/vmlinux*' >arch/foo/kernel/.gitignore +-------------------------------------------------------------- + +The second .gitignore prevents git from ignoring +`arch/foo/kernel/vmlinux.lds.S`. + +Documentation +------------- +Documentation by David Greaves, Junio C Hamano, Josh Triplett, +Frank Lichtenheld, and the git-list . + +GIT +--- +Part of the gitlink:git[7] suite diff --git a/Documentation/repository-layout.txt b/Documentation/repository-layout.txt index 0459bd9ca1..15221b5320 100644 --- a/Documentation/repository-layout.txt +++ b/Documentation/repository-layout.txt @@ -155,8 +155,7 @@ info/exclude:: exclude pattern list. `.gitignore` is the per-directory ignore file. `git status`, `git add`, `git rm` and `git clean` look at it but the core git commands do not look - at it. See also: gitlink:git-ls-files[1] `--exclude-from` - and `--exclude-per-directory`. + at it. See also: gitlink:gitignore[5]. remotes:: Stores shorthands to be used to give URL and default diff --git a/Documentation/user-manual.txt b/Documentation/user-manual.txt index 4fabb8e2a9..7eaafa80e9 100644 --- a/Documentation/user-manual.txt +++ b/Documentation/user-manual.txt @@ -1103,12 +1103,12 @@ showing up in the output of "`git status`", etc. Git therefore provides "exclude patterns" for telling git which files to actively ignore. Exclude patterns are thoroughly explained in the -"Exclude Patterns" section of the gitlink:git-ls-files[1] manual page, -but the heart of the concept is simply a list of files which git should -ignore. Entries in the list may contain globs to specify multiple files, -or may be prefixed by "`!`" to explicitly include (un-ignore) a previously -excluded (ignored) file (i.e. later exclude patterns override earlier ones). -The following example should illustrate such patterns: +gitlink:gitignore[5] manual page, but the heart of the concept is simply +a list of files which git should ignore. Entries in the list may contain +globs to specify multiple files, or may be prefixed by "`!`" to +explicitly include (un-ignore) a previously excluded (ignored) file +(i.e. later exclude patterns override earlier ones). The following +example should illustrate such patterns: ------------------------------------------------- # Lines starting with '#' are considered comments. From 996e2d6ea2626f55a59e70ac7305a02ce0171814 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Fri, 1 Jun 2007 17:08:12 -0400 Subject: [PATCH 54/55] Use =20 when rfc2047 encoding spaces. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Encode ' ' using '=20' even though rfc2047 allows using '_' for readability. Unfortunately, many programs do not understand this and just leave the underscore in place. Using '=20' seems to work better. [jc: with adjustment to t3901] Signed-off-by: Kristian Høgsberg Signed-off-by: Junio C Hamano --- commit.c | 10 +++++++--- t/t3901-i18n-patch.sh | 10 +++++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/commit.c b/commit.c index bee066fa32..5632e32685 100644 --- a/commit.c +++ b/commit.c @@ -511,12 +511,16 @@ static int add_rfc2047(char *buf, const char *line, int len, bp += i; for (i = 0; i < len; i++) { unsigned ch = line[i] & 0xFF; - if (is_rfc2047_special(ch)) { + /* + * We encode ' ' using '=20' even though rfc2047 + * allows using '_' for readability. Unfortunately, + * many programs do not understand this and just + * leave the underscore in place. + */ + if (is_rfc2047_special(ch) || ch == ' ') { sprintf(bp, "=%02X", ch); bp += 3; } - else if (ch == ' ') - *bp++ = '_'; else *bp++ = ch; } diff --git a/t/t3901-i18n-patch.sh b/t/t3901-i18n-patch.sh index a881797bc7..24bf0ee018 100755 --- a/t/t3901-i18n-patch.sh +++ b/t/t3901-i18n-patch.sh @@ -13,7 +13,7 @@ check_encoding () { while test "$i" -le $cnt do git format-patch --encoding=UTF-8 --stdout HEAD~$i..HEAD~$j | - grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" && + grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD=20=C3=B3=C3=BA?=" && git-cat-file commit HEAD~$j | case "$header" in 8859) @@ -73,9 +73,9 @@ test_expect_success 'format-patch output (ISO-8859-1)' ' git format-patch --stdout master..HEAD^ >out-l1 && git format-patch --stdout HEAD^ >out-l2 && grep "^Content-Type: text/plain; charset=ISO-8859-1" out-l1 && - grep "^From: =?ISO-8859-1?q?=C1=E9=ED_=F3=FA?=" out-l1 && + grep "^From: =?ISO-8859-1?q?=C1=E9=ED=20=F3=FA?=" out-l1 && grep "^Content-Type: text/plain; charset=ISO-8859-1" out-l2 && - grep "^From: =?ISO-8859-1?q?=C1=E9=ED_=F3=FA?=" out-l2 + grep "^From: =?ISO-8859-1?q?=C1=E9=ED=20=F3=FA?=" out-l2 ' test_expect_success 'format-patch output (UTF-8)' ' @@ -84,9 +84,9 @@ test_expect_success 'format-patch output (UTF-8)' ' git format-patch --stdout master..HEAD^ >out-u1 && git format-patch --stdout HEAD^ >out-u2 && grep "^Content-Type: text/plain; charset=UTF-8" out-u1 && - grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" out-u1 && + grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD=20=C3=B3=C3=BA?=" out-u1 && grep "^Content-Type: text/plain; charset=UTF-8" out-u2 && - grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" out-u2 + grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD=20=C3=B3=C3=BA?=" out-u2 ' test_expect_success 'rebase (U/U)' ' From 41cf68a85ca2a9199b32eb3932582b234fa474b4 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 2 Jun 2007 15:01:33 -0700 Subject: [PATCH 55/55] GIT 1.5.2.1 Signed-off-by: Junio C Hamano --- Documentation/RelNotes-1.5.2.1.txt | 53 ++++++++++++++++++++++++++++++ GIT-VERSION-GEN | 2 +- RelNotes | 2 +- 3 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 Documentation/RelNotes-1.5.2.1.txt diff --git a/Documentation/RelNotes-1.5.2.1.txt b/Documentation/RelNotes-1.5.2.1.txt new file mode 100644 index 0000000000..ebf20e22a7 --- /dev/null +++ b/Documentation/RelNotes-1.5.2.1.txt @@ -0,0 +1,53 @@ +GIT v1.5.2.1 Release Notes +========================== + +Fixes since v1.5.2 +------------------ + +* Bugfixes + + - Temporary files that are used when invoking external diff + programs did not tolerate a long TMPDIR. + + - git-daemon did not notice when it could not write into its + pid file. + + - git-status did not honor core.excludesFile configuration like + git-add did. + + - git-annotate did not work from a subdirectory while + git-blame did. + + - git-cvsserver should have disabled access to a repository + with "gitcvs.pserver.enabled = false" set even when + "gitcvs.enabled = true" was set at the same time. It + didn't. + + - git-cvsimport did not work correctly in a repository with + its branch heads were packed with pack-refs. + + - ident unexpansion to squash "$Id: xxx $" that is in the + repository copy removed incorrect number of bytes. + + - git-svn misbehaved when the subversion repository did not + provide MD5 checksums for files. + + - git rebase (and git am) misbehaved on commits that have '\n' + (literally backslash and en, not a linefeed) in the title. + + - code to decode base85 used in binary patches had one error + return codepath wrong. + + - RFC2047 Q encoding output by git-format-patch used '_' for a + space, which is not understood by some programs. It uses =20 + which is safer. + + - git-fastimport --import-marks was broken; fixed. + + - A lot of documentation updates, clarifications and fixes. + +-- +exec >/var/tmp/1 +O=v1.5.2-65-g996e2d6 +echo O=`git describe refs/heads/maint` +git shortlog --no-merges $O..refs/heads/maint diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN index 06c360b267..bd30398dd3 100755 --- a/GIT-VERSION-GEN +++ b/GIT-VERSION-GEN @@ -1,7 +1,7 @@ #!/bin/sh GVF=GIT-VERSION-FILE -DEF_VER=v1.5.2.GIT +DEF_VER=v1.5.2.1.GIT LF=' ' diff --git a/RelNotes b/RelNotes index c543b1d1ee..403fb97037 120000 --- a/RelNotes +++ b/RelNotes @@ -1 +1 @@ -Documentation/RelNotes-1.5.2.txt \ No newline at end of file +Documentation/RelNotes-1.5.2.1.txt \ No newline at end of file