From d9ac9df41c8c1c3a2f5b0fb1bcc0546dc1bafba2 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 16 Aug 2005 02:20:34 +0200 Subject: [PATCH] Make git-format-patch's signoff option more consistent Since git-commit-script has a "--signoff" option, use that in git-format-patch-script, too (and since partial option names are supported,"--sign" is still valid). Also, if the message already contains the S-O-B line, silently ignore the "--signoff" request. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- git-format-patch-script | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/git-format-patch-script b/git-format-patch-script index ebe6616494..78bb089542 100755 --- a/git-format-patch-script +++ b/git-format-patch-script @@ -6,7 +6,7 @@ . git-sh-setup-script || die "Not a git archive." usage () { - echo >&2 "usage: $0"' [-n] [-o dir] [--mbox] [--check] [--sign] [-...] upstream [ our-head ] + echo >&2 "usage: $0"' [-n] [-o dir] [--mbox] [--check] [--signoff] [-...] upstream [ our-head ] Prepare each commit with its patch since our-head forked from upstream, one file per patch, for e-mail submission. Each output file is @@ -46,7 +46,7 @@ do date=t author=t mbox=t ;; -n|--n|--nu|--num|--numb|--numbe|--number|--numbere|--numbered) numbered=t ;; - -s|--s|--si|--sig|--sign) + -s|--s|--si|--sig|--sign|--signo|--signof|--signoff) signoff=t ;; -o=*|--o=*|--ou=*|--out=*|--outp=*|--outpu=*|--output=*|--output-=*|\ --output-d=*|--output-di=*|--output-dir=*|--output-dire=*|\ @@ -179,9 +179,12 @@ Date: '"$ad" test "$signoff" = "t" && { offsigner=`git-var GIT_COMMITTER_IDENT | sed -e 's/>.*/>/'` - echo - echo "Signed-off-by: $offsigner" - echo + line="Signed-off-by: $offsigner" + grep -q "^$line\$" $commsg || { + echo + echo "$line" + echo + } } echo '---' -- cgit v1.2.3 From 8c5989029215227230cccc9b5da54e798e2f2029 Mon Sep 17 00:00:00 2001 From: Chris Wright Date: Tue, 16 Aug 2005 11:28:02 -0700 Subject: Make tools use DESTDIR as well (otherwise rpm build is broken). Signed-off-by: Chris Wright Signed-off-by: Junio C Hamano --- tools/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/Makefile b/tools/Makefile index 779177c5a9..5cc6d14ebc 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -18,7 +18,7 @@ git-%: %.c all: $(PROGRAMS) install: $(PROGRAMS) $(SCRIPTS) - $(INSTALL) -m755 -d $(dest)$(bindir) + $(INSTALL) -m755 -d $(DESTDIR)$(bindir) $(INSTALL) $(PROGRAMS) $(SCRIPTS) $(DESTDIR)$(bindir) clean: -- cgit v1.2.3 From 8b8840e046923f34d6b3e76adc44106f9e63ab4c Mon Sep 17 00:00:00 2001 From: Matthias Urlichs Date: Mon, 15 Aug 2005 11:28:19 +0200 Subject: [PATCH] cvsgit fixes: spaces in filenames and CVS server dialog woes Problems found while importing dasher's CVS: * Allow spaces in filenames. * cvsps may create unnamed branches with revisions that don't really exist, which causes the CVS server to return something we haven't hitherto expected. * Report deleted files when being verbose. * Also, report the commit date. Signed-off-by: Junio C Hamano --- git-cvsimport-script | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/git-cvsimport-script b/git-cvsimport-script index 8f57396c2d..3b1fb052a6 100755 --- a/git-cvsimport-script +++ b/git-cvsimport-script @@ -294,6 +294,12 @@ sub _line { return $res; } elsif($line =~ s/^E //) { # print STDERR "S: $line\n"; + } elsif($line =~ /^Remove-entry /i) { + $line = $self->readline(); # filename + $line = $self->readline(); # OK + chomp $line; + die "Unknown: $line" if $line ne "ok"; + return -1; } else { die "Unknown: $line\n"; } @@ -561,7 +567,7 @@ my $commit = sub { or die "Error writing to git-commit-tree: $!\n"; $pw->close(); - print "Committed patch $patchset ($branch)\n" if $opt_v; + print "Committed patch $patchset ($branch ".strftime("%Y-%m-%d %H:%M:%S",gmtime($date)).")\n" if $opt_v; chomp(my $cid = <$pr>); length($cid) == 40 or die "Cannot get commit id ($cid): $!\n"; @@ -675,26 +681,32 @@ while() { $state = 9; } elsif($state == 8) { $logmsg .= "$_\n"; - } elsif($state == 9 and /^\s+(\S+):(INITIAL|\d+(?:\.\d+)+)->(\d+(?:\.\d+)+)\s*$/) { + } elsif($state == 9 and /^\s+(.+?):(INITIAL|\d+(?:\.\d+)+)->(\d+(?:\.\d+)+)\s*$/) { # VERSION:1.96->1.96.2.1 my $init = ($2 eq "INITIAL"); my $fn = $1; my $rev = $3; $fn =~ s#^/+##; my ($tmpname, $size) = $cvs->file($fn,$rev); - print "".($init ? "New" : "Update")." $fn: $size bytes.\n" if $opt_v; - open my $F, '-|', "git-hash-object -w $tmpname" - or die "Cannot create object: $!\n"; - my $sha = <$F>; - chomp $sha; - close $F; + if($size == -1) { + push(@old,$fn); + print "Drop $fn\n" if $opt_v; + } else { + print "".($init ? "New" : "Update")." $fn: $size bytes\n" if $opt_v; + open my $F, '-|', "git-hash-object -w $tmpname" + or die "Cannot create object: $!\n"; + my $sha = <$F>; + chomp $sha; + close $F; + my $mode = pmode($cvs->{'mode'}); + push(@new,[$mode, $sha, $fn]); # may be resurrected! + } unlink($tmpname); - my $mode = pmode($cvs->{'mode'}); - push(@new,[$mode, $sha, $fn]); # may be resurrected! - } elsif($state == 9 and /^\s+(\S+):\d(?:\.\d+)+->(\d(?:\.\d+)+)\(DEAD\)\s*$/) { + } elsif($state == 9 and /^\s+(.+?):\d(?:\.\d+)+->(\d(?:\.\d+)+)\(DEAD\)\s*$/) { my $fn = $1; $fn =~ s#^/+##; push(@old,$fn); + print "Delete $fn\n" if $opt_v; } elsif($state == 9 and /^\s*$/) { $state = 10; } elsif(($state == 9 or $state == 10) and /^-+$/) { -- cgit v1.2.3 From b0921331030d52febf52839753eee1b2b9ca1f24 Mon Sep 17 00:00:00 2001 From: iso-8859-1?Q?David_K=E5gedal Date: Mon, 15 Aug 2005 20:18:25 +0200 Subject: [PATCH] Fixed two bugs in git-cvsimport-script. The git-cvsimport-script had a copule of small bugs that prevented me from importing a big CVS repository. The first was that it didn't handle removed files with a multi-digit primary revision number. The second was that it was asking the CVS server for "F" messages, although they were not handled. I also updated the documentation for that script to correspond to actual flags. Signed-off-by: David K?5gedal Signed-off-by: Junio C Hamano --- Documentation/git-cvsimport-script.txt | 9 ++++++++- git-cvsimport-script | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Documentation/git-cvsimport-script.txt b/Documentation/git-cvsimport-script.txt index 05145e9383..07b288f754 100644 --- a/Documentation/git-cvsimport-script.txt +++ b/Documentation/git-cvsimport-script.txt @@ -29,6 +29,10 @@ OPTIONS currently, only the :local:, :ext: and :pserver: access methods are supported. +-C :: + The GIT repository to import to. If the directory doesn't + exist, it will be created. Default is the current directory. + -i:: Import-only: don't perform a checkout after importing. This option ensures the working directory and cache remain untouched and will @@ -44,7 +48,7 @@ OPTIONS -p :: Additional options for cvsps. - The options '-x' and '-A' are implicit and should not be used here. + The options '-u' and '-A' are implicit and should not be used here. If you need to pass multiple options, separate them with a comma. @@ -57,6 +61,9 @@ OPTIONS -h:: Print a short usage message and exit. +-z :: + Pass the timestamp fuzz factor to cvsps. + OUTPUT ------ If '-v' is specified, the script reports what it is doing. diff --git a/git-cvsimport-script b/git-cvsimport-script index 3b1fb052a6..a389f48965 100755 --- a/git-cvsimport-script +++ b/git-cvsimport-script @@ -190,7 +190,7 @@ sub conn { $self->{'socketo'}->write("Root $repo\n"); # Trial and error says that this probably is the minimum set - $self->{'socketo'}->write("Valid-responses ok error Valid-requests Mode M Mbinary E F Checked-in Created Updated Merged Removed\n"); + $self->{'socketo'}->write("Valid-responses ok error Valid-requests Mode M Mbinary E Checked-in Created Updated Merged Removed\n"); $self->{'socketo'}->write("valid-requests\n"); $self->{'socketo'}->flush(); @@ -702,7 +702,7 @@ while() { push(@new,[$mode, $sha, $fn]); # may be resurrected! } unlink($tmpname); - } elsif($state == 9 and /^\s+(.+?):\d(?:\.\d+)+->(\d(?:\.\d+)+)\(DEAD\)\s*$/) { + } elsif($state == 9 and /^\s+(.+?):\d+(?:\.\d+)+->(\d+(?:\.\d+)+)\(DEAD\)\s*$/) { my $fn = $1; $fn =~ s#^/+##; push(@old,$fn); -- cgit v1.2.3 From c508df5edfe12b9df7dfea4d438c1dab2812b3e9 Mon Sep 17 00:00:00 2001 From: Daniel Barkalow Date: Tue, 16 Aug 2005 00:10:03 -0400 Subject: [PATCH] Add function to read an index file from an arbitrary filename. Note that the pack file has to be in the usual location if it gets installed later. Signed-off-by: Daniel Barkalow Signed-off-by: Junio C Hamano --- cache.h | 2 ++ sha1_file.c | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cache.h b/cache.h index dbde95a0b6..f14a4ce91a 100644 --- a/cache.h +++ b/cache.h @@ -319,6 +319,8 @@ extern int get_ack(int fd, unsigned char *result_sha1); extern struct ref **get_remote_heads(int in, struct ref **list, int nr_match, char **match); extern struct packed_git *parse_pack_index(unsigned char *sha1); +extern struct packed_git *parse_pack_index_file(unsigned char *sha1, + char *idx_path); extern void prepare_packed_git(void); extern void install_packed_git(struct packed_git *pack); diff --git a/sha1_file.c b/sha1_file.c index 2d109f928b..b6ebbc5c9a 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -475,13 +475,19 @@ struct packed_git *add_packed_git(char *path, int path_len) } struct packed_git *parse_pack_index(unsigned char *sha1) +{ + char *path = sha1_pack_index_name(sha1); + return parse_pack_index_file(sha1, path); +} + +struct packed_git *parse_pack_index_file(unsigned char *sha1, char *idx_path) { struct packed_git *p; unsigned long idx_size; void *idx_map; - char *path = sha1_pack_index_name(sha1); + char *path; - if (check_packed_git_idx(path, &idx_size, &idx_map)) + if (check_packed_git_idx(idx_path, &idx_size, &idx_map)) return NULL; path = sha1_pack_name(sha1); -- cgit v1.2.3 From 08b1161697996b5478f726541c0d8a457abcc439 Mon Sep 17 00:00:00 2001 From: Daniel Barkalow Date: Tue, 16 Aug 2005 00:10:32 -0400 Subject: [PATCH] Support packs in local-pull If it doesn't find an object, it looks for an index that contains it and uses the same methods on that instead. Signed-off-by: Daniel Barkalow Signed-off-by: Junio C Hamano --- local-pull.c | 112 ++++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 91 insertions(+), 21 deletions(-) diff --git a/local-pull.c b/local-pull.c index b715203f6f..7e47ec0598 100644 --- a/local-pull.c +++ b/local-pull.c @@ -15,34 +15,54 @@ void prefetch(unsigned char *sha1) { } -int fetch(unsigned char *sha1) +static struct packed_git *packs = NULL; + +void setup_index(unsigned char *sha1) { - static int object_name_start = -1; - static char filename[PATH_MAX]; - char *hex = sha1_to_hex(sha1); - const char *dest_filename = sha1_file_name(sha1); + struct packed_git *new_pack; + char filename[PATH_MAX]; + strcpy(filename, path); + strcat(filename, "/objects/pack/pack-"); + strcat(filename, sha1_to_hex(sha1)); + strcat(filename, ".idx"); + new_pack = parse_pack_index_file(sha1, filename); + new_pack->next = packs; + packs = new_pack; +} - if (object_name_start < 0) { - strcpy(filename, path); /* e.g. git.git */ - strcat(filename, "/objects/"); - object_name_start = strlen(filename); +int setup_indices() +{ + DIR *dir; + struct dirent *de; + char filename[PATH_MAX]; + unsigned char sha1[20]; + sprintf(filename, "%s/objects/pack/", path); + dir = opendir(filename); + while ((de = readdir(dir)) != NULL) { + int namelen = strlen(de->d_name); + if (namelen != 50 || + strcmp(de->d_name + namelen - 5, ".pack")) + continue; + get_sha1_hex(sha1, de->d_name + 5); + setup_index(sha1); } - filename[object_name_start+0] = hex[0]; - filename[object_name_start+1] = hex[1]; - filename[object_name_start+2] = '/'; - strcpy(filename + object_name_start + 3, hex + 2); + return 0; +} + +int copy_file(const char *source, const char *dest, const char *hex) +{ if (use_link) { - if (!link(filename, dest_filename)) { + if (!link(source, dest)) { pull_say("link %s\n", hex); return 0; } /* If we got ENOENT there is no point continuing. */ if (errno == ENOENT) { - fprintf(stderr, "does not exist %s\n", filename); + fprintf(stderr, "does not exist %s\n", source); return -1; } } - if (use_symlink && !symlink(filename, dest_filename)) { + if (use_symlink && !symlink(source, dest)) { pull_say("symlink %s\n", hex); return 0; } @@ -50,25 +70,25 @@ int fetch(unsigned char *sha1) int ifd, ofd, status; struct stat st; void *map; - ifd = open(filename, O_RDONLY); + ifd = open(source, O_RDONLY); if (ifd < 0 || fstat(ifd, &st) < 0) { close(ifd); - fprintf(stderr, "cannot open %s\n", filename); + fprintf(stderr, "cannot open %s\n", source); return -1; } map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, ifd, 0); close(ifd); if (map == MAP_FAILED) { - fprintf(stderr, "cannot mmap %s\n", filename); + fprintf(stderr, "cannot mmap %s\n", source); return -1; } - ofd = open(dest_filename, O_WRONLY | O_CREAT | O_EXCL, 0666); + ofd = open(dest, O_WRONLY | O_CREAT | O_EXCL, 0666); status = ((ofd < 0) || (write(ofd, map, st.st_size) != st.st_size)); munmap(map, st.st_size); close(ofd); if (status) - fprintf(stderr, "cannot write %s\n", dest_filename); + fprintf(stderr, "cannot write %s\n", dest); else pull_say("copy %s\n", hex); return status; @@ -77,6 +97,56 @@ int fetch(unsigned char *sha1) return -1; } +int fetch_pack(unsigned char *sha1) +{ + struct packed_git *target; + char filename[PATH_MAX]; + if (setup_indices()) + return -1; + target = find_sha1_pack(sha1, packs); + if (!target) + return error("Couldn't find %s: not separate or in any pack", + sha1_to_hex(sha1)); + if (get_verbosely) { + fprintf(stderr, "Getting pack %s\n", + sha1_to_hex(target->sha1)); + fprintf(stderr, " which contains %s\n", + sha1_to_hex(sha1)); + } + sprintf(filename, "%s/objects/pack/pack-%s.pack", + path, sha1_to_hex(sha1)); + copy_file(filename, sha1_pack_name(sha1), sha1_to_hex(sha1)); + sprintf(filename, "%s/objects/pack/pack-%s.idx", + path, sha1_to_hex(sha1)); + copy_file(filename, sha1_pack_index_name(sha1), sha1_to_hex(sha1)); + install_packed_git(target); + return 0; +} + +int fetch_file(unsigned char *sha1) +{ + static int object_name_start = -1; + static char filename[PATH_MAX]; + char *hex = sha1_to_hex(sha1); + const char *dest_filename = sha1_file_name(sha1); + + if (object_name_start < 0) { + strcpy(filename, path); /* e.g. git.git */ + strcat(filename, "/objects/"); + object_name_start = strlen(filename); + } + filename[object_name_start+0] = hex[0]; + filename[object_name_start+1] = hex[1]; + filename[object_name_start+2] = '/'; + strcpy(filename + object_name_start + 3, hex + 2); + return copy_file(filename, dest_filename, hex); +} + +int fetch(unsigned char *sha1) +{ + return fetch_file(sha1) && fetch_pack(sha1); +} + int fetch_ref(char *ref, unsigned char *sha1) { static int ref_name_start = -1; -- cgit v1.2.3 From d920032042c9fb3de04db640afe8611dfd4b6c21 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 15 Aug 2005 22:48:09 -0700 Subject: [PATCH] Fix local pull that uses packs. The patch mixed up the sha1 for the object being pulled, and the sha1 the pull engine internally use to represent the name of the pack that contains the object being pulled. Signed-off-by: Junio C Hamano --- local-pull.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/local-pull.c b/local-pull.c index 7e47ec0598..8b16f50e33 100644 --- a/local-pull.c +++ b/local-pull.c @@ -43,7 +43,7 @@ int setup_indices() if (namelen != 50 || strcmp(de->d_name + namelen - 5, ".pack")) continue; - get_sha1_hex(sha1, de->d_name + 5); + get_sha1_hex(de->d_name + 5, sha1); setup_index(sha1); } return 0; @@ -114,11 +114,13 @@ int fetch_pack(unsigned char *sha1) sha1_to_hex(sha1)); } sprintf(filename, "%s/objects/pack/pack-%s.pack", - path, sha1_to_hex(sha1)); - copy_file(filename, sha1_pack_name(sha1), sha1_to_hex(sha1)); + path, sha1_to_hex(target->sha1)); + copy_file(filename, sha1_pack_name(target->sha1), + sha1_to_hex(target->sha1)); sprintf(filename, "%s/objects/pack/pack-%s.idx", - path, sha1_to_hex(sha1)); - copy_file(filename, sha1_pack_index_name(sha1), sha1_to_hex(sha1)); + path, sha1_to_hex(target->sha1)); + copy_file(filename, sha1_pack_index_name(target->sha1), + sha1_to_hex(target->sha1)); install_packed_git(target); return 0; } -- cgit v1.2.3 From abe0582207c72ec848e78707577c61a98f5c633d Mon Sep 17 00:00:00 2001 From: Martin Langhoff Date: Tue, 16 Aug 2005 17:39:29 +1200 Subject: [PATCH] Add -k kill keyword expansion option to git-cvsimport - revised Early versions of git-cvsimport defaulted to using preexisting keyword expansion settings. This change preserves compatibility with existing cvs imports and allows new repository migrations to kill keyword expansion. After exploration of the different -k modes in the cvs protocol, we use -kk which kills keyword expansion wherever possible. Against the protocol spec, -ko and -kb will sometimes expand keywords. Should improve our chances of detecting merges and reduce imported repository size. Signed-off: Martin Langhoff Signed-off-by: Junio C Hamano --- Documentation/git-cvsimport-script.txt | 7 ++++++- git-cvsimport-script | 12 +++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Documentation/git-cvsimport-script.txt b/Documentation/git-cvsimport-script.txt index 07b288f754..61713d859c 100644 --- a/Documentation/git-cvsimport-script.txt +++ b/Documentation/git-cvsimport-script.txt @@ -11,7 +11,7 @@ SYNOPSIS -------- 'git-cvsimport-script' [ -o ] [ -h ] [ -v ] [ -d ] [ -p ] - [ -C ] [ -i ] [ ] + [ -C ] [ -i ] [ -k ] [ ] DESCRIPTION @@ -38,6 +38,11 @@ OPTIONS ensures the working directory and cache remain untouched and will not create them if they do not exist. +-k:: + Kill keywords: will extract files with -kk from the CVS archive + to avoid noisy changesets. Highly recommended, but off by default + to preserve compatibility with early imported trees. + -o :: The 'HEAD' branch from CVS is imported to the 'origin' branch within the git repository, as 'HEAD' already has a special meaning for git. diff --git a/git-cvsimport-script b/git-cvsimport-script index a389f48965..a6a6f0db39 100755 --- a/git-cvsimport-script +++ b/git-cvsimport-script @@ -28,19 +28,19 @@ use POSIX qw(strftime dup2); $SIG{'PIPE'}="IGNORE"; $ENV{'TZ'}="UTC"; -our($opt_h,$opt_o,$opt_v,$opt_d,$opt_p,$opt_C,$opt_z,$opt_i); +our($opt_h,$opt_o,$opt_v,$opt_k,$opt_d,$opt_p,$opt_C,$opt_z,$opt_i); sub usage() { print STDERR <{'socketo'}->write("Argument -N\n") or return undef; $self->{'socketo'}->write("Argument -P\n") or return undef; - # $self->{'socketo'}->write("Argument -ko\n") or return undef; - # -ko: Linus' version doesn't use it + # -kk: Linus' version doesn't use it - defaults to off + if ($opt_k) { + $self->{'socketo'}->write("Argument -kk\n") or return undef; + } $self->{'socketo'}->write("Argument -r\n") or return undef; $self->{'socketo'}->write("Argument $rev\n") or return undef; $self->{'socketo'}->write("Argument --\n") or return undef; -- cgit v1.2.3