* [PATCH 5/7] Make it possible to set up libgit directly (instead of from the environment)
From: Petr Baudis @ 2006-06-25 1:54 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <20060625015421.29906.50002.stgit@machine.or.cz>
This introduces a setup_git() function which is essentialy a (public)
backend for setup_git_env() which lets anyone specify custom sources
for the various paths instead of environment variables. Since the repositories
may get switched on the fly, this also updates code that caches paths to
invalidate them properly; I hope neither of those is a sweet spot.
It is used by Git.xs' xs__call_gate() to set up per-repository data
for libgit's consumption. No code actually takes advantage of it yet
but get_object() will in the next patches.
Signed-off-by: Petr Baudis <pasky@suse.cz>
---
cache.h | 3 +++
commit.c | 23 +++++++++++++++++++----
environment.c | 45 +++++++++++++++++++++++++++++++++++++++------
perl/Git.pm | 8 ++++----
perl/Git.xs | 16 +++++++++++++++-
sha1_file.c | 30 ++++++++++++++++++++++++------
sha1_name.c | 10 ++++++++--
7 files changed, 112 insertions(+), 23 deletions(-)
diff --git a/cache.h b/cache.h
index efeafea..9844e88 100644
--- a/cache.h
+++ b/cache.h
@@ -116,6 +116,9 @@ extern struct cache_entry **active_cache
extern unsigned int active_nr, active_alloc, active_cache_changed;
extern struct cache_tree *active_cache_tree;
+extern void setup_git(char *new_git_dir, char *new_git_object_dir,
+ char *new_git_index_file, char *new_git_graft_file);
+
#define GIT_DIR_ENVIRONMENT "GIT_DIR"
#define DEFAULT_GIT_DIR_ENVIRONMENT ".git"
#define DB_ENVIRONMENT "GIT_OBJECT_DIRECTORY"
diff --git a/commit.c b/commit.c
index 946615d..6c4acc2 100644
--- a/commit.c
+++ b/commit.c
@@ -163,6 +163,14 @@ int register_commit_graft(struct commit_
return 0;
}
+void free_commit_grafts(void)
+{
+ int pos = commit_graft_nr;
+ while (pos >= 0)
+ free(commit_graft[pos--]);
+ commit_graft_nr = 0;
+}
+
struct commit_graft *read_graft_line(char *buf, int len)
{
/* The format is just "Commit Parent1 Parent2 ...\n" */
@@ -215,11 +223,18 @@ int read_graft_file(const char *graft_fi
static void prepare_commit_graft(void)
{
static int commit_graft_prepared;
- char *graft_file;
+ static char *last_graft_file;
+ char *graft_file = get_graft_file();
+
+ if (last_graft_file) {
+ if (!strcmp(graft_file, last_graft_file))
+ return;
+ free_commit_grafts();
+ }
+ if (last_graft_file)
+ free(last_graft_file);
+ last_graft_file = strdup(graft_file);
- if (commit_graft_prepared)
- return;
- graft_file = get_graft_file();
read_graft_file(graft_file);
commit_graft_prepared = 1;
}
diff --git a/environment.c b/environment.c
index 3de8eb3..6b64d11 100644
--- a/environment.c
+++ b/environment.c
@@ -21,28 +21,61 @@ char git_commit_encoding[MAX_ENCODING_LE
int shared_repository = PERM_UMASK;
const char *apply_default_whitespace = NULL;
+static int dyn_git_object_dir, dyn_git_index_file, dyn_git_graft_file;
static char *git_dir, *git_object_dir, *git_index_file, *git_refs_dir,
*git_graft_file;
-static void setup_git_env(void)
+
+void setup_git(char *new_git_dir, char *new_git_object_dir,
+ char *new_git_index_file, char *new_git_graft_file)
{
- git_dir = getenv(GIT_DIR_ENVIRONMENT);
+ git_dir = new_git_dir;
if (!git_dir)
git_dir = DEFAULT_GIT_DIR_ENVIRONMENT;
- git_object_dir = getenv(DB_ENVIRONMENT);
+
+ if (dyn_git_object_dir)
+ free(git_object_dir);
+ git_object_dir = new_git_object_dir;
if (!git_object_dir) {
git_object_dir = xmalloc(strlen(git_dir) + 9);
sprintf(git_object_dir, "%s/objects", git_dir);
+ dyn_git_object_dir = 1;
+ } else {
+ dyn_git_object_dir = 0;
}
+
+ if (git_refs_dir)
+ free(git_refs_dir);
git_refs_dir = xmalloc(strlen(git_dir) + 6);
sprintf(git_refs_dir, "%s/refs", git_dir);
- git_index_file = getenv(INDEX_ENVIRONMENT);
+
+ if (dyn_git_index_file)
+ free(git_index_file);
+ git_index_file = new_git_index_file;
if (!git_index_file) {
git_index_file = xmalloc(strlen(git_dir) + 7);
sprintf(git_index_file, "%s/index", git_dir);
+ dyn_git_index_file = 1;
+ } else {
+ dyn_git_index_file = 0;
}
- git_graft_file = getenv(GRAFT_ENVIRONMENT);
- if (!git_graft_file)
+
+ if (dyn_git_graft_file)
+ free(git_graft_file);
+ git_graft_file = new_git_graft_file;
+ if (!git_graft_file) {
git_graft_file = strdup(git_path("info/grafts"));
+ dyn_git_graft_file = 1;
+ } else {
+ dyn_git_graft_file = 0;
+ }
+}
+
+static void setup_git_env(void)
+{
+ setup_git(getenv(GIT_DIR_ENVIRONMENT),
+ getenv(DB_ENVIRONMENT),
+ getenv(INDEX_ENVIRONMENT),
+ getenv(GRAFT_ENVIRONMENT));
}
char *get_git_dir(void)
diff --git a/perl/Git.pm b/perl/Git.pm
index 1c3a2ec..c490e0c 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -92,6 +92,7 @@ increate nonwithstanding).
use Carp qw(carp croak); # but croak is bad - throw instead
use Error qw(:try);
use Cwd qw(abs_path);
+use Scalar::Util;
require XSLoader;
XSLoader::load('Git', $VERSION);
@@ -822,11 +823,10 @@ sub _call_gate {
if (defined $self) {
# XXX: We ignore the WorkingCopy! To properly support
# that will require heavy changes in libgit.
+ # For now, when we will need to do it we could temporarily
+ # chdir() there and then chdir() back after the call is done.
- # XXX: And we ignore everything else as well. libgit
- # at least needs to be extended to let us specify
- # the $GIT_DIR instead of looking it up in environment.
- #xs_call_gate($self->{opts}->{Repository});
+ xs__call_gate(Scalar::Util::refaddr($self), $self->repo_path());
}
# Having to call throw from the C code is a sure path to insanity.
diff --git a/perl/Git.xs b/perl/Git.xs
index 2fd1c67..4e85d69 100644
--- a/perl/Git.xs
+++ b/perl/Git.xs
@@ -59,7 +59,21 @@ BOOT:
}
-# /* TODO: xs_call_gate(). See Git.pm. */
+void
+xs__call_gate(repoid, git_dir)
+ long repoid;
+ char *git_dir;
+CODE:
+{
+ static long last_repoid;
+ if (repoid != last_repoid) {
+ setup_git(git_dir,
+ getenv(DB_ENVIRONMENT),
+ getenv(INDEX_ENVIRONMENT),
+ getenv(GRAFT_ENVIRONMENT));
+ last_repoid = repoid;
+ }
+}
const char *
diff --git a/sha1_file.c b/sha1_file.c
index c80528b..8d24f50 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -126,16 +126,22 @@ static void fill_sha1_path(char *pathbuf
char *sha1_file_name(const unsigned char *sha1)
{
static char *name, *base;
+ static const char *last_objdir;
+ const char *sha1_file_directory = get_object_directory();
- if (!base) {
- const char *sha1_file_directory = get_object_directory();
+ if (!last_objdir || strcmp(last_objdir, sha1_file_directory)) {
int len = strlen(sha1_file_directory);
+ if (base)
+ free(base);
base = xmalloc(len + 60);
memcpy(base, sha1_file_directory, len);
memset(base+len, 0, 60);
base[len] = '/';
base[len+3] = '/';
name = base + len + 1;
+ if (last_objdir)
+ free((char *) last_objdir);
+ last_objdir = strdup(sha1_file_directory);
}
fill_sha1_path(name, sha1);
return base;
@@ -145,14 +151,20 @@ char *sha1_pack_name(const unsigned char
{
static const char hex[] = "0123456789abcdef";
static char *name, *base, *buf;
+ static const char *last_objdir;
+ const char *sha1_file_directory = get_object_directory();
int i;
- if (!base) {
- const char *sha1_file_directory = get_object_directory();
+ if (!last_objdir || strcmp(last_objdir, sha1_file_directory)) {
int len = strlen(sha1_file_directory);
+ if (base)
+ free(base);
base = xmalloc(len + 60);
sprintf(base, "%s/pack/pack-1234567890123456789012345678901234567890.pack", sha1_file_directory);
name = base + len + 11;
+ if (last_objdir)
+ free((char *) last_objdir);
+ last_objdir = strdup(sha1_file_directory);
}
buf = name;
@@ -170,14 +182,20 @@ char *sha1_pack_index_name(const unsigne
{
static const char hex[] = "0123456789abcdef";
static char *name, *base, *buf;
+ static const char *last_objdir;
+ const char *sha1_file_directory = get_object_directory();
int i;
- if (!base) {
- const char *sha1_file_directory = get_object_directory();
+ if (!last_objdir || strcmp(last_objdir, sha1_file_directory)) {
int len = strlen(sha1_file_directory);
+ if (base)
+ free(base);
base = xmalloc(len + 60);
sprintf(base, "%s/pack/pack-1234567890123456789012345678901234567890.idx", sha1_file_directory);
name = base + len + 11;
+ if (last_objdir)
+ free((char *) last_objdir);
+ last_objdir = strdup(sha1_file_directory);
}
buf = name;
diff --git a/sha1_name.c b/sha1_name.c
index cd85d1f..1451cb6 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -12,15 +12,21 @@ static int find_short_object_filename(in
char hex[40];
int found = 0;
static struct alternate_object_database *fakeent;
+ static const char *last_objdir;
+ const char *objdir = get_object_directory();
- if (!fakeent) {
- const char *objdir = get_object_directory();
+ if (!last_objdir || strcmp(last_objdir, objdir)) {
int objdir_len = strlen(objdir);
int entlen = objdir_len + 43;
+ if (fakeent)
+ free(fakeent);
fakeent = xmalloc(sizeof(*fakeent) + entlen);
memcpy(fakeent->base, objdir, objdir_len);
fakeent->name = fakeent->base + objdir_len + 1;
fakeent->name[-1] = '/';
+ if (last_objdir)
+ free((char *) last_objdir);
+ last_objdir = strdup(objdir);
}
fakeent->next = alt_odb_list;
^ permalink raw reply related
* [PATCH 7/7] Convert git-annotate to use Git.pm
From: Petr Baudis @ 2006-06-25 1:54 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <20060625015421.29906.50002.stgit@machine.or.cz>
Together with the other converted scripts, this is probably still pu
material; it appears to work fine for me, though. The speed gain from
get_object() is about 10% (I expected more...).
Signed-off-by: Petr Baudis <pasky@suse.cz>
---
git-annotate.perl | 167 ++++++++++-------------------------------------------
1 files changed, 31 insertions(+), 136 deletions(-)
diff --git a/git-annotate.perl b/git-annotate.perl
index a6a7a48..d924e87 100755
--- a/git-annotate.perl
+++ b/git-annotate.perl
@@ -11,6 +11,7 @@ use strict;
use Getopt::Long;
use POSIX qw(strftime gmtime);
use File::Basename qw(basename dirname);
+use Git;
sub usage() {
print STDERR "Usage: ${\basename $0} [-s] [-S revs-file] file [ revision ]
@@ -29,7 +30,7 @@ sub usage() {
exit(1);
}
-our ($help, $longrev, $rename, $rawtime, $starting_rev, $rev_file) = (0, 0, 1);
+our ($help, $longrev, $rename, $rawtime, $starting_rev, $rev_file, $repo) = (0, 0, 1);
my $rc = GetOptions( "long|l" => \$longrev,
"time|t" => \$rawtime,
@@ -52,6 +53,8 @@ my @stack = (
},
);
+$repo = Git->repository();
+
our @filelines = ();
if (defined $starting_rev) {
@@ -102,15 +105,11 @@ while (my $bound = pop @stack) {
push @revqueue, $head;
init_claim( defined $starting_rev ? $head : 'dirty');
unless (defined $starting_rev) {
- my $diff = open_pipe("git","diff","-R", "HEAD", "--",$filename)
- or die "Failed to call git diff to check for dirty state: $!";
-
- _git_diff_parse($diff, $head, "dirty", (
- 'author' => gitvar_name("GIT_AUTHOR_IDENT"),
- 'author_date' => sprintf("%s +0000",time()),
- )
- );
- close($diff);
+ my %ident;
+ @ident{'author', 'author_email', 'author_date'} = $repo->ident('author');
+ my $diff = $repo->command_output_pipe('diff', '-R', 'HEAD', '--', $filename);
+ _git_diff_parse($diff, $head, "dirty", %ident);
+ $repo->command_close_pipe($diff);
}
handle_rev();
@@ -181,8 +180,7 @@ sub git_rev_list {
open($revlist, '<' . $rev_file)
or die "Failed to open $rev_file : $!";
} else {
- $revlist = open_pipe("git-rev-list","--parents","--remove-empty",$rev,"--",$file)
- or die "Failed to exec git-rev-list: $!";
+ $revlist = $repo->command_output_pipe('rev-list', '--parents', '--remove-empty', $rev, '--', $file);
}
my @revs;
@@ -191,7 +189,7 @@ sub git_rev_list {
my ($rev, @parents) = split /\s+/, $line;
push @revs, [ $rev, @parents ];
}
- close($revlist);
+ $repo->command_close_pipe($revlist);
printf("0 revs found for rev %s (%s)\n", $rev, $file) if (@revs == 0);
return @revs;
@@ -200,8 +198,7 @@ sub git_rev_list {
sub find_parent_renames {
my ($rev, $file) = @_;
- my $patch = open_pipe("git-diff-tree", "-M50", "-r","--name-status", "-z","$rev")
- or die "Failed to exec git-diff: $!";
+ my $patch = $repo->command_output_pipe('diff-tree', '-M50', '-r', '--name-status', '-z', $rev);
local $/ = "\0";
my %bound;
@@ -227,7 +224,7 @@ sub find_parent_renames {
}
}
}
- close($patch);
+ $repo->command_close_pipe($patch);
return \%bound;
}
@@ -236,14 +233,9 @@ sub find_parent_renames {
sub git_find_parent {
my ($rev, $filename) = @_;
- my $revparent = open_pipe("git-rev-list","--remove-empty", "--parents","--max-count=1","$rev","--",$filename)
- or die "Failed to open git-rev-list to find a single parent: $!";
-
- my $parentline = <$revparent>;
- chomp $parentline;
- my ($revfound,$parent) = split m/\s+/, $parentline;
-
- close($revparent);
+ my $parentline = $repo->command_oneline('rev-list', '--remove-empty',
+ '--parents', '--max-count=1', $rev, '--', $filename);
+ my ($revfound, $parent) = split m/\s+/, $parentline;
return $parent;
}
@@ -254,13 +246,13 @@ # Record the commit information that res
sub git_diff_parse {
my ($parent, $rev, %revinfo) = @_;
- my $diff = open_pipe("git-diff-tree","-M","-p",$rev,$parent,"--",
- $revs{$rev}{'filename'}, $revs{$parent}{'filename'})
- or die "Failed to call git-diff for annotation: $!";
+ my $diff = $repo->command_output_pipe('diff-tree', '-M', '-p',
+ $rev, $parent, '--',
+ $revs{$rev}{'filename'}, $revs{$parent}{'filename'});
_git_diff_parse($diff, $parent, $rev, %revinfo);
- close($diff);
+ $repo->command_close_pipe($diff);
}
sub _git_diff_parse {
@@ -351,36 +343,25 @@ sub git_cat_file {
my $blob = git_ls_tree($rev, $filename);
die "Failed to find a blob for $filename in rev $rev\n" if !defined $blob;
- my $catfile = open_pipe("git","cat-file", "blob", $blob)
- or die "Failed to git-cat-file blob $blob (rev $rev, file $filename): " . $!;
-
- my @lines;
- while(<$catfile>) {
- chomp;
- push @lines, $_;
- }
- close($catfile);
-
+ my @lines = split(/\n/, $repo->get_object('blob', $blob));
+ pop @lines unless $lines[$#lines]; # Trailing newline
return @lines;
}
sub git_ls_tree {
my ($rev, $filename) = @_;
- my $lstree = open_pipe("git","ls-tree",$rev,$filename)
- or die "Failed to call git ls-tree: $!";
-
+ my $lstree = $repo->command_output_pipe('ls-tree', $rev, $filename);
my ($mode, $type, $blob, $tfilename);
while(<$lstree>) {
chomp;
($mode, $type, $blob, $tfilename) = split(/\s+/, $_, 4);
last if ($tfilename eq $filename);
}
- close($lstree);
+ $repo->command_close_pipe($lstree);
return $blob if ($tfilename eq $filename);
die "git-ls-tree failed to find blob for $filename";
-
}
@@ -396,25 +377,17 @@ sub claim_line {
sub git_commit_info {
my ($rev) = @_;
- my $commit = open_pipe("git-cat-file", "commit", $rev)
- or die "Failed to call git-cat-file: $!";
+ my $commit = $repo->get_object('commit', $rev);
my %info;
- while(<$commit>) {
- chomp;
- last if (length $_ == 0);
-
- if (m/^author (.*) <(.*)> (.*)$/) {
- $info{'author'} = $1;
- $info{'author_email'} = $2;
- $info{'author_date'} = $3;
- } elsif (m/^committer (.*) <(.*)> (.*)$/) {
- $info{'committer'} = $1;
- $info{'committer_email'} = $2;
- $info{'committer_date'} = $3;
+ while ($commit =~ /(.*?)\n/g) {
+ my $line = $1;
+ if ($line =~ s/^author //) {
+ @info{'author', 'author_email', 'author_date'} = $repo->ident($line);
+ } elsif ($line =~ s/^committer//) {
+ @info{'committer', 'committer_email', 'committer_date'} = $repo->ident($line);
}
}
- close($commit);
return %info;
}
@@ -432,81 +405,3 @@ sub format_date {
my $t = $timestamp + $minutes * 60;
return strftime("%Y-%m-%d %H:%M:%S " . $timezone, gmtime($t));
}
-
-# Copied from git-send-email.perl - We need a Git.pm module..
-sub gitvar {
- my ($var) = @_;
- my $fh;
- my $pid = open($fh, '-|');
- die "$!" unless defined $pid;
- if (!$pid) {
- exec('git-var', $var) or die "$!";
- }
- my ($val) = <$fh>;
- close $fh or die "$!";
- chomp($val);
- return $val;
-}
-
-sub gitvar_name {
- my ($name) = @_;
- my $val = gitvar($name);
- my @field = split(/\s+/, $val);
- return join(' ', @field[0...(@field-4)]);
-}
-
-sub open_pipe {
- if ($^O eq '##INSERT_ACTIVESTATE_STRING_HERE##') {
- return open_pipe_activestate(@_);
- } else {
- return open_pipe_normal(@_);
- }
-}
-
-sub open_pipe_activestate {
- tie *fh, "Git::ActiveStatePipe", @_;
- return *fh;
-}
-
-sub open_pipe_normal {
- my (@execlist) = @_;
-
- my $pid = open my $kid, "-|";
- defined $pid or die "Cannot fork: $!";
-
- unless ($pid) {
- exec @execlist;
- die "Cannot exec @execlist: $!";
- }
-
- return $kid;
-}
-
-package Git::ActiveStatePipe;
-use strict;
-
-sub TIEHANDLE {
- my ($class, @params) = @_;
- my $cmdline = join " ", @params;
- my @data = qx{$cmdline};
- bless { i => 0, data => \@data }, $class;
-}
-
-sub READLINE {
- my $self = shift;
- if ($self->{i} >= scalar @{$self->{data}}) {
- return undef;
- }
- return $self->{'data'}->[ $self->{i}++ ];
-}
-
-sub CLOSE {
- my $self = shift;
- delete $self->{data};
- delete $self->{i};
-}
-
-sub EOF {
- my $self = shift;
- return ($self->{i} >= scalar @{$self->{data}});
-}
^ permalink raw reply related
* [PATCH 6/7] Git.pm: Introduce fast get_object() method
From: Petr Baudis @ 2006-06-25 1:54 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <20060625015421.29906.50002.stgit@machine.or.cz>
Direct .xs routine. Note that it does not work 100% correctly when
you juggle multiple repository objects, but it is not that bad either.
The trouble is that we might reuse packs information for another
Git project; that is not an issue since Git depends on uniqueness
of SHA1 ids so if we have found the object somewhere else, it is
nevertheless going to be the same object. It merely makes object
existence detection through this method unreliable; it is duly noted
in the documentation.
At least that's how I see it, I hope I didn't overlook any other
potential problem. I tested it for memory leaks and it appears to be
doing ok.
Signed-off-by: Petr Baudis <pasky@suse.cz>
---
perl/Git.pm | 17 +++++++++++++++++
perl/Git.xs | 24 ++++++++++++++++++++++++
2 files changed, 41 insertions(+), 0 deletions(-)
diff --git a/perl/Git.pm b/perl/Git.pm
index c490e0c..cdae1fe 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -571,6 +571,23 @@ sub ident_person {
}
+=item get_object ( TYPE, SHA1 )
+
+Return contents of the given object in a scalar string. If the object has
+not been found, undef is returned; however, do not rely on this! Currently,
+if you use multiple repositories at once, get_object() on one repository
+_might_ return the object even though it exists only in another repository.
+(But do not rely on this behaviour either.)
+
+The method must be called on a repository instance.
+
+Implementation of this method is very fast; no external command calls
+are involved. That's why it is broken, too. ;-)
+
+=cut
+
+# Implemented in Git.xs.
+
=item hash_object ( TYPE, FILENAME )
diff --git a/perl/Git.xs b/perl/Git.xs
index 4e85d69..e841e4a 100644
--- a/perl/Git.xs
+++ b/perl/Git.xs
@@ -118,6 +118,30 @@ CODE:
free((char **) argv);
}
+
+SV *
+xs_get_object(type, id)
+ char *type;
+ char *id;
+CODE:
+{
+ unsigned char sha1[20];
+ unsigned long size;
+ void *buf;
+
+ if (strlen(id) != 40 || get_sha1_hex(id, sha1) < 0)
+ XSRETURN_UNDEF;
+
+ buf = read_sha1_file(sha1, type, &size);
+ if (!buf)
+ XSRETURN_UNDEF;
+ RETVAL = newSVpvn(buf, size);
+ free(buf);
+}
+OUTPUT:
+ RETVAL
+
+
char *
xs_hash_object(type, file)
char *type;
^ permalink raw reply related
* [PATCH 4/7] Git.pm: Fix Git->repository("/somewhere/totally/elsewhere")
From: Petr Baudis @ 2006-06-25 1:54 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <20060625015421.29906.50002.stgit@machine.or.cz>
Signed-off-by: Petr Baudis <pasky@suse.cz>
---
perl/Git.pm | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/perl/Git.pm b/perl/Git.pm
index eea6c07..1c3a2ec 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -178,7 +178,8 @@ sub repository {
};
if ($dir) {
- $opts{Repository} = abs_path($dir);
+ $dir =~ m#^/# or $dir = $opts{Directory} . '/' . $dir;
+ $opts{Repository} = $dir;
# If --git-dir went ok, this shouldn't die either.
my $prefix = $search->command_oneline('rev-parse', '--show-prefix');
^ permalink raw reply related
* [PATCH 3/7] Git.pm: Swap hash_object() parameters
From: Petr Baudis @ 2006-06-25 1:54 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <20060625015421.29906.50002.stgit@machine.or.cz>
I'm about to introduce get_object() and it will be better for consistency
if the object type always goes first. And writing 'blob' there explicitly
is not much bother.
Signed-off-by: Petr Baudis <pasky@suse.cz>
---
perl/Git.pm | 8 ++++----
perl/Git.xs | 4 ++--
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/perl/Git.pm b/perl/Git.pm
index 6da11a6..eea6c07 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -570,13 +570,13 @@ sub ident_person {
-=item hash_object ( FILENAME [, TYPE ] )
+=item hash_object ( TYPE, FILENAME )
-=item hash_object ( FILEHANDLE [, TYPE ] )
+=item hash_object ( TYPE, FILEHANDLE )
Compute the SHA1 object id of the given C<FILENAME> (or data waiting in
-C<FILEHANDLE>) considering it is of the C<TYPE> object type (C<blob>
-(default), C<commit>, C<tree>).
+C<FILEHANDLE>) considering it is of the C<TYPE> object type (C<blob>,
+C<commit>, C<tree>).
In case of C<FILEHANDLE> passed instead of file name, all the data
available are read and hashed, and the filehandle is automatically
diff --git a/perl/Git.xs b/perl/Git.xs
index ebaac4b..2fd1c67 100644
--- a/perl/Git.xs
+++ b/perl/Git.xs
@@ -105,9 +105,9 @@ CODE:
}
char *
-xs_hash_object(file, type = "blob")
- SV *file;
+xs_hash_object(type, file)
char *type;
+ SV *file;
CODE:
{
unsigned char sha1[20];
^ permalink raw reply related
* [PATCH 2/7] Git.pm: Try to support ActiveState output pipe
From: Petr Baudis @ 2006-06-25 1:54 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <20060625015421.29906.50002.stgit@machine.or.cz>
The code is stolen from git-annotate and completely untested since
I don't have access to any Microsoft operating system now. Someone
ActiveState-savvy should look at it anyway and try to implement
the input pipe as well, if it is possible at all; also, the implementation
seems to be horribly whitespace-unsafe.
Signed-off-by: Petr Baudis <pasky@suse.cz>
---
perl/Git.pm | 68 +++++++++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 57 insertions(+), 11 deletions(-)
diff --git a/perl/Git.pm b/perl/Git.pm
index 08f56c0..6da11a6 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -748,18 +748,29 @@ sub _command_common_pipe {
}
_check_valid_cmd($cmd);
- my $pid = open(my $fh, $direction);
- if (not defined $pid) {
- throw Error::Simple("open failed: $!");
- } elsif ($pid == 0) {
- if (defined $opts{STDERR}) {
- close STDERR;
- }
- if ($opts{STDERR}) {
- open (STDERR, '>&', $opts{STDERR})
- or die "dup failed: $!";
+ my $fh;
+ if ($^O eq '##INSERT_ACTIVESTATE_STRING_HERE##') {
+ # ActiveState Perl
+ #defined $opts{STDERR} and
+ # warn 'ignoring STDERR option - running w/ ActiveState';
+ $direction eq '-|' or
+ die 'input pipe for ActiveState not implemented';
+ tie ($fh, 'Git::activestate_pipe', $cmd, @args);
+
+ } else {
+ my $pid = open($fh, $direction);
+ if (not defined $pid) {
+ throw Error::Simple("open failed: $!");
+ } elsif ($pid == 0) {
+ if (defined $opts{STDERR}) {
+ close STDERR;
+ }
+ if ($opts{STDERR}) {
+ open (STDERR, '>&', $opts{STDERR})
+ or die "dup failed: $!";
+ }
+ _cmd_exec($self, $cmd, @args);
}
- _cmd_exec($self, $cmd, @args);
}
return wantarray ? ($fh, join(' ', $cmd, @args)) : $fh;
}
@@ -834,4 +845,39 @@ sub AUTOLOAD {
sub DESTROY { }
+# Pipe implementation for ActiveState Perl.
+
+package Git::activestate_pipe;
+use strict;
+
+sub TIEHANDLE {
+ my ($class, @params) = @_;
+ # 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};
+ bless { i => 0, data => \@data }, $class;
+}
+
+sub READLINE {
+ my $self = shift;
+ if ($self->{i} >= scalar @{$self->{data}}) {
+ return undef;
+ }
+ return $self->{'data'}->[ $self->{i}++ ];
+}
+
+sub CLOSE {
+ my $self = shift;
+ delete $self->{data};
+ delete $self->{i};
+}
+
+sub EOF {
+ my $self = shift;
+ return ($self->{i} >= scalar @{$self->{data}});
+}
+
+
1; # Famous last words
^ permalink raw reply related
* [PATCH 1/7] Git.pm: Introduce ident() and ident_person() methods
From: Petr Baudis @ 2006-06-25 1:54 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
These methods can retrieve/parse the author/committer ident.
Signed-off-by: Petr Baudis <pasky@suse.cz>
---
git-send-email.perl | 11 ++---------
perl/Git.pm | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 52 insertions(+), 9 deletions(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index e794e44..79e82f5 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -84,15 +84,8 @@ foreach my $entry (@bcclist) {
# Now, let's fill any that aren't set in with defaults:
-sub gitvar_ident {
- my ($name) = @_;
- my $val = $repo->command('var', $name);
- my @field = split(/\s+/, $val);
- return join(' ', @field[0...(@field-3)]);
-}
-
-my ($author) = gitvar_ident('GIT_AUTHOR_IDENT');
-my ($committer) = gitvar_ident('GIT_COMMITTER_IDENT');
+my ($author) = $repo->ident_person('author');
+my ($committer) = $repo->ident_person('committer');
my %aliases;
my @alias_files = $repo->config('sendemail.aliasesfile');
diff --git a/perl/Git.pm b/perl/Git.pm
index 2e1241b..08f56c0 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -520,6 +520,56 @@ sub config {
}
+=item ident ( TYPE | IDENTSTR )
+
+=item ident_person ( TYPE | IDENTSTR | IDENTARRAY )
+
+This suite of functions retrieves and parses ident information, as stored
+in the commit and tag objects or produced by C<var GIT_type_IDENT> (thus
+C<TYPE> can be either I<author> or I<committer>; case is insignificant).
+
+The C<ident> method retrieves the ident information from C<git-var>
+and either returns it as a scalar string or as an array with the fields parsed.
+Alternatively, it can take a prepared ident string (e.g. from the commit
+object) and just parse it.
+
+C<ident_person> returns the person part of the ident - name and email;
+it can take the same arguments as C<ident> or the array returned by C<ident>.
+
+The synopsis is like:
+
+ my ($name, $email, $time_tz) = ident('author');
+ "$name <$email>" eq ident_person('author');
+ "$name <$email>" eq ident_person($name);
+ $time_tz =~ /^\d+ [+-]\d{4}$/;
+
+Both methods must be called on a repository instance.
+
+=cut
+
+sub ident {
+ my ($self, $type) = @_;
+ my $identstr;
+ if (lc $type eq lc 'committer' or lc $type eq lc 'author') {
+ $identstr = $self->command_oneline('var', 'GIT_'.uc($type).'_IDENT');
+ } else {
+ $identstr = $type;
+ }
+ if (wantarray) {
+ return $identstr =~ /^(.*) <(.*)> (\d+ [+-]\d{4})$/;
+ } else {
+ return $identstr;
+ }
+}
+
+sub ident_person {
+ my ($self, @ident) = @_;
+ $#ident == 0 and @ident = $self->ident($ident[0]);
+ return "$ident[0] <$ident[1]>";
+}
+
+
+
=item hash_object ( FILENAME [, TYPE ] )
=item hash_object ( FILEHANDLE [, TYPE ] )
^ permalink raw reply related
* Re: [PATCH] Introduce Git.pm (v3)
From: Johannes Schindelin @ 2006-06-25 1:54 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7vzmg2rpxt.fsf@assigned-by-dhcp.cox.net>
Hi,
On Sat, 24 Jun 2006, Junio C Hamano wrote:
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>
> > My original idea: on a machine where you have no accurate diff, you at
> > least want to pass the tests, and you want to ensure you can apply a diff
> > you generated on that machine.
>
> I remember that, but I think recently we converted t4100 and
> t4101 to use pregenerated test vectors so it might not be an
> issue anymore?
Exactly.
> I would maybe rename the option to --inaccurate-eof and default
> it to off (i.e. no --accurate-eof option). After all we are not
> talking about arbitrary inaccuracy but the particular botch of
> not having "\No newline at the end of file."
Sure. Want me to redo the patch?
Ciao,
Dscho
^ permalink raw reply
* [PATCH 2/2] format-patch: introduce "--ignore-if-in-upstream"
From: Johannes Schindelin @ 2006-06-25 1:52 UTC (permalink / raw)
To: git, junkio, martin
With this flag, format-patch will try very hard not to output patches which
are already in the upstream branch.
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
---
builtin-log.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 80 insertions(+), 0 deletions(-)
diff --git a/builtin-log.c b/builtin-log.c
index 5a8a50b..e78a9a4 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -160,6 +160,71 @@ static void reopen_stdout(struct commit
freopen(filename, "w", stdout);
}
+static void reset_all_objects_flags()
+{
+ int i;
+
+ for (i = 0; i < obj_allocs; i++)
+ if (objs[i])
+ objs[i]->flags = 0;
+}
+
+static int get_patch_id(struct commit *commit, struct diff_options *options,
+ unsigned char *sha1)
+{
+ diff_tree_sha1(commit->parents->item->object.sha1, commit->object.sha1,
+ "", options);
+ diffcore_std(options);
+ return diff_flush_patch_id(options, sha1);
+}
+
+static void get_patch_ids(struct rev_info *rev, struct diff_options *options)
+{
+ struct rev_info check_rev;
+ struct commit *commit;
+ struct object *o1, *o2;
+ unsigned flags1, flags2;
+ unsigned char sha1[20];
+
+ if (rev->pending.nr != 2)
+ die("Need exactly one range.");
+
+ o1 = rev->pending.objects[0].item;
+ flags1 = o1->flags;
+ o2 = rev->pending.objects[1].item;
+ flags2 = o2->flags;
+
+ if ((flags1 & UNINTERESTING) == (flags2 & UNINTERESTING))
+ die("Not a range.");
+
+ diff_setup(options);
+ options->recursive = 1;
+ if (diff_setup_done(options) < 0)
+ die("diff_setup_done failed");
+
+ /* given a range a..b get all patch ids for b..a */
+ init_revisions(&check_rev);
+ o1->flags ^= UNINTERESTING;
+ o2->flags ^= UNINTERESTING;
+ add_pending_object(&check_rev, o1, "o1");
+ add_pending_object(&check_rev, o2, "o2");
+ prepare_revision_walk(&check_rev);
+
+ while ((commit = get_revision(&check_rev)) != NULL) {
+ /* ignore merges */
+ if (commit->parents && commit->parents->next)
+ continue;
+
+ if (!get_patch_id(commit, options, sha1))
+ created_object(sha1, xcalloc(1, sizeof(struct object)));
+ }
+
+ /* reset for next revision walk */
+ reset_all_objects_flags();
+ o1->flags = flags1;
+ o2->flags = flags2;
+}
+
int cmd_format_patch(int argc, const char **argv, char **envp)
{
struct commit *commit;
@@ -170,6 +235,8 @@ int cmd_format_patch(int argc, const cha
int numbered = 0;
int start_number = -1;
int keep_subject = 0;
+ int ignore_if_in_upstream = 0;
+ struct diff_options patch_id_opts;
char *add_signoff = NULL;
init_revisions(&rev);
@@ -235,6 +302,8 @@ int cmd_format_patch(int argc, const cha
rev.mime_boundary = git_version_string;
else if (!strncmp(argv[i], "--attach=", 9))
rev.mime_boundary = argv[i] + 9;
+ else if (!strcmp(argv[i], "--ignore-if-in-upstream"))
+ ignore_if_in_upstream = 1;
else
argv[j++] = argv[i];
}
@@ -262,14 +331,25 @@ int cmd_format_patch(int argc, const cha
add_head(&rev);
}
+ if (ignore_if_in_upstream)
+ get_patch_ids(&rev, &patch_id_opts);
+
if (!use_stdout)
realstdout = fdopen(dup(1), "w");
prepare_revision_walk(&rev);
while ((commit = get_revision(&rev)) != NULL) {
+ unsigned char sha1[20];
+
/* ignore merges */
if (commit->parents && commit->parents->next)
continue;
+
+ if (ignore_if_in_upstream &&
+ !get_patch_id(commit, &patch_id_opts, sha1) &&
+ lookup_object(sha1))
+ continue;
+
nr++;
list = realloc(list, nr * sizeof(list[0]));
list[nr - 1] = commit;
--
1.4.0.g7a200-dirty
^ permalink raw reply related
* [PATCH 1/2] add diff_flush_patch_id() to calculate the patch id
From: Johannes Schindelin @ 2006-06-25 1:51 UTC (permalink / raw)
To: git, junkio, martin
Call it like this:
unsigned char id[20];
if (diff_flush_patch_id(diff_options, id))
printf("And the patch id is: %s\n", sha1_to_hex(id));
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
---
diff.c | 139 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
diff.h | 2 +
2 files changed, 141 insertions(+), 0 deletions(-)
diff --git a/diff.c b/diff.c
index 5b34f73..3beecb9 100644
--- a/diff.c
+++ b/diff.c
@@ -2027,6 +2027,145 @@ static void diff_summary(struct diff_fil
}
}
+struct patch_id_t {
+ struct xdiff_emit_state xm;
+ SHA_CTX *ctx;
+ int patchlen;
+};
+
+static int remove_space(char *line, int len)
+{
+ int i;
+ char *dst = line;
+ unsigned char c;
+
+ for (i = 0; i < len; i++)
+ if (!isspace((c = line[i])))
+ *dst++ = c;
+
+ return dst - line;
+}
+
+static void patch_id_consume(void *priv, char *line, unsigned long len)
+{
+ struct patch_id_t *data = priv;
+ int new_len;
+
+ /* Ignore line numbers when computing the SHA1 of the patch */
+ if (!strncmp(line, "@@ -", 4))
+ return;
+
+ new_len = remove_space(line, len);
+
+ SHA1_Update(data->ctx, line, new_len);
+ data->patchlen += new_len;
+}
+
+/* returns 0 upon success, and writes result into sha1 */
+static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1)
+{
+ struct diff_queue_struct *q = &diff_queued_diff;
+ int i;
+ SHA_CTX ctx;
+ struct patch_id_t data;
+ char buffer[PATH_MAX * 4 + 20];
+
+ SHA1_Init(&ctx);
+ memset(&data, 0, sizeof(struct patch_id_t));
+ data.ctx = &ctx;
+ data.xm.consume = patch_id_consume;
+
+ for (i = 0; i < q->nr; i++) {
+ xpparam_t xpp;
+ xdemitconf_t xecfg;
+ xdemitcb_t ecb;
+ mmfile_t mf1, mf2;
+ struct diff_filepair *p = q->queue[i];
+ int len1, len2;
+
+ if (p->status == 0)
+ return error("internal diff status error");
+ if (p->status == DIFF_STATUS_UNKNOWN)
+ continue;
+ if (diff_unmodified_pair(p))
+ continue;
+ if ((DIFF_FILE_VALID(p->one) && S_ISDIR(p->one->mode)) ||
+ (DIFF_FILE_VALID(p->two) && S_ISDIR(p->two->mode)))
+ continue;
+ if (DIFF_PAIR_UNMERGED(p))
+ continue;
+
+ diff_fill_sha1_info(p->one);
+ diff_fill_sha1_info(p->two);
+ if (fill_mmfile(&mf1, p->one) < 0 ||
+ fill_mmfile(&mf2, p->two) < 0)
+ return error("unable to read files to diff");
+
+ /* Maybe hash p->two? into the patch id? */
+ if (mmfile_is_binary(&mf2))
+ continue;
+
+ len1 = remove_space(p->one->path, strlen(p->one->path));
+ len2 = remove_space(p->two->path, strlen(p->two->path));
+ if (p->one->mode == 0)
+ len1 = snprintf(buffer, sizeof(buffer),
+ "diff--gita/%.*sb/%.*s"
+ "newfilemode%06o"
+ "---/dev/null"
+ "+++b/%.*s",
+ len1, p->one->path,
+ len2, p->two->path,
+ p->two->mode,
+ len2, p->two->path);
+ else if (p->two->mode == 0)
+ len1 = snprintf(buffer, sizeof(buffer),
+ "diff--gita/%.*sb/%.*s"
+ "deletedfilemode%06o"
+ "---a/%.*s"
+ "+++/dev/null",
+ len1, p->one->path,
+ len2, p->two->path,
+ p->one->mode,
+ len1, p->one->path);
+ else
+ len1 = snprintf(buffer, sizeof(buffer),
+ "diff--gita/%.*sb/%.*s"
+ "---a/%.*s"
+ "+++b/%.*s",
+ len1, p->one->path,
+ len2, p->two->path,
+ len1, p->one->path,
+ len2, p->two->path);
+ SHA1_Update(&ctx, buffer, len1);
+
+ xpp.flags = XDF_NEED_MINIMAL;
+ xecfg.ctxlen = 3;
+ xecfg.flags = 3;
+ ecb.outf = xdiff_outf;
+ ecb.priv = &data;
+ xdl_diff(&mf1, &mf2, &xpp, &xecfg, &ecb);
+ }
+
+ SHA1_Final(sha1, &ctx);
+ return 0;
+}
+
+int diff_flush_patch_id(struct diff_options *options, unsigned char *sha1)
+{
+ struct diff_queue_struct *q = &diff_queued_diff;
+ int i;
+ int result = diff_get_patch_id(options, sha1);
+
+ for (i = 0; i < q->nr; i++)
+ diff_free_filepair(q->queue[i]);
+
+ free(q->queue);
+ q->queue = NULL;
+ q->nr = q->alloc = 0;
+
+ return result;
+}
+
void diff_flush(struct diff_options *options)
{
struct diff_queue_struct *q = &diff_queued_diff;
diff --git a/diff.h b/diff.h
index 7d7b6cd..850c15f 100644
--- a/diff.h
+++ b/diff.h
@@ -185,4 +185,6 @@ extern int run_diff_files(struct rev_inf
extern int run_diff_index(struct rev_info *revs, int cached);
+extern int diff_flush_patch_id(struct diff_options *, unsigned char *);
+
#endif /* DIFF_H */
--
1.4.0.g7a200-dirty
^ permalink raw reply related
* [PATCH 0/2] resurrect format-patch's patch id checking
From: Johannes Schindelin @ 2006-06-25 1:50 UTC (permalink / raw)
To: git, junkio, martin
With these patches, you can say
git format-patch --ignore-if-in-upstream upstream
to get a series of only the patches which are in HEAD, but not upstream.
The first patch adds diff_flush_patch_id() to calculate the patch id, after
a diff queue was set up. (Earlier, I sent out a version which also adds
a command line option to the diff family, but I'll postpone that until
Timo's patches went in).
The second patch adds the actual patch id checking. There are two tricky
things involved:
- I add a pseudo-object for each patch of the upstream, which has
the patch id as sha1. This is no real object, but since we rely
on the hashes being unique for all practical purposes, and since
it has parsed == 0, it should be no problem.
- To add the patch ids of the upstream, the revision walker must
be called twice.
So, if format-patch was called with a range "a..b" (a single
revision "a" is handled as "a..HEAD" by format-patch), a revision
walker is set up for "b..a", and the patch ids are calculated and
stored. This is done by toggling the UNINTERESTING bits of both
pending objects.
After that, the flags of all objects are reset to 0, so that the
revisions can be walked again. The flags of the two pending objects
are then reset to their original state.
Note that "--numbered" still works.
WARNING: since it is quite late in this part of the world, _and_ I am known
to produce not-always-optimal patches which could eat your children, please
give this a good beating.
Ciao,
Dscho
^ permalink raw reply
* [PATCH] Git.pm: Support for perl/ being built by a different compiler
From: Petr Baudis @ 2006-06-25 1:47 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
dst_ on #git reported that on Solaris 9, Perl was built by Sun CC
and perl/ is therefore being built with it as well, while the rest
of Git is built with gcc. The problem (the first one visible, anyway)
is that we passed perl/ even various gcc-specific options. This
separates those to a special variable.
This is not really meant for an application yet since it's not clear
if it will alone help anything.
Signed-off-by: Petr Baudis <pasky@suse.cz>
---
Makefile | 66 ++++++++++++++++++++++++++++++++++++--------------------------
1 files changed, 38 insertions(+), 28 deletions(-)
diff --git a/Makefile b/Makefile
index 4f0a501..6755f26 100644
--- a/Makefile
+++ b/Makefile
@@ -115,6 +115,11 @@ SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powe
### --- END CONFIGURATION SECTION ---
+# Those must not be GNU-specific; they are shared with perl/ which may
+# be built by a different compiler.
+BASIC_CFLAGS =
+BASIC_LDFLAGS =
+
SCRIPT_SH = \
git-bisect.sh git-branch.sh git-checkout.sh \
git-cherry.sh git-clean.sh git-clone.sh git-commit.sh \
@@ -249,13 +254,13 @@ ifeq ($(uname_S),Darwin)
NEEDS_LIBICONV = YesPlease
## fink
ifeq ($(shell test -d /sw/lib && echo y),y)
- ALL_CFLAGS += -I/sw/include
- ALL_LDFLAGS += -L/sw/lib
+ BASIC_CFLAGS += -I/sw/include
+ BASIC_LDFLAGS += -L/sw/lib
endif
## darwinports
ifeq ($(shell test -d /opt/local/lib && echo y),y)
- ALL_CFLAGS += -I/opt/local/include
- ALL_LDFLAGS += -L/opt/local/lib
+ BASIC_CFLAGS += -I/opt/local/include
+ BASIC_LDFLAGS += -L/opt/local/lib
endif
endif
ifeq ($(uname_S),SunOS)
@@ -274,7 +279,7 @@ ifeq ($(uname_S),SunOS)
endif
INSTALL = ginstall
TAR = gtar
- ALL_CFLAGS += -D__EXTENSIONS__
+ BASIC_CFLAGS += -D__EXTENSIONS__
endif
ifeq ($(uname_O),Cygwin)
NO_D_TYPE_IN_DIRENT = YesPlease
@@ -291,21 +296,22 @@ ifeq ($(uname_O),Cygwin)
endif
ifeq ($(uname_S),FreeBSD)
NEEDS_LIBICONV = YesPlease
- ALL_CFLAGS += -I/usr/local/include
- ALL_LDFLAGS += -L/usr/local/lib
+ BASIC_CFLAGS += -I/usr/local/include
+ BASIC_LDFLAGS += -L/usr/local/lib
endif
ifeq ($(uname_S),OpenBSD)
NO_STRCASESTR = YesPlease
NEEDS_LIBICONV = YesPlease
- ALL_CFLAGS += -I/usr/local/include
- ALL_LDFLAGS += -L/usr/local/lib
+ BASIC_CFLAGS += -I/usr/local/include
+ BASIC_LDFLAGS += -L/usr/local/lib
endif
ifeq ($(uname_S),NetBSD)
ifeq ($(shell expr "$(uname_R)" : '[01]\.'),2)
NEEDS_LIBICONV = YesPlease
endif
- ALL_CFLAGS += -I/usr/pkg/include
- ALL_LDFLAGS += -L/usr/pkg/lib -Wl,-rpath,/usr/pkg/lib
+ BASIC_CFLAGS += -I/usr/pkg/include
+ BASIC_LDFLAGS += -L/usr/pkg/lib
+ ALL_LDFLAGS += -Wl,-rpath,/usr/pkg/lib
endif
ifeq ($(uname_S),AIX)
NO_STRCASESTR=YesPlease
@@ -317,9 +323,9 @@ ifeq ($(uname_S),IRIX64)
NO_STRCASESTR=YesPlease
NO_SOCKADDR_STORAGE=YesPlease
SHELL_PATH=/usr/gnu/bin/bash
- ALL_CFLAGS += -DPATH_MAX=1024
+ BASIC_CFLAGS += -DPATH_MAX=1024
# for now, build 32-bit version
- ALL_LDFLAGS += -L/usr/lib32
+ BASIC_LDFLAGS += -L/usr/lib32
endif
ifneq (,$(findstring arm,$(uname_M)))
ARM_SHA1 = YesPlease
@@ -340,7 +346,7 @@ endif
ifndef NO_CURL
ifdef CURLDIR
# This is still problematic -- gcc does not always want -R.
- ALL_CFLAGS += -I$(CURLDIR)/include
+ BASIC_CFLAGS += -I$(CURLDIR)/include
CURL_LIBCURL = -L$(CURLDIR)/lib -R$(CURLDIR)/lib -lcurl
else
CURL_LIBCURL = -lcurl
@@ -361,13 +367,13 @@ ifndef NO_OPENSSL
OPENSSL_LIBSSL = -lssl
ifdef OPENSSLDIR
# Again this may be problematic -- gcc does not always want -R.
- ALL_CFLAGS += -I$(OPENSSLDIR)/include
+ BASIC_CFLAGS += -I$(OPENSSLDIR)/include
OPENSSL_LINK = -L$(OPENSSLDIR)/lib -R$(OPENSSLDIR)/lib
else
OPENSSL_LINK =
endif
else
- ALL_CFLAGS += -DNO_OPENSSL
+ BASIC_CFLAGS += -DNO_OPENSSL
MOZILLA_SHA1 = 1
OPENSSL_LIBSSL =
endif
@@ -379,7 +385,7 @@ endif
ifdef NEEDS_LIBICONV
ifdef ICONVDIR
# Again this may be problematic -- gcc does not always want -R.
- ALL_CFLAGS += -I$(ICONVDIR)/include
+ BASIC_CFLAGS += -I$(ICONVDIR)/include
ICONV_LINK = -L$(ICONVDIR)/lib -R$(ICONVDIR)/lib
else
ICONV_LINK =
@@ -395,13 +401,13 @@ ifdef NEEDS_NSL
SIMPLE_LIB += -lnsl
endif
ifdef NO_D_TYPE_IN_DIRENT
- ALL_CFLAGS += -DNO_D_TYPE_IN_DIRENT
+ BASIC_CFLAGS += -DNO_D_TYPE_IN_DIRENT
endif
ifdef NO_D_INO_IN_DIRENT
- ALL_CFLAGS += -DNO_D_INO_IN_DIRENT
+ BASIC_CFLAGS += -DNO_D_INO_IN_DIRENT
endif
ifdef NO_SYMLINK_HEAD
- ALL_CFLAGS += -DNO_SYMLINK_HEAD
+ BASIC_CFLAGS += -DNO_SYMLINK_HEAD
endif
ifdef NO_STRCASESTR
COMPAT_CFLAGS += -DNO_STRCASESTR
@@ -420,13 +426,13 @@ ifdef NO_MMAP
COMPAT_OBJS += compat/mmap.o
endif
ifdef NO_IPV6
- ALL_CFLAGS += -DNO_IPV6
+ BASIC_CFLAGS += -DNO_IPV6
endif
ifdef NO_SOCKADDR_STORAGE
ifdef NO_IPV6
- ALL_CFLAGS += -Dsockaddr_storage=sockaddr_in
+ BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in
else
- ALL_CFLAGS += -Dsockaddr_storage=sockaddr_in6
+ BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in6
endif
endif
ifdef NO_INET_NTOP
@@ -434,7 +440,7 @@ ifdef NO_INET_NTOP
endif
ifdef NO_ICONV
- ALL_CFLAGS += -DNO_ICONV
+ BASIC_CFLAGS += -DNO_ICONV
endif
ifdef PPC_SHA1
@@ -458,7 +464,7 @@ ifdef USE_PIC
ALL_CFLAGS += -fPIC
endif
ifdef NO_ACCURATE_DIFF
- ALL_CFLAGS += -DNO_ACCURATE_DIFF
+ BASIC_CFLAGS += -DNO_ACCURATE_DIFF
endif
# Shell quote (do not use $(call) to accomodate ancient setups);
@@ -478,8 +484,12 @@ GIT_PYTHON_DIR_SQ = $(subst ','\'',$(GIT
LIBS = $(GITLIBS) $(EXTLIBS)
-ALL_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' $(COMPAT_CFLAGS)
+BASIC_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' $(COMPAT_CFLAGS)
LIB_OBJS += $(COMPAT_OBJS)
+
+ALL_CFLAGS += $(BASIC_CFLAGS)
+ALL_LDFLAGS += $(BASIC_LDFLAGS)
+
export prefix TAR INSTALL DESTDIR SHELL_PATH template_dir
@@ -608,9 +618,9 @@ XDIFF_OBJS=xdiff/xdiffi.o xdiff/xprepare
rm -f $@ && $(AR) rcs $@ $(XDIFF_OBJS)
-PERL_DEFINE = $(ALL_CFLAGS) -DGIT_VERSION='"$(GIT_VERSION)"'
+PERL_DEFINE = $(BASIC_CFLAGS) -DGIT_VERSION='"$(GIT_VERSION)"'
PERL_DEFINE_SQ = $(subst ','\'',$(PERL_DEFINE))
-PERL_LIBS = $(EXTLIBS)
+PERL_LIBS = $(BASIC_LDFLAGS) $(EXTLIBS)
PERL_LIBS_SQ = $(subst ','\'',$(PERL_LIBS))
perl/Makefile: perl/Git.pm perl/Makefile.PL GIT-CFLAGS
(cd perl && $(PERL_PATH) Makefile.PL \
^ permalink raw reply related
* [PATCH] Git.pm build: Fix quoting and missing GIT-CFLAGS dependency
From: Petr Baudis @ 2006-06-25 1:40 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Linus Torvalds, git
In-Reply-To: <20060625010202.GX21864@pasky.or.cz>
Signed-off-by: Petr Baudis <pasky@suse.cz>
---
This one should do a better job; if we quote, let's do it proper. :-)
Makefile | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index 9a59466..fb9ffad 100644
--- a/Makefile
+++ b/Makefile
@@ -608,11 +608,15 @@ XDIFF_OBJS=xdiff/xdiffi.o xdiff/xprepare
rm -f $@ && $(AR) rcs $@ $(XDIFF_OBJS)
-perl/Makefile: perl/Git.pm perl/Makefile.PL
+PERL_DEFINE = $(ALL_CFLAGS) -DGIT_VERSION='"$(GIT_VERSION)"'
+PERL_DEFINE_SQ = $(subst ','\'',$(PERL_DEFINE))
+PERL_LIBS = $(EXTLIBS)
+PERL_LIBS_SQ = $(subst ','\'',$(PERL_LIBS))
+perl/Makefile: perl/Git.pm perl/Makefile.PL GIT-CFLAGS
(cd perl && $(PERL_PATH) Makefile.PL \
- PREFIX="$(prefix)" \
- DEFINE="$(ALL_CFLAGS) -DGIT_VERSION=\\\"$(GIT_VERSION)\\\"" \
- LIBS="$(EXTLIBS)")
+ PREFIX='$(prefix_SQ)' \
+ DEFINE='$(PERL_DEFINE_SQ)' \
+ LIBS='$(PERL_LIBS)')
doc:
$(MAKE) -C Documentation all
--
Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
A person is just about as big as the things that make them angry.
^ permalink raw reply related
* Re: [PATCH 07/12] Git.pm: Better error handling
From: Junio C Hamano @ 2006-06-25 1:30 UTC (permalink / raw)
To: Petr Baudis; +Cc: git, Linus Torvalds
In-Reply-To: <20060624131731.GU21864@pasky.or.cz>
Petr Baudis <pasky@suse.cz> writes:
>> --------------------------------
>>
>> (cd perl && /usr/bin/perl Makefile.PL \
>> PREFIX="/home/junio/git-test" \
>> DEFINE="-O2 -Wall -Wdeclaration-after-statement
>> -g -DSHA1_HEADER='<openssl/sha.h>'
>> -DGIT_VERSION=\\\"1.4.1.rc1.gab0df\\\"" \
>> LIBS="libgit.a xdiff/lib.a -lz -lcrypto")
>> Unrecognized argument in LIBS ignored: 'libgit.a'
>> Unrecognized argument in LIBS ignored: 'xdiff/lib.a'
>>
>> Do you need to pass LIBS, and if so maybe this is not a way
>> Makefile.PL expects it to be passed perhaps?
>
> It is harmless, but this should fix it:
>
> Signed-off-by: Petr Baudis <pasky@suse.cz>
Applied the "EXTLIBS" change in the message. I did the same
"clean twice" change last night. Also I will apply the
"PERL_DEFINES_SQ" change as well. Hopefully this would make
things buildable for more people.
Thanks.
^ permalink raw reply
* [PATCH 3/3] rebase: allow --skip to work with --merge
From: Eric Wong @ 2006-06-25 1:29 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Eric Wong
In-Reply-To: <20060622110941.GA32261@hand.yhbt.net>
Now that we control the merge base selection, we won't be forced
into rolling things in that we wanted to skip beforehand.
Also, add a test to ensure this all works as intended.
Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
Documentation/git-rebase.txt | 1 -
git-rebase.sh | 13 ++++++++-
t/t3403-rebase-skip.sh | 61 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 73 insertions(+), 2 deletions(-)
diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index c339c45..9d7bcaa 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -108,7 +108,6 @@ OPTIONS
--skip::
Restart the rebasing process by skipping the current patch.
- This does not work with the --merge option.
--merge::
Use merging strategies to rebase. When the recursive (default) merge
diff --git a/git-rebase.sh b/git-rebase.sh
index a95ada6..9ad1c44 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -137,7 +137,18 @@ do
--skip)
if test -d "$dotest"
then
- die "--skip is not supported when using --merge"
+ prev_head="`cat $dotest/prev_head`"
+ end="`cat $dotest/end`"
+ msgnum="`cat $dotest/msgnum`"
+ msgnum=$(($msgnum + 1))
+ onto="`cat $dotest/onto`"
+ while test "$msgnum" -le "$end"
+ do
+ call_merge "$msgnum"
+ continue_merge
+ done
+ finish_rb_merge
+ exit
fi
git am -3 --skip --resolvemsg="$RESOLVEMSG"
exit
diff --git a/t/t3403-rebase-skip.sh b/t/t3403-rebase-skip.sh
new file mode 100755
index 0000000..8ab63c5
--- /dev/null
+++ b/t/t3403-rebase-skip.sh
@@ -0,0 +1,61 @@
+#!/bin/sh
+#
+# Copyright (c) 2006 Eric Wong
+#
+
+test_description='git rebase --merge --skip tests'
+
+. ./test-lib.sh
+
+# we assume the default git-am -3 --skip strategy is tested independently
+# and always works :)
+
+if test "$no_python"; then
+ echo "Skipping: no python => no recursive merge"
+ test_done
+ exit 0
+fi
+
+test_expect_success setup '
+ echo hello > hello &&
+ git add hello &&
+ git commit -m "hello" &&
+ git branch skip-reference &&
+
+ echo world >> hello &&
+ git commit -a -m "hello world" &&
+ echo goodbye >> hello &&
+ git commit -a -m "goodbye" &&
+
+ git checkout -f skip-reference &&
+ echo moo > hello &&
+ git commit -a -m "we should skip this" &&
+ echo moo > cow &&
+ git add cow &&
+ git commit -m "this should not be skipped" &&
+ git branch pre-rebase skip-reference &&
+ git branch skip-merge skip-reference
+ '
+
+test_expect_failure 'rebase with git am -3 (default)' 'git rebase master'
+
+test_expect_success 'rebase --skip with am -3' '
+ git reset --hard HEAD &&
+ git rebase --skip
+ '
+test_expect_success 'checkout skip-merge' 'git checkout -f skip-merge'
+
+test_expect_failure 'rebase with --merge' 'git rebase --merge master'
+
+test_expect_success 'rebase --skip with --merge' '
+ git reset --hard HEAD &&
+ git rebase --skip
+ '
+
+test_expect_success 'merge and reference trees equal' \
+ 'test -z "`git-diff-tree skip-merge skip-reference`"'
+
+test_debug 'gitk --all & sleep 1'
+
+test_done
+
--
1.4.0.g937a
^ permalink raw reply related
* [PATCH 2/3] rebase: cleanup rebasing with --merge
From: Eric Wong @ 2006-06-25 1:29 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Eric Wong
In-Reply-To: <20060622110941.GA32261@hand.yhbt.net>
We no longer have to recommit each patch to remove the parent
information we're rebasing since we're using the low-level merge
strategies directly instead of git-merge.
Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
git-rebase.sh | 33 +++++----------------------------
1 files changed, 5 insertions(+), 28 deletions(-)
diff --git a/git-rebase.sh b/git-rebase.sh
index 53fb14e..a95ada6 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -59,15 +59,16 @@ continue_merge () {
if test -n "`git-diff-index HEAD`"
then
+ printf "Committed: %0${prec}d" $msgnum
git-commit -C "`cat $dotest/current`"
else
- echo "Previous merge succeeded automatically"
+ printf "Already applied: %0${prec}d" $msgnum
fi
+ echo ' '`git-rev-list --pretty=oneline -1 HEAD | \
+ sed 's/^[a-f0-9]\+ //'`
prev_head=`git-rev-parse HEAD^0`
-
# save the resulting commit so we can read-tree on it later
- echo "$prev_head" > "$dotest/cmt.$msgnum.result"
echo "$prev_head" > "$dotest/prev_head"
# onto the next patch:
@@ -82,10 +83,7 @@ call_merge () {
rv=$?
case "$rv" in
0)
- if test -n "`git-diff-index HEAD`"
- then
- git-commit -C "$cmt" || die "commit failed: $MRESOLVEMSG"
- fi
+ return
;;
1)
test -d "$GIT_DIR/rr-cache" && git-rerere
@@ -103,27 +101,6 @@ call_merge () {
}
finish_rb_merge () {
- set -e
-
- msgnum=1
- echo "Finalizing rebased commits..."
- git-reset --hard "`cat $dotest/onto`"
- end="`cat $dotest/end`"
- while test "$msgnum" -le "$end"
- do
- git-read-tree `cat "$dotest/cmt.$msgnum.result"`
- git-checkout-index -q -f -u -a
- if test -n "`git-diff-index HEAD`"
- then
- git-commit -C "`cat $dotest/cmt.$msgnum`"
- printf "Committed %0${prec}d" $msgnum
- else
- printf "Already applied: %0${prec}d" $msgnum
- fi
- echo ' '`git-rev-list --pretty=oneline -1 HEAD | \
- sed 's/^[a-f0-9]\+ //'`
- msgnum=$(($msgnum + 1))
- done
rm -r "$dotest"
echo "All done."
}
--
1.4.0.g937a
^ permalink raw reply related
* [PATCH 0/3] rebase --merge improvements and fixes
From: Eric Wong @ 2006-06-25 1:29 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <20060622110941.GA32261@hand.yhbt.net>
These patches should address the current issues with rebase --merge
usage. It can now do everything the original format-patch | am -3
strategy including --skip and detection of merged commits by upstream.
--
Eric Wong
^ permalink raw reply
* [PATCH 1/3] rebase: allow --merge option to handle patches merged upstream
From: Eric Wong @ 2006-06-25 1:29 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Eric Wong
In-Reply-To: <20060622110941.GA32261@hand.yhbt.net>
Enhance t3401-rebase-partial to test with --merge as well as
the standard am -3 strategy.
Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
git-rebase.sh | 15 +++++++++++----
t/t3401-rebase-partial.sh | 13 ++++++++++++-
2 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/git-rebase.sh b/git-rebase.sh
index 9159477..53fb14e 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -82,7 +82,10 @@ call_merge () {
rv=$?
case "$rv" in
0)
- git-commit -C "$cmt" || die "commit failed: $MRESOLVEMSG"
+ if test -n "`git-diff-index HEAD`"
+ then
+ git-commit -C "$cmt" || die "commit failed: $MRESOLVEMSG"
+ fi
;;
1)
test -d "$GIT_DIR/rr-cache" && git-rerere
@@ -110,9 +113,13 @@ finish_rb_merge () {
do
git-read-tree `cat "$dotest/cmt.$msgnum.result"`
git-checkout-index -q -f -u -a
- git-commit -C "`cat $dotest/cmt.$msgnum`"
-
- printf "Committed %0${prec}d" $msgnum
+ if test -n "`git-diff-index HEAD`"
+ then
+ git-commit -C "`cat $dotest/cmt.$msgnum`"
+ printf "Committed %0${prec}d" $msgnum
+ else
+ printf "Already applied: %0${prec}d" $msgnum
+ fi
echo ' '`git-rev-list --pretty=oneline -1 HEAD | \
sed 's/^[a-f0-9]\+ //'`
msgnum=$(($msgnum + 1))
diff --git a/t/t3401-rebase-partial.sh b/t/t3401-rebase-partial.sh
index 32dc9c5..360a670 100755
--- a/t/t3401-rebase-partial.sh
+++ b/t/t3401-rebase-partial.sh
@@ -37,7 +37,9 @@ test_expect_success \
test_expect_success \
'pick top patch from topic branch into master' \
'git-cherry-pick my-topic-branch^0 &&
- git-checkout -f my-topic-branch
+ git-checkout -f my-topic-branch &&
+ git-branch master-merge master &&
+ git-branch my-topic-branch-merge my-topic-branch
'
test_debug \
@@ -50,4 +52,13 @@ test_expect_success \
'rebase topic branch against new master and check git-am did not get halted' \
'git-rebase master && test ! -d .dotest'
+if test -z "$no_python"
+then
+ test_expect_success \
+ 'rebase --merge topic branch that was partially merged upstream' \
+ 'git-checkout -f my-topic-branch-merge &&
+ git-rebase --merge master-merge &&
+ test ! -d .git/.dotest-merge'
+fi
+
test_done
--
1.4.0.g937a
^ permalink raw reply related
* Re: PPC SHA-1 Updates in "pu"
From: Petr Baudis @ 2006-06-25 1:24 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Linus Torvalds, git
In-Reply-To: <7vhd2atid1.fsf@assigned-by-dhcp.cox.net>
Dear diary, on Sat, Jun 24, 2006 at 10:21:30PM CEST, I got a letter
where Junio C Hamano <junkio@cox.net> said that...
> Pasky, can we first iron out kinks in the build procedure and
> installation before converting existing programs further?
Sure.
> The things I worry about currently are:
>
> - the SITELIBARCH gotcha I sent you a message about (and you
> responded to it already -- was that an Acked-by?);
Yes. :-)
> - RPM target -- we probably acquired a new build-dependency in
> which case the .spec file needs to be updated;
Well, perl is currently not listed even as a runtime dependency,
so does it really need to be listed as a build dependency?
> - Make sure Git.xs builds and installed result works fine on
> all platforms we care about, including Cygwin and other
> non-Linux boxes.
Unfortunately I don't have access to a lot of those. :-(
> I'd even suggest we revert the changes to git-fmt-merge-msg to
> keep it working for now, until the above worries are resolved.
> Otherwise we cannot have it in "next" safely (and I REALLY _do_
> want to have Git.pm infrastructure in "next" soonish).
Yes, that sounds reasonable.
> We can start using Git.xs and friends in some _new_ ancillary
> programs, once we solve building and installing problems for
> everybody. That way it would help us gain portability and
> confidence without disrupting existing users.
Well, I don't think it's very likely that Git.pm per se would be buggy
on a certain specific platform - it should either work as well as
everywhere else or not build at all, in which case you have disrupted
the existing users anyway. :-) (But without disrupting anyone we won't
get any bugreports and never get it fixed.)
Perhaps other converted perl scripts can linger at least on the pu
branch?
--
Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
A person is just about as big as the things that make them angry.
^ permalink raw reply
* Re: [PATCH] Introduce Git.pm (v3)
From: Junio C Hamano @ 2006-06-25 1:20 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git
In-Reply-To: <Pine.LNX.4.63.0606242207510.29667@wbgn013.biozentrum.uni-wuerzburg.de>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> My original idea: on a machine where you have no accurate diff, you at
> least want to pass the tests, and you want to ensure you can apply a diff
> you generated on that machine.
I remember that, but I think recently we converted t4100 and
t4101 to use pregenerated test vectors so it might not be an
issue anymore?
> This patch is just compile tested, but obviously correct
Looks sane, thanks.
I would maybe rename the option to --inaccurate-eof and default
it to off (i.e. no --accurate-eof option). After all we are not
talking about arbitrary inaccuracy but the particular botch of
not having "\No newline at the end of file."
^ permalink raw reply
* Re: [PATCH 07/12] Git.pm: Better error handling
From: Petr Baudis @ 2006-06-25 1:13 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <20060624131731.GU21864@pasky.or.cz>
Dear diary, on Sat, Jun 24, 2006 at 03:17:31PM CEST, I got a letter
where Petr Baudis <pasky@suse.cz> said that...
> Dear diary, on Sat, Jun 24, 2006 at 10:37:25AM CEST, I got a letter
> where Junio C Hamano <junkio@cox.net> said that...
> > Petr Baudis <pasky@suse.cz> writes:
> >
> > > +int
> > > +error_xs(const char *err, va_list params)
> > > +{
> >
> > You said in git-compat-util.h that set_error_routine takes a
> > function that returns void, so this gives unnecessary type
> > clash.
> >
> > --------------------------------
> > In file included from /usr/lib/perl/5.8/CORE/perl.h:756,
> > from Git.xs:15:
> > /usr/lib/perl/5.8/CORE/embed.h:4193:1: warning: "die" redefined
> > Git.xs:11:1: warning: this is the location of the previous definition
> > Git.xs: In function 'boot_Git':
> > Git.xs:57: warning: passing argument 1 of 'set_error_routine' from incompatible pointer type
> > Git.xs:58: warning: passing argument 1 of 'set_die_routine' makes qualified function pointer from unqualified
> > --------------------------------
>
> Oh, I forgot to fix it in the .xs. :-(
---
[PATCH] Git.pm: Squash some annoying warnings in Git.xs
From: Petr Baudis <pasky@suse.cz>
Signed-off-by: Petr Baudis <pasky@suse.cz>
---
perl/Git.xs | 11 ++++-------
1 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/perl/Git.xs b/perl/Git.xs
index e841e4a..d7a2b75 100644
--- a/perl/Git.xs
+++ b/perl/Git.xs
@@ -29,21 +29,18 @@ report_xs(const char *prefix, const char
return buf;
}
-void
+void NORETURN
die_xs(const char *err, va_list params)
{
- char *str;
- str = report_xs("fatal: ", err, params);
+ char *str = report_xs("fatal: ", err, params);
croak(str);
}
-int
+void
error_xs(const char *err, va_list params)
{
- char *str;
- str = report_xs("error: ", err, params);
+ char *str = report_xs("error: ", err, params);
warn(str);
- return -1;
}
--
Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
A person is just about as big as the things that make them angry.
^ permalink raw reply related
* Re: PPC SHA-1 Updates in "pu"
From: Petr Baudis @ 2006-06-25 1:02 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Linus Torvalds, git
In-Reply-To: <7vd5cyt8a3.fsf@assigned-by-dhcp.cox.net>
Dear diary, on Sun, Jun 25, 2006 at 01:59:16AM CEST, I got a letter
where Junio C Hamano <junkio@cox.net> said that...
> Linus Torvalds <torvalds@osdl.org> writes:
>
> > how does that compile for anybody else, when -DSHA1_HEADER isn't set
> > correctly? The quotes have gone missing:
> >
> > -DSHA1_HEADER='ppc/sha1.h'
> >
> > don't ask me why.
>
> That is, as usual, caused by careless shell quoting.
>
> : gitster; PPC_SHA1=YesPlease Meta/Make perl/Makefile
> GIT_VERSION = 1.4.1.rc1.g9adbe
> (cd perl && /usr/bin/perl Makefile.PL \
> PREFIX="/home/junio/git-test" \
> DEFINE="-O2 -Wall -Wdeclaration-after-statement
> -g -fPIC -DSHA1_HEADER='"ppc/sha1.h"'
> -DGIT_VERSION=\\\"1.4.1.rc1.g9adbe\\\"" \
> LIBS="libgit.a xdiff/lib.a -lz")
> Unrecognized argument in LIBS ignored: 'libgit.a'
> Unrecognized argument in LIBS ignored: 'xdiff/lib.a'
> Writing Makefile for Git
Oops...
----
Git.pm build: Fix $DEFINE quoting and missing GIT-CFLAGS dependency
Signed-off-by: Petr Baudis <pasky@suse.cz>
diff --git a/Makefile b/Makefile
index 9a59466..64375f6 100644
--- a/Makefile
+++ b/Makefile
@@ -608,10 +608,12 @@ XDIFF_OBJS=xdiff/xdiffi.o xdiff/xprepare
rm -f $@ && $(AR) rcs $@ $(XDIFF_OBJS)
-perl/Makefile: perl/Git.pm perl/Makefile.PL
+PERL_DEFINES = $(ALL_CFLAGS) -DGIT_VERSION='"$(GIT_VERSION)"'
+PERL_DEFINES_SQ = $(subst ','\'',$(PERL_DEFINES))
+perl/Makefile: perl/Git.pm perl/Makefile.PL GIT-CFLAGS
(cd perl && $(PERL_PATH) Makefile.PL \
PREFIX="$(prefix)" \
- DEFINE="$(ALL_CFLAGS) -DGIT_VERSION=\\\"$(GIT_VERSION)\\\"" \
+ DEFINE='$(PERL_DEFINES_SQ)' \
LIBS="$(EXTLIBS)")
doc:
--
Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
A person is just about as big as the things that make them angry.
^ permalink raw reply related
* Re: PPC SHA-1 Updates in "pu"
From: Junio C Hamano @ 2006-06-24 23:59 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git, Petr Baudis
In-Reply-To: <Pine.LNX.4.64.0606241338370.6483@g5.osdl.org>
Linus Torvalds <torvalds@osdl.org> writes:
> Don't everybody see them?
No. But I see it now.
> how does that compile for anybody else, when -DSHA1_HEADER isn't set
> correctly? The quotes have gone missing:
>
> -DSHA1_HEADER='ppc/sha1.h'
>
> don't ask me why.
That is, as usual, caused by careless shell quoting.
: gitster; PPC_SHA1=YesPlease Meta/Make perl/Makefile
GIT_VERSION = 1.4.1.rc1.g9adbe
(cd perl && /usr/bin/perl Makefile.PL \
PREFIX="/home/junio/git-test" \
DEFINE="-O2 -Wall -Wdeclaration-after-statement
-g -fPIC -DSHA1_HEADER='"ppc/sha1.h"'
-DGIT_VERSION=\\\"1.4.1.rc1.g9adbe\\\"" \
LIBS="libgit.a xdiff/lib.a -lz")
Unrecognized argument in LIBS ignored: 'libgit.a'
Unrecognized argument in LIBS ignored: 'xdiff/lib.a'
Writing Makefile for Git
All options but to use OpenSSL SHA-1 implementation share the
same problem (Meta/Make is a thin "make" wrapper to give USE_PIC
and other C compilation flags):
: gitster; ARM_SHA1=YesPlease Meta/Make perl/Makefile
(cd perl && /usr/bin/perl Makefile.PL \
PREFIX="/home/junio/git-test" \
DEFINE="-O2 -Wall -Wdeclaration-after-statement
-g -fPIC -DSHA1_HEADER='"arm/sha1.h"'
-DGIT_VERSION=\\\"1.4.1.rc1.g9adbe\\\"" \
LIBS="libgit.a xdiff/lib.a -lz")
Unrecognized argument in LIBS ignored: 'libgit.a'
Unrecognized argument in LIBS ignored: 'xdiff/lib.a'
Writing Makefile for Git
: gitster; MOZILLA_SHA1=YesPlease Meta/Make perl/Makefile
(cd perl && /usr/bin/perl Makefile.PL \
PREFIX="/home/junio/git-test" \
DEFINE="-O2 -Wall -Wdeclaration-after-statement
-g -fPIC -DSHA1_HEADER='"mozilla-sha1/sha1.h"'
-DGIT_VERSION=\\\"1.4.1.rc1.g9adbe\\\"" \
LIBS="libgit.a xdiff/lib.a -lz")
Unrecognized argument in LIBS ignored: 'libgit.a'
Unrecognized argument in LIBS ignored: 'xdiff/lib.a'
Writing Makefile for Git
^ permalink raw reply
* Re: [RFC] GIT user survey
From: Martin Langhoff @ 2006-06-24 23:42 UTC (permalink / raw)
To: Paolo Ciarrocchi; +Cc: Git Mailing List
In-Reply-To: <4d8e3fd30606240918m6b452314m6514b5e5fc86f147@mail.gmail.com>
Paolo,
I've seen in the irc logs that you were wondering whether we could a
web-based survey tool. Perhaps I can setup Moodle with an
easy-to-fillout survey. Interested?
martin
^ permalink raw reply
* Re: [PATCH 2/7] Merge with_raw, with_stat and summary variables to output_format
From: Johannes Schindelin @ 2006-06-24 23:20 UTC (permalink / raw)
To: Timo Hirvonen; +Cc: junkio, git
In-Reply-To: <20060625005654.627e176b.tihirvon@gmail.com>
Hi,
On Sun, 25 Jun 2006, Timo Hirvonen wrote:
> Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
>
> > On Sat, 24 Jun 2006, Timo Hirvonen wrote:
> >
> > > @@ -818,17 +817,12 @@ void show_combined_diff(struct combine_d
> > > struct diff_options *opt = &rev->diffopt;
> > > if (!p->len)
> > > return;
> > > - switch (opt->output_format) {
> > > - case DIFF_FORMAT_RAW:
> > > - case DIFF_FORMAT_NAME_STATUS:
> > > - case DIFF_FORMAT_NAME:
> > > + if (opt->output_format & (DIFF_FORMAT_RAW |
> > > + DIFF_FORMAT_NAME |
> > > + DIFF_FORMAT_NAME_STATUS)) {
> > > show_raw_diff(p, num_parent, rev);
> > > - return;
> > > - case DIFF_FORMAT_PATCH:
> > > + } else if (opt->output_format & DIFF_FORMAT_PATCH) {
> >
> > Not that it matters, but this "else" could go. (Otherwise, "--raw -p"
> > would be the same as "--raw", right?)
>
> Just tested, ./git log -p --raw displays both raw and patch. I think it
> works because I changed diff_tree_combined() to use show_raw_diff() and
> show_patch_diff() directly.
>
> It feels 'wrong' to check flags and then call a function which checks
> the flags again. This combined diff stuff is confusing.
Sorry for not checking the result, but just the patch. I also find this
behaviour confusing. Junio?
> > > + int inter_name_termination = '\t';
> > > + int line_termination = options->line_termination;
> > > +
> > > + if (!line_termination)
> > > + inter_name_termination = 0;
> >
> > <nit type=minor>
> > This should be part of patch 1/7.
> > </nit>
>
> That clean up was possible only after I made other changes to the code,
> I think. At least it wasn't obvious when I wrote 1/7.
It is just a minor nit, I do not think it is necessary to change the
patch.
> > > show_stats(diffstat);
> > > free(diffstat);
> >
> > Why not go the full nine yards, and make diffstat not a pointer, but the
> > struct itself? You would avoid calloc()ing and free()ing. (Of course,
> > instead of calloc()ing you have to memset() it to 0.)
>
> I was blind :)
;-) In my experience, after staring at the code too long, you turn blind.
This is why I like a second pair of eyeballs so much.
> > > + if (output_format & DIFF_FORMAT_PATCH) {
> > > + if (output_format & (DIFF_FORMAT_DIFFSTAT |
> > > + DIFF_FORMAT_SUMMARY)) {
> > > + if (options->stat_sep)
> > > + fputs(options->stat_sep, stdout);
> > > + else
> > > + putchar(options->line_termination);
> >
> > Are we sure we do not want something like
> >
> > if (output_format / DIFF_FORMAT_DIFFSTAT > 1)
> > /* output separator */
> >
> > after each format (this example being after the diffstat), the condition
> > being: if there is still an output format to come, add the separator?
>
> I'm not sure what you mean.
>
> It outputs separator between (diffstat and/or summary) and patch.
> There's no separator between diffstat and summary or raw and diffstat.
> Should there be one?
IMHO there should be one.
> Thanks for your comments. Should I patch the patch or send a fixed one?
I cannot speak for Junio, but I think an additional patch to clean things
up would be the way to go.
Ciao,
Dscho
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox