Merge branch 'ff/svnimport' into next

* ff/svnimport:
  git-svnimport: Improved detection of merges.
  Improved pack format documentation.
  git_exec_path, execv_git_cmd: ignore empty environment variables
  execv_git_cmd: Fix stack buffer overflow.
  Fixed Cygwin CR-munging problem in mailsplit
This commit is contained in:
Junio C Hamano
2006-05-31 14:26:39 -07:00
4 changed files with 43 additions and 17 deletions

View File

@ -5,8 +5,13 @@ GIT pack format
- The header appears at the beginning and consists of the following: - The header appears at the beginning and consists of the following:
4-byte signature 4-byte signature:
4-byte version number (network byte order) 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) 4-byte number of objects contained in the pack (network byte order)
Observation: we cannot have more than 4G versions ;-) and 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 8-byte integers to go beyond 4G objects per pack, but it is
not strictly necessary. 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: per object in the pack. Each entry is:
4-byte network byte order integer, recording where the 4-byte network byte order integer, recording where the

View File

@ -21,7 +21,7 @@ const char *git_exec_path(void)
return current_exec_path; return current_exec_path;
env = getenv("GIT_EXEC_PATH"); env = getenv("GIT_EXEC_PATH");
if (env) { if (env && *env) {
return env; return env;
} }
@ -32,22 +32,25 @@ const char *git_exec_path(void)
int execv_git_cmd(const char **argv) int execv_git_cmd(const char **argv)
{ {
char git_command[PATH_MAX + 1]; char git_command[PATH_MAX + 1];
int len, i; int i;
const char *paths[] = { current_exec_path, const char *paths[] = { current_exec_path,
getenv("GIT_EXEC_PATH"), getenv("GIT_EXEC_PATH"),
builtin_exec_path }; builtin_exec_path };
for (i = 0; i < ARRAY_SIZE(paths); ++i) { for (i = 0; i < ARRAY_SIZE(paths); ++i) {
size_t len;
int rc;
const char *exec_dir = paths[i]; const char *exec_dir = paths[i];
const char *tmp; const char *tmp;
if (!exec_dir) continue; if (!exec_dir || !*exec_dir) continue;
if (*exec_dir != '/') { if (*exec_dir != '/') {
if (!getcwd(git_command, sizeof(git_command))) { if (!getcwd(git_command, sizeof(git_command))) {
fprintf(stderr, "git: cannot determine " fprintf(stderr, "git: cannot determine "
"current directory\n"); "current directory: %s\n",
exit(1); strerror(errno));
break;
} }
len = strlen(git_command); len = strlen(git_command);
@ -57,17 +60,28 @@ int execv_git_cmd(const char **argv)
while (*exec_dir == '/') while (*exec_dir == '/')
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 { } 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); strcpy(git_command, exec_dir);
} }
len = strlen(git_command); len = strlen(git_command);
len += snprintf(git_command + len, sizeof(git_command) - len, rc = snprintf(git_command + len, sizeof(git_command) - len,
"/git-%s", argv[0]); "/git-%s", argv[0]);
if (rc < 0 || rc >= sizeof(git_command) - len) {
if (sizeof(git_command) <= len) {
fprintf(stderr, fprintf(stderr,
"git: command name given is too long.\n"); "git: command name given is too long.\n");
break; break;

View File

@ -63,10 +63,17 @@ my $svn_dir = $ARGV[1];
our @mergerx = (); our @mergerx = ();
if ($opt_m) { 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) { 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 # Absolutize filename now, since we will have chdir'ed by the time we

View File

@ -162,7 +162,7 @@ int main(int argc, const char **argv)
while (*argp) { while (*argp) {
const char *file = *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; int file_done = 0;
if ( !f ) if ( !f )