From d3b1785f3fe681f6837a6110008af98003f675d3 Mon Sep 17 00:00:00 2001 From: Alex Riesen Date: Mon, 22 Jan 2007 17:14:56 +0100 Subject: [PATCH 01/12] Insert ACTIVESTATE_STRING in Git.pm Also add "git" to the pipe parameters, otherwise it does not work at all, as no git commands are usable out of git context. Signed-off-by: Alex Riesen Signed-off-by: Junio C Hamano --- perl/Git.pm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/perl/Git.pm b/perl/Git.pm index 3474ad320f..58414e3ec8 100644 --- a/perl/Git.pm +++ b/perl/Git.pm @@ -736,7 +736,7 @@ sub _command_common_pipe { _check_valid_cmd($cmd); my $fh; - if ($^O eq '##INSERT_ACTIVESTATE_STRING_HERE##') { + if ($^O eq 'MSWin32') { # ActiveState Perl #defined $opts{STDERR} and # warn 'ignoring STDERR option - running w/ ActiveState'; @@ -809,8 +809,9 @@ sub TIEHANDLE { # FIXME: This is probably horrible idea and the thing will explode # at the moment you give it arguments that require some quoting, # but I have no ActiveState clue... --pasky - my $cmdline = join " ", @params; - my @data = qx{$cmdline}; + # Let's just hope ActiveState Perl does at least the quoting + # correctly. + my @data = qx{git @params}; bless { i => 0, data => \@data }, $class; } From bed118d6bb6dee92180469466dfa265265678dd4 Mon Sep 17 00:00:00 2001 From: Alex Riesen Date: Mon, 22 Jan 2007 17:16:05 +0100 Subject: [PATCH 02/12] Force Activestate Perl to tie git command pipe handle to a handle class Otherwise it tries to tie it to a scalar and complains about missing method. Dunno why, may be ActiveState brokenness again. Signed-off-by: Alex Riesen Acked-by: Petr Baudis Signed-off-by: Junio C Hamano --- perl/Git.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/perl/Git.pm b/perl/Git.pm index 58414e3ec8..2f6b59a43b 100644 --- a/perl/Git.pm +++ b/perl/Git.pm @@ -742,7 +742,13 @@ sub _command_common_pipe { # warn 'ignoring STDERR option - running w/ ActiveState'; $direction eq '-|' or die 'input pipe for ActiveState not implemented'; - tie ($fh, 'Git::activestate_pipe', $cmd, @args); + # the strange construction with *ACPIPE is just to + # explain the tie below that we want to bind to + # a handle class, not scalar. It is not known if + # it is something specific to ActiveState Perl or + # just a Perl quirk. + tie (*ACPIPE, 'Git::activestate_pipe', $cmd, @args); + $fh = *ACPIPE; } else { my $pid = open($fh, $direction); From 67e4baf82679e6362d950f6a80a9a261cf266555 Mon Sep 17 00:00:00 2001 From: Alex Riesen Date: Mon, 22 Jan 2007 15:58:03 +0100 Subject: [PATCH 03/12] Cleanup uninitialized value in chomp which happens if you use ActiveState Perl and a pipe workaround specially for it. Signed-off-by: Alex Riesen Signed-off-by: Junio C Hamano --- perl/Git.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/perl/Git.pm b/perl/Git.pm index 2f6b59a43b..c1729bafd2 100644 --- a/perl/Git.pm +++ b/perl/Git.pm @@ -275,7 +275,7 @@ sub command { } else { my @lines = <$fh>; - chomp @lines; + defined and chomp for @lines; try { _cmd_close($fh, $ctx); } catch Git::Error::Command with { From bf3f67ba718393fb2b5fd5d4fc861029d4578a8a Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 22 Jan 2007 12:20:14 -0800 Subject: [PATCH 04/12] cvsimport: activate -a option, really. An earlier commit ded9f400 added $opt_a support to disable the cvsps grace period mechanism, but forgot to tell the option parser about it. Signed-off-by: Junio C Hamano --- git-cvsimport.perl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-cvsimport.perl b/git-cvsimport.perl index 35ef0c0ee5..6c9fbfec3a 100755 --- a/git-cvsimport.perl +++ b/git-cvsimport.perl @@ -85,7 +85,7 @@ sub write_author_info($) { close ($f); } -getopts("hivmkuo:d:p:C:z:s:M:P:A:S:L:") or usage(); +getopts("haivmkuo:d:p:C:z:s:M:P:A:S:L:") or usage(); usage if $opt_h; @ARGV <= 1 or usage(); From e136f33b5ff9b2293a61073295b0294fad8e6e42 Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Mon, 22 Jan 2007 16:25:47 +0100 Subject: [PATCH 05/12] Documentation/config.txt: Document config file syntax better Separate part of Documentation/config.txt which deals with git config file syntax into "Syntax" subsection, and expand it. Add information about subsections, boolean values, escaping and escape sequences in string values, and continuing variable value on the next line. Add also proxy settings to config file example to show example of partially enclosed in double quotes string value. Parts based on comments by Junio C Hamano, Johannes Schindelin, config.c, and the smb.conf(5) man page. Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano --- Documentation/config.txt | 76 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 69 insertions(+), 7 deletions(-) diff --git a/Documentation/config.txt b/Documentation/config.txt index f1f409d24b..77a2b16416 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -14,14 +14,72 @@ dot-separated segment and the section name is everything before the last dot. The variable names are case-insensitive and only alphanumeric characters are allowed. Some variables may appear multiple times. +Syntax +~~~~~~ + The syntax is fairly flexible and permissive; whitespaces are mostly -ignored. The '#' and ';' characters begin comments to the end of line, -blank lines are ignored, lines containing strings enclosed in square -brackets start sections and all the other lines are recognized -as setting variables, in the form 'name = value'. If there is no equal -sign on the line, the entire line is taken as 'name' and the variable -is recognized as boolean "true". String values may be entirely or partially -enclosed in double quotes; some variables may require special value format. +ignored. The '#' and ';' characters begin comments to the end of line, +blank lines are ignored. + +The file consists of sections and variables. A section begins with +the name of the section in square brackets and continues until the next +section begins. Section names are not case sensitive. Only alphanumeric +characters, '`-`' and '`.`' are allowed in section names. Each variable +must belong to some section, which means that there must be section +header before first setting of a variable. + +Sections can be further divided into subsections. To begin a subsection +put its name in double quotes, separated by space from the section name, +in the section header, like in example below: + +-------- + [section "subsection"] + +-------- + +Subsection names can contain any characters (doublequote '`"`', backslash +'`\`' and newline have to be entered escaped as '`\"`', '`\\`' and '`\n`', +respecitvely) and are case sensitive. Section header cannot span multiple +lines. Variables may belong directly to a section or to a given subsection. +You can have `[section]` if you have `[section "subsection"]`, but you +don't need to. + +There is also (case insensitive) alternative `[section.subsection]` syntax. +In this syntax subsection names follow the same restrictions as for section +name. + +All the other lines are recognized as setting variables, in the form +'name = value'. If there is no equal sign on the line, the entire line +is taken as 'name' and the variable is recognized as boolean "true". +The variable names are case-insensitive and only alphanumeric +characters and '`-`' are allowed. There can be more than one value +for a given variable; we say then that variable is multivalued. + +Leading and trailing whitespace in a variable value is discarded. +Internal whitespace within a variable value is retained verbatim. + +The values following the equals sign in variable assign are all either +a string, an integer, or a boolean. Boolean values may be given as yes/no, +0/1 or true/false. Case is not significant in boolean values, when +converting value to the canonical form using '--bool' type specifier; +`git-repo-config` will ensure that the output is "true" or "false". + +String values may be entirely or partially enclosed in double quotes. +You need to enclose variable value in double quotes if you want to +preserve leading or trailing whitespace, or if variable value contains +beginning of comment characters (if it contains '#' or ';'). +Double quote '`"`' and backslash '`\`' characters in variable value must +be escaped: use '`\"`' for '`"`' and '`\\`' for '`\`'. + +The following escape sequences (beside '`\"`' and '`\\`') are recognized: +'`\n`' for newline character (NL), '`\t`' for horizontal tabulation (HT, TAB) +and '`\b`' for backspace (BS). No other char escape sequence, nor octal +char sequences are valid. + +Variable value ending in a '`\`' is continued on the next line in the +customary UNIX fashion. + +Some variables may require special value format. Example ~~~~~~~ @@ -40,6 +98,10 @@ Example remote = origin merge = refs/heads/devel + # Proxy settings + [core] + gitProxy="ssh" for "ssh://kernel.org/" + gitProxy=default-proxy ; for the rest Variables ~~~~~~~~~ From 8276c0070f8f8959ab4b6ec458fa0740e9abda9e Mon Sep 17 00:00:00 2001 From: Peter Eriksen Date: Mon, 22 Jan 2007 21:29:45 +0100 Subject: [PATCH 06/12] sha1_file.c: Avoid multiple calls to find_pack_entry(). We used to call find_pack_entry() twice from read_sha1_file() in order to avoid printing an error message, when the object did not exist. This is fixed by moving the call to error() to the only place it really could be called. Signed-off-by: Peter Eriksen Signed-off-by: Junio C Hamano --- sha1_file.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/sha1_file.c b/sha1_file.c index 3025440941..43ff402380 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -1469,21 +1469,20 @@ static void *read_packed_sha1(const unsigned char *sha1, char *type, unsigned lo { struct pack_entry e; - if (!find_pack_entry(sha1, &e, NULL)) { - error("cannot read sha1_file for %s", sha1_to_hex(sha1)); + if (!find_pack_entry(sha1, &e, NULL)) return NULL; - } - return unpack_entry(e.p, e.offset, type, size); + else + return unpack_entry(e.p, e.offset, type, size); } void * read_sha1_file(const unsigned char *sha1, char *type, unsigned long *size) { unsigned long mapsize; void *map, *buf; - struct pack_entry e; - if (find_pack_entry(sha1, &e, NULL)) - return read_packed_sha1(sha1, type, size); + buf = read_packed_sha1(sha1, type, size); + if (buf) + return buf; map = map_sha1_file(sha1, &mapsize); if (map) { buf = unpack_sha1_file(map, mapsize, type, size); @@ -1491,9 +1490,7 @@ void * read_sha1_file(const unsigned char *sha1, char *type, unsigned long *size return buf; } reprepare_packed_git(); - if (find_pack_entry(sha1, &e, NULL)) - return read_packed_sha1(sha1, type, size); - return NULL; + return read_packed_sha1(sha1, type, size); } void *read_object_with_reference(const unsigned char *sha1, @@ -1781,6 +1778,8 @@ static void *repack_object(const unsigned char *sha1, unsigned long *objsize) /* need to unpack and recompress it by itself */ unpacked = read_packed_sha1(sha1, type, &len); + if (!unpacked) + error("cannot read sha1_file for %s", sha1_to_hex(sha1)); hdrlen = sprintf(hdr, "%s %lu", type, len) + 1; From cea70cf881290741da59c2e36050c723e6c9309d Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 22 Jan 2007 12:25:30 -0800 Subject: [PATCH 07/12] git-svn: remove leading slash when printing removed directories Not sure why it was there in the first place, we always do our work relative to the URL we're connected to; even if that URL is the root of the repository, so the leading slash is pointless... Lets be consistent when printing things for the user to see. Signed-off-by: Eric Wong Signed-off-by: Junio C Hamano --- git-svn.perl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-svn.perl b/git-svn.perl index b8ede9cbae..83ec03d478 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -2856,7 +2856,7 @@ sub rmdirs { foreach my $d (sort { $b =~ tr#/#/# <=> $a =~ tr#/#/# } keys %$rm) { $self->close_directory($bat->{$d}, $p); my ($dn) = ($d =~ m#^(.*?)/?(?:[^/]+)$#); - print "\tD+\t/$d/\n" unless $q; + print "\tD+\t$d/\n" unless $q; $self->SUPER::delete_entry($d, $r, $bat->{$dn}, $p); delete $bat->{$d}; } From 5e207b4bf837f0ac4e76a925b1c5cb23326de492 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 22 Jan 2007 16:25:15 -0800 Subject: [PATCH 08/12] .mailmap: fix screw-ups in Uwe's name Signed-off-by: Junio C Hamano --- .mailmap | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.mailmap b/.mailmap index 2c658f42f5..c7a3a75f33 100644 --- a/.mailmap +++ b/.mailmap @@ -30,7 +30,9 @@ Robert Fitzsimons Santi Béjar Sean Estabrooks Shawn O. Pearce +Theodore Ts'o Tony Luck +Uwe Kleine-König Ville Skyttä YOSHIFUJI Hideaki anonymous From 83e24dce148fd384cbfb01cf718ec32618f6d8b3 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 22 Jan 2007 13:03:31 -0800 Subject: [PATCH 09/12] [PATCH] honor --author even with --amend, -C, and -c. Earlier code discarded GIT_AUTHOR_DATE taken from the base commit when --author was specified. This was often wrong as that use is likely to fix the spelling of author's name. Signed-off-by: Junio C Hamano --- git-commit.sh | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/git-commit.sh b/git-commit.sh index e23918cd6c..6f4dcdbccc 100755 --- a/git-commit.sh +++ b/git-commit.sh @@ -462,15 +462,7 @@ if test -f "$GIT_DIR/MERGE_HEAD" && test -z "$no_edit"; then fi >>"$GIT_DIR"/COMMIT_EDITMSG # Author -if test '' != "$force_author" -then - GIT_AUTHOR_NAME=`expr "z$force_author" : 'z\(.*[^ ]\) *<.*'` && - GIT_AUTHOR_EMAIL=`expr "z$force_author" : '.*\(<.*\)'` && - test '' != "$GIT_AUTHOR_NAME" && - test '' != "$GIT_AUTHOR_EMAIL" || - die "malformed --author parameter" - export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL -elif test '' != "$use_commit" +if test '' != "$use_commit" then pick_author_script=' /^author /{ @@ -501,6 +493,15 @@ then export GIT_AUTHOR_EMAIL export GIT_AUTHOR_DATE fi +if test '' != "$force_author" +then + GIT_AUTHOR_NAME=`expr "z$force_author" : 'z\(.*[^ ]\) *<.*'` && + GIT_AUTHOR_EMAIL=`expr "z$force_author" : '.*\(<.*\)'` && + test '' != "$GIT_AUTHOR_NAME" && + test '' != "$GIT_AUTHOR_EMAIL" || + die "malformed --author parameter" + export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL +fi PARENTS="-p HEAD" if test -z "$initial_commit" From 90f70a910ac77cab7bc1b9a6c4b233add98a58c7 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Mon, 22 Jan 2007 22:38:28 -0500 Subject: [PATCH 10/12] format-patch: fix bug with --stdout in a subdirectory We set the output directory to the git subdirectory prefix if one has not already been specified. However, in the case of --stdout, we explicitly _don't_ want the output directory to be set. The result was that "git-format-patch --stdout" in a directory besides the project root produced the "standard output, or directory, which one?" error message. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- builtin-log.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin-log.c b/builtin-log.c index 13a3f9b25d..503cd1e2be 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -476,7 +476,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) if (!rev.diffopt.text) rev.diffopt.binary = 1; - if (!output_directory) + if (!output_directory && !use_stdout) output_directory = prefix; if (output_directory) { From 222664e74dec10303bfa0c99e88f31563fdc6952 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Mon, 22 Jan 2007 22:21:15 -0500 Subject: [PATCH 11/12] contrib/vim: update syntax for changed commit template Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- contrib/vim/syntax/gitcommit.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/vim/syntax/gitcommit.vim b/contrib/vim/syntax/gitcommit.vim index d911efbb4b..332121b40e 100644 --- a/contrib/vim/syntax/gitcommit.vim +++ b/contrib/vim/syntax/gitcommit.vim @@ -1,7 +1,7 @@ syn region gitLine start=/^#/ end=/$/ -syn region gitCommit start=/^# Added but not yet committed:$/ end=/^#$/ contains=gitHead,gitCommitFile +syn region gitCommit start=/^# Changes to be committed:$/ end=/^#$/ contains=gitHead,gitCommitFile syn region gitHead contained start=/^# (.*)/ end=/^#$/ -syn region gitChanged start=/^# Changed but not added:/ end=/^#$/ contains=gitHead,gitChangedFile +syn region gitChanged start=/^# Changed but not updated:/ end=/^#$/ contains=gitHead,gitChangedFile syn region gitUntracked start=/^# Untracked files:/ end=/^#$/ contains=gitHead,gitUntrackedFile syn match gitCommitFile contained /^#\t.*/hs=s+2 From c9a899256920b3266bb29f9d22bf6b9ab1b5a377 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 22 Jan 2007 21:39:03 -0800 Subject: [PATCH 12/12] reflog gc: a tag that does not point at a commit is not a crime. Although unusual, tags can point at any object. Warning only once is fine, but warning every time about the same tag gets annoying. Signed-off-by: Junio C Hamano --- builtin-reflog.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/builtin-reflog.c b/builtin-reflog.c index 62e0e96a67..b443ed9ef6 100644 --- a/builtin-reflog.c +++ b/builtin-reflog.c @@ -263,9 +263,6 @@ static int expire_reflog(const char *ref, const unsigned char *sha1, int unused, } cb.ref_commit = lookup_commit_reference_gently(sha1, 1); - if (!cb.ref_commit) - fprintf(stderr, - "warning: ref '%s' does not point at a commit\n", ref); cb.ref = ref; cb.cmd = cmd; for_each_reflog_ent(ref, expire_reflog_ent, &cb);