Merge branch 'maint-1.5.4' into maint
authorJunio C Hamano <gitster@pobox.com>
Wed, 30 Apr 2008 05:55:07 +0000 (22:55 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 30 Apr 2008 05:55:07 +0000 (22:55 -0700)
* maint-1.5.4:
cvsimport: always pass user data to "system" as a list
fix reflog approxidate parsing bug

1  2 
git-cvsimport.perl
sha1_name.c
diff --combined git-cvsimport.perl
index 95c5eec51ecc6ab6f142cef51eb4bd3b5842debb,33777e278585268c767ebcab6fbf65352a5459f0..bdac5d51b6dfb721bb648e455cb8f3c5078217e4
@@@ -15,7 -15,7 +15,7 @@@
  
  use strict;
  use warnings;
 -use Getopt::Std;
 +use Getopt::Long;
  use File::Spec;
  use File::Temp qw(tempfile tmpnam);
  use File::Path qw(mkpath);
@@@ -29,7 -29,7 +29,7 @@@ use IPC::Open2
  $SIG{'PIPE'}="IGNORE";
  $ENV{'TZ'}="UTC";
  
 -our ($opt_h,$opt_o,$opt_v,$opt_k,$opt_u,$opt_d,$opt_p,$opt_C,$opt_z,$opt_i,$opt_P, $opt_s,$opt_m,$opt_M,$opt_A,$opt_S,$opt_L, $opt_a, $opt_r);
 +our ($opt_h,$opt_o,$opt_v,$opt_k,$opt_u,$opt_d,$opt_p,$opt_C,$opt_z,$opt_i,$opt_P, $opt_s,$opt_m,@opt_M,$opt_A,$opt_S,$opt_L, $opt_a, $opt_r);
  my (%conv_author_name, %conv_author_email);
  
  sub usage(;$) {
@@@ -112,12 -112,7 +112,12 @@@ sub read_repo_config 
  
  my $opts = "haivmkuo:d:p:r:C:z:s:M:P:A:S:L:";
  read_repo_config($opts);
 -getopts($opts) or usage();
 +Getopt::Long::Configure( 'no_ignore_case', 'bundling' );
 +
 +# turn the Getopt::Std specification in a Getopt::Long one,
 +# with support for multiple -M options
 +GetOptions( map { s/:/=s/; /M/ ? "$_\@" : $_ } split( /(?!:)/, $opts ) )
 +    or usage();
  usage if $opt_h;
  
  if (@ARGV == 0) {
@@@ -169,10 -164,10 +169,10 @@@ if ($#ARGV == 0) 
  
  our @mergerx = ();
  if ($opt_m) {
 -      @mergerx = ( qr/\b(?:from|of|merge|merging|merged) (\w+)/i );
 +      @mergerx = ( qr/\b(?:from|of|merge|merging|merged) ([-\w]+)/i );
  }
 -if ($opt_M) {
 -      push (@mergerx, qr/$opt_M/);
 +if (@opt_M) {
 +      push (@mergerx, map { qr/$_/ } @opt_M);
  }
  
  # Remember UTC of our starting time
@@@ -772,7 -767,7 +772,7 @@@ sub commit 
        waitpid($pid,0);
        die "Error running git-commit-tree: $?\n" if $?;
  
-       system("git-update-ref $remote/$branch $cid") == 0
+       system('git-update-ref', "$remote/$branch", $cid) == 0
                or die "Cannot write branch $branch for update: $!\n";
  
        if ($tag) {
diff --combined sha1_name.c
index 491d2e7ebf19d5c582adbc5ece28d931b09b8a6d,6298c37ae3a9b516ff75c122abf2181827f32bce..b0b2167578a7baebeba676af0b33161fb688bae0
@@@ -192,25 -192,26 +192,25 @@@ static int get_short_sha1(const char *n
  
  const char *find_unique_abbrev(const unsigned char *sha1, int len)
  {
 -      int status, is_null;
 +      int status, exists;
        static char hex[41];
  
 -      is_null = is_null_sha1(sha1);
 +      exists = has_sha1_file(sha1);
        memcpy(hex, sha1_to_hex(sha1), 40);
        if (len == 40 || !len)
                return hex;
        while (len < 40) {
                unsigned char sha1_ret[20];
                status = get_short_sha1(hex, len, sha1_ret, 1);
 -              if (!status ||
 -                  (is_null && status != SHORT_NAME_AMBIGUOUS)) {
 +              if (exists
 +                  ? !status
 +                  : status == SHORT_NAME_NOT_FOUND) {
                        hex[len] = 0;
                        return hex;
                }
 -              if (status != SHORT_NAME_AMBIGUOUS)
 -                      return NULL;
                len++;
        }
 -      return NULL;
 +      return hex;
  }
  
  static int ambiguous_path(const char *path, int len)
@@@ -351,8 -352,11 +351,11 @@@ static int get_sha1_basic(const char *s
                }
                if (0 <= nth)
                        at_time = 0;
-               else
-                       at_time = approxidate(str + at + 2);
+               else {
+                       char *tmp = xstrndup(str + at + 2, reflog_len);
+                       at_time = approxidate(tmp);
+                       free(tmp);
+               }
                if (read_ref_at(real_ref, at_time, nth, sha1, NULL,
                                &co_time, &co_tz, &co_cnt)) {
                        if (at_time)
@@@ -426,37 -430,6 +429,37 @@@ static int get_nth_ancestor(const char 
        return 0;
  }
  
 +struct object *peel_to_type(const char *name, int namelen,
 +                          struct object *o, enum object_type expected_type)
 +{
 +      if (name && !namelen)
 +              namelen = strlen(name);
 +      if (!o) {
 +              unsigned char sha1[20];
 +              if (get_sha1_1(name, namelen, sha1))
 +                      return NULL;
 +              o = parse_object(sha1);
 +      }
 +      while (1) {
 +              if (!o || (!o->parsed && !parse_object(o->sha1)))
 +                      return NULL;
 +              if (o->type == expected_type)
 +                      return o;
 +              if (o->type == OBJ_TAG)
 +                      o = ((struct tag*) o)->tagged;
 +              else if (o->type == OBJ_COMMIT)
 +                      o = &(((struct commit *) o)->tree->object);
 +              else {
 +                      if (name)
 +                              error("%.*s: expected %s type, but the object "
 +                                    "dereferences to %s type",
 +                                    namelen, name, typename(expected_type),
 +                                    typename(o->type));
 +                      return NULL;
 +              }
 +      }
 +}
 +
  static int peel_onion(const char *name, int len, unsigned char *sha1)
  {
        unsigned char outer[20];
                hashcpy(sha1, o->sha1);
        }
        else {
 -              /* At this point, the syntax look correct, so
 +              /*
 +               * At this point, the syntax look correct, so
                 * if we do not get the needed object, we should
                 * barf.
                 */
 -
 -              while (1) {
 -                      if (!o || (!o->parsed && !parse_object(o->sha1)))
 -                              return -1;
 -                      if (o->type == expected_type) {
 -                              hashcpy(sha1, o->sha1);
 -                              return 0;
 -                      }
 -                      if (o->type == OBJ_TAG)
 -                              o = ((struct tag*) o)->tagged;
 -                      else if (o->type == OBJ_COMMIT)
 -                              o = &(((struct commit *) o)->tree->object);
 -                      else
 -                              return error("%.*s: expected %s type, but the object dereferences to %s type",
 -                                           len, name, typename(expected_type),
 -                                           typename(o->type));
 -                      if (!o->parsed)
 -                              parse_object(o->sha1);
 +              o = peel_to_type(name, len, o, expected_type);
 +              if (o) {
 +                      hashcpy(sha1, o->sha1);
 +                      return 0;
                }
 +              return -1;
        }
        return 0;
  }
@@@ -598,11 -583,8 +601,11 @@@ static int handle_one_ref(const char *p
        struct object *object = parse_object(sha1);
        if (!object)
                return 0;
 -      if (object->type == OBJ_TAG)
 +      if (object->type == OBJ_TAG) {
                object = deref_tag(object, path, strlen(path));
 +              if (!object)
 +                      return 0;
 +      }
        if (object->type != OBJ_COMMIT)
                return 0;
        insert_by_date((struct commit *)object, list);
@@@ -640,9 -622,9 +643,9 @@@ static int get_sha1_oneline(const char 
                unsigned long size;
  
                commit = pop_most_recent_commit(&list, ONELINE_SEEN);
 -              parse_object(commit->object.sha1);
 -              if (temp_commit_buffer)
 -                      free(temp_commit_buffer);
 +              if (!parse_object(commit->object.sha1))
 +                      continue;
 +              free(temp_commit_buffer);
                if (commit->buffer)
                        p = commit->buffer;
                else {
                        break;
                }
        }
 -      if (temp_commit_buffer)
 -              free(temp_commit_buffer);
 +      free(temp_commit_buffer);
        free_commit_list(list);
        for (l = backup; l; l = l->next)
                clear_commit_marks(l->item, ONELINE_SEEN);
@@@ -717,7 -700,7 +720,7 @@@ int get_sha1_with_mode(const char *name
                                break;
                        if (ce_stage(ce) == stage) {
                                hashcpy(sha1, ce->sha1);
 -                              *mode = ntohl(ce->ce_mode);
 +                              *mode = ce->ce_mode;
                                return 0;
                        }
                        pos++;