diff options
-rw-r--r-- | Documentation/technical/pack-format.txt | 11 | ||||
-rw-r--r-- | exec_cmd.c | 36 | ||||
-rwxr-xr-x | git-svnimport.perl | 11 | ||||
-rw-r--r-- | mailsplit.c | 2 |
4 files changed, 43 insertions, 17 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 diff --git a/exec_cmd.c b/exec_cmd.c index 44bb2f23de..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; } @@ -32,22 +32,25 @@ 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; - if (!exec_dir) continue; + if (!exec_dir || !*exec_dir) continue; 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; 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 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 ) |