From 347f1d2608471cbc64f1cf25943f8d6f89256d2c Mon Sep 17 00:00:00 2001 From: Salikh Zakirov Date: Sat, 27 May 2006 21:57:29 +0400 Subject: [PATCH 1/5] Fixed Cygwin CR-munging problem in mailsplit Do not open mailbox file as fopen(..., "rt") as this strips CR characters from the diff, thus breaking the patch context for changes in CRLF files. Signed-off-by: Salikh Zakirov Signed-off-by: Junio C Hamano --- mailsplit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mailsplit.c b/mailsplit.c index c529e2d060..70a569c12a 100644 --- a/mailsplit.c +++ b/mailsplit.c @@ -162,7 +162,7 @@ int main(int argc, const char **argv) while (*argp) { const char *file = *argp++; - FILE *f = !strcmp(file, "-") ? stdin : fopen(file, "rt"); + FILE *f = !strcmp(file, "-") ? stdin : fopen(file, "r"); int file_done = 0; if ( !f ) From d6859901012535b3781e5332923ede51d5977395 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Tue, 30 May 2006 18:58:52 +0400 Subject: [PATCH 2/5] execv_git_cmd: Fix stack buffer overflow. Signed-off-by: Dmitry V. Levin Signed-off-by: Junio C Hamano --- exec_cmd.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/exec_cmd.c b/exec_cmd.c index 44bb2f23de..12eb36494c 100644 --- a/exec_cmd.c +++ b/exec_cmd.c @@ -32,12 +32,14 @@ const char *git_exec_path(void) int execv_git_cmd(const char **argv) { char git_command[PATH_MAX + 1]; - int len, i; + int i; const char *paths[] = { current_exec_path, getenv("GIT_EXEC_PATH"), builtin_exec_path }; for (i = 0; i < ARRAY_SIZE(paths); ++i) { + size_t len; + int rc; const char *exec_dir = paths[i]; const char *tmp; @@ -46,8 +48,9 @@ int execv_git_cmd(const char **argv) if (*exec_dir != '/') { if (!getcwd(git_command, sizeof(git_command))) { fprintf(stderr, "git: cannot determine " - "current directory\n"); - exit(1); + "current directory: %s\n", + strerror(errno)); + break; } len = strlen(git_command); @@ -57,17 +60,28 @@ int execv_git_cmd(const char **argv) while (*exec_dir == '/') exec_dir++; } - snprintf(git_command + len, sizeof(git_command) - len, - "/%s", exec_dir); + + rc = snprintf(git_command + len, + sizeof(git_command) - len, "/%s", + exec_dir); + if (rc < 0 || rc >= sizeof(git_command) - len) { + fprintf(stderr, "git: command name given " + "is too long.\n"); + break; + } } else { + if (strlen(exec_dir) + 1 > sizeof(git_command)) { + fprintf(stderr, "git: command name given " + "is too long.\n"); + break; + } strcpy(git_command, exec_dir); } len = strlen(git_command); - len += snprintf(git_command + len, sizeof(git_command) - len, - "/git-%s", argv[0]); - - if (sizeof(git_command) <= len) { + rc = snprintf(git_command + len, sizeof(git_command) - len, + "/git-%s", argv[0]); + if (rc < 0 || rc >= sizeof(git_command) - len) { fprintf(stderr, "git: command name given is too long.\n"); break; From 2b6016263c984b71b29373fc9354d497cd51947d Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Mon, 29 May 2006 04:34:34 +0400 Subject: [PATCH 3/5] git_exec_path, execv_git_cmd: ignore empty environment variables Ignoring empty environment variables is good common practice. Ignoring --exec-path with empty argument won't harm, too: if user means current directory, there is a "--exec-path=." Signed-off-by: Dmitry V. Levin Signed-off-by: Junio C Hamano --- exec_cmd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exec_cmd.c b/exec_cmd.c index 12eb36494c..c1539d12ce 100644 --- a/exec_cmd.c +++ b/exec_cmd.c @@ -21,7 +21,7 @@ const char *git_exec_path(void) return current_exec_path; env = getenv("GIT_EXEC_PATH"); - if (env) { + if (env && *env) { return env; } @@ -43,7 +43,7 @@ int execv_git_cmd(const char **argv) const char *exec_dir = paths[i]; const char *tmp; - if (!exec_dir) continue; + if (!exec_dir || !*exec_dir) continue; if (*exec_dir != '/') { if (!getcwd(git_command, sizeof(git_command))) { From 1361fa3e49717de9588e6d925073eb6885cedaa3 Mon Sep 17 00:00:00 2001 From: Shawn Pearce Date: Mon, 29 May 2006 03:17:18 -0400 Subject: [PATCH 4/5] Improved pack format documentation. While trying to implement a pack reader in Java I was mislead by some facts listed in this documentation as well as found a few details to be missing about the pack header. Signed-off-by: Shawn O. Pearce Signed-off-by: Junio C Hamano --- Documentation/technical/pack-format.txt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Documentation/technical/pack-format.txt b/Documentation/technical/pack-format.txt index ed2decc107..0e1ffb2427 100644 --- a/Documentation/technical/pack-format.txt +++ b/Documentation/technical/pack-format.txt @@ -5,8 +5,13 @@ GIT pack format - The header appears at the beginning and consists of the following: - 4-byte signature - 4-byte version number (network byte order) + 4-byte signature: + The signature is: {'P', 'A', 'C', 'K'} + + 4-byte version number (network byte order): + GIT currently accepts version number 2 or 3 but + generates version 2 only. + 4-byte number of objects contained in the pack (network byte order) Observation: we cannot have more than 4G versions ;-) and @@ -41,7 +46,7 @@ GIT pack format 8-byte integers to go beyond 4G objects per pack, but it is not strictly necessary. - - The header is followed by sorted 28-byte entries, one entry + - The header is followed by sorted 24-byte entries, one entry per object in the pack. Each entry is: 4-byte network byte order integer, recording where the From 65160b8b04f814ab5b2573b32605320ff875f99e Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Wed, 31 May 2006 12:32:08 +0200 Subject: [PATCH 5/5] git-svnimport: Improved detection of merges. The regexes detecting merges (while still relying on the commit messages, though) have been improved to catch saner (and hopefully more) messages. The old regex was so generic that it often matched something else and missed the actual merge-message. Also, the regex given with the `-M' commandline-option is checked first: Explicitely given regexes should be considered better than the builtin ones, and should therefore be given a chance to match a message first. Signed-off-by: Junio C Hamano --- git-svnimport.perl | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/git-svnimport.perl b/git-svnimport.perl index 61f559f0a8..38ac732ca9 100755 --- a/git-svnimport.perl +++ b/git-svnimport.perl @@ -63,10 +63,17 @@ my $svn_dir = $ARGV[1]; our @mergerx = (); if ($opt_m) { - @mergerx = ( qr/\W(?:from|of|merge|merging|merged) (\w+)/i ); + my $branch_esc = quotemeta ($branch_name); + my $trunk_esc = quotemeta ($trunk_name); + @mergerx = + ( + qr!\b(?:merg(?:ed?|ing))\b.*?\b((?:(?<=$branch_esc/)[\w\.\-]+)|(?:$trunk_esc))\b!i, + qr!\b(?:from|of)\W+((?:(?<=$branch_esc/)[\w\.\-]+)|(?:$trunk_esc))\b!i, + qr!\b(?:from|of)\W+(?:the )?([\w\.\-]+)[-\s]branch\b!i + ); } if ($opt_M) { - push (@mergerx, qr/$opt_M/); + unshift (@mergerx, qr/$opt_M/); } # Absolutize filename now, since we will have chdir'ed by the time we