Skip to content

Commit

Permalink
Merge branch 'lt/rev-list' into next
Browse files Browse the repository at this point in the history
* lt/rev-list:
  First cut at libifying revlist generation
  Merge branch 'maint'
  sample hooks template.
  Teach the "git" command to handle some commands internally
  Use setenv(), fix warnings
  contrib/git-svn: version 0.10.0
  contrib/git-svn: optimize sequential commits to svn
  contrib/git-svn: add show-ignore command
  annotate: Use qx{} for pipes on activestate.
  annotate: Convert all -| calls to use a helper open_pipe().
  annotate: Handle dirty state and arbitrary revisions.
  git-fetch: print the new and old ref when fast-forwarding
  • Loading branch information
Junio C Hamano committed Feb 26, 2006
2 parents ab57c8d + ae56354 commit b5233a6
Show file tree
Hide file tree
Showing 19 changed files with 838 additions and 461 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ LIB_FILE=libgit.a
LIB_H = \
blob.h cache.h commit.h count-delta.h csum-file.h delta.h \
diff.h epoch.h object.h pack.h pkt-line.h quote.h refs.h \
run-command.h strbuf.h tag.h tree.h git-compat-util.h
run-command.h strbuf.h tag.h tree.h git-compat-util.h revision.h

DIFF_OBJS = \
diff.o diffcore-break.o diffcore-order.o diffcore-pathspec.o \
Expand All @@ -205,7 +205,7 @@ LIB_OBJS = \
quote.o read-cache.o refs.o run-command.o \
server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \
tag.o tree.o usage.o config.o environment.o ctype.o copy.o \
fetch-clone.o \
fetch-clone.o revision.o \
$(DIFF_OBJS)

LIBS = $(LIB_FILE)
Expand Down
2 changes: 1 addition & 1 deletion cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#define deflateBound(c,s) ((s) + (((s) + 7) >> 3) + (((s) + 63) >> 6) + 11)
#endif

#if defined(DT_UNKNOWN) && !NO_D_TYPE_IN_DIRENT
#if defined(DT_UNKNOWN) && !defined(NO_D_TYPE_IN_DIRENT)
#define DTYPE(de) ((de)->d_type)
#else
#undef DT_UNKNOWN
Expand Down
57 changes: 53 additions & 4 deletions contrib/git-svn/git-svn.perl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
$GIT_SVN_INDEX $GIT_SVN
$GIT_DIR $REV_DIR/;
$AUTHOR = 'Eric Wong <normalperson@yhbt.net>';
$VERSION = '0.9.1';
$VERSION = '0.10.0';
$GIT_DIR = $ENV{GIT_DIR} || "$ENV{PWD}/.git";
$GIT_SVN = $ENV{GIT_SVN_ID} || 'git-svn';
$GIT_SVN_INDEX = "$GIT_DIR/$GIT_SVN/index";
Expand All @@ -30,6 +30,7 @@
use File::Path qw/mkpath/;
use Getopt::Long qw/:config gnu_getopt no_ignore_case auto_abbrev/;
use File::Spec qw//;
use POSIX qw/strftime/;
my $sha1 = qr/[a-f\d]{40}/;
my $sha1_short = qr/[a-f\d]{6,40}/;
my ($_revision,$_stdin,$_no_ignore_ext,$_no_stop_copy,$_help,$_rmdir,$_edit,
Expand All @@ -49,6 +50,7 @@
fetch => [ \&fetch, "Download new revisions from SVN" ],
init => [ \&init, "Initialize and fetch (import)"],
commit => [ \&commit, "Commit git revisions to SVN" ],
'show-ignore' => [ \&show_ignore, "Show svn:ignore listings" ],
rebuild => [ \&rebuild, "Rebuild git-svn metadata (after git clone)" ],
help => [ \&usage, "Show help" ],
);
Expand Down Expand Up @@ -258,6 +260,30 @@ sub commit {

}

sub show_ignore {
require File::Find or die $!;
my $exclude_file = "$GIT_DIR/info/exclude";
open my $fh, '<', $exclude_file or croak $!;
chomp(my @excludes = (<$fh>));
close $fh or croak $!;

$SVN_URL ||= file_to_s("$GIT_DIR/$GIT_SVN/info/url");
chdir $SVN_WC or croak $!;
my %ign;
File::Find::find({wanted=>sub{if(lstat $_ && -d _ && -d "$_/.svn"){
s#^\./##;
@{$ign{$_}} = safe_qx(qw(svn propget svn:ignore),$_);
}}, no_chdir=>1},'.');

print "\n# /\n";
foreach (@{$ign{'.'}}) { print '/',$_ if /\S/ }
delete $ign{'.'};
foreach my $i (sort keys %ign) {
print "\n# ",$i,"\n";
foreach (@{$ign{$i}}) { print '/',$i,'/',$_ if /\S/ }
}
}

########################### utility functions #########################

sub setup_git_svn {
Expand Down Expand Up @@ -566,6 +592,7 @@ sub handle_rmdir {
sub svn_commit_tree {
my ($svn_rev, $commit) = @_;
my $commit_msg = "$GIT_DIR/$GIT_SVN/.svn-commit.tmp.$$";
my %log_msg = ( msg => '' );
open my $msg, '>', $commit_msg or croak $!;

chomp(my $type = `git-cat-file -t $commit`);
Expand All @@ -581,6 +608,7 @@ sub svn_commit_tree {
if (!$in_msg) {
$in_msg = 1 if (/^\s*$/);
} else {
$log_msg{msg} .= $_;
print $msg $_ or croak $!;
}
}
Expand All @@ -600,9 +628,30 @@ sub svn_commit_tree {
join("\n",@ci_output),"\n";
my ($rev_committed) = ($committed =~ /^Committed revision (\d+)\./);

# resync immediately
my @svn_up = (qw(svn up), "-r$svn_rev");
my @svn_up = qw(svn up);
push @svn_up, '--ignore-externals' unless $_no_ignore_ext;
if ($rev_committed == ($svn_rev + 1)) {
push @svn_up, "-r$rev_committed";
sys(@svn_up);
my $info = svn_info('.');
my $date = $info->{'Last Changed Date'} or die "Missing date\n";
if ($info->{'Last Changed Rev'} != $rev_committed) {
croak "$info->{'Last Changed Rev'} != $rev_committed\n"
}
my ($Y,$m,$d,$H,$M,$S,$tz) = ($date =~
/(\d{4})\-(\d\d)\-(\d\d)\s
(\d\d)\:(\d\d)\:(\d\d)\s([\-\+]\d+)/x)
or croak "Failed to parse date: $date\n";
$log_msg{date} = "$tz $Y-$m-$d $H:$M:$S";
$log_msg{author} = $info->{'Last Changed Author'};
$log_msg{revision} = $rev_committed;
$log_msg{msg} .= "\n";
my $parent = file_to_s("$REV_DIR/$svn_rev");
git_commit(\%log_msg, $parent, $commit);
return $rev_committed;
}
# resync immediately
push @svn_up, "-r$svn_rev";
sys(@svn_up);
return fetch("$rev_committed=$commit")->{revision};
}
Expand Down Expand Up @@ -699,7 +748,7 @@ sub svn_info {
# only single-lines seem to exist in svn info output
while (<$info_fh>) {
chomp $_;
if (m#^([^:]+)\s*:\s*(\S*)$#) {
if (m#^([^:]+)\s*:\s*(\S.*)$#) {
$ret->{$1} = $2;
push @{$ret->{-order}}, $1;
}
Expand Down
7 changes: 7 additions & 0 deletions contrib/git-svn/git-svn.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ rebuild::
the directory/repository you're tracking has moved or changed
protocols.

show-ignore::
Recursively finds and lists the svn:ignore property on
directories. The output is suitable for appending to
the $GIT_DIR/info/exclude file.

OPTIONS
-------
-r <ARG>::
Expand Down Expand Up @@ -152,6 +157,8 @@ Tracking and contributing to an Subversion managed-project:
git commit git-svn-HEAD..my-branch
# Something is committed to SVN, pull the latest into your branch::
git-svn fetch && git pull . git-svn-HEAD
# Append svn:ignore settings to the default git exclude file:
git-svn show-ignore >> .git/info/exclude

DESIGN PHILOSOPHY
-----------------
Expand Down
1 change: 1 addition & 0 deletions epoch.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include "cache.h"
#include "commit.h"
#include "revision.h"
#include "epoch.h"

struct fraction {
Expand Down
1 change: 0 additions & 1 deletion epoch.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ typedef int (*emitter_func) (struct commit *);
int sort_list_in_merge_order(struct commit_list *list, emitter_func emitter);

/* Low bits are used by rev-list */
#define UNINTERESTING (1u<<10)
#define BOUNDARY (1u<<11)
#define VISITED (1u<<12)
#define DISCONTINUITY (1u<<13)
Expand Down
2 changes: 1 addition & 1 deletion exec_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ void git_set_exec_path(const char *exec_path)


/* Returns the highest-priority, location to look for git programs. */
const char *git_exec_path()
const char *git_exec_path(void)
{
const char *env;

Expand Down
2 changes: 1 addition & 1 deletion fetch-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ static void mark_common(struct commit *commit,
Get the next rev to send, ignoring the common.
*/

static const unsigned char* get_rev()
static const unsigned char* get_rev(void)
{
struct commit *commit = NULL;

Expand Down
2 changes: 1 addition & 1 deletion fsck-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ static int check_strict = 0;
static int keep_cache_objects = 0;
static unsigned char head_sha1[20];

#if NO_D_INO_IN_DIRENT
#ifdef NO_D_INO_IN_DIRENT
#define SORT_DIRENT 0
#define DIRENT_SORT_HINT(de) 0
#else
Expand Down
Loading

0 comments on commit b5233a6

Please sign in to comment.