Merge branch 'maint'
authorShawn O. Pearce <spearce@spearce.org>
Wed, 8 Oct 2008 15:05:43 +0000 (08:05 -0700)
committerShawn O. Pearce <spearce@spearce.org>
Wed, 8 Oct 2008 15:05:43 +0000 (08:05 -0700)
* maint:
Do not use errno when pread() returns 0
git init: --bare/--shared overrides system/global config
git-push.txt: Describe --repo option in more detail
git rm: refresh index before up-to-date check
Fix a few typos in relnotes

1  2 
builtin-push.c
index-pack.c
diff --combined builtin-push.c
index cc6666f75e7db8a546d4a1589335589190e414fe,f5cc76266b1d7bc8bb0dcf0924cd866d326010a8..122fdcfbdc13a11388a091e5ec33d077648fab0a
@@@ -10,7 -10,7 +10,7 @@@
  #include "parse-options.h"
  
  static const char * const push_usage[] = {
-       "git push [--all | --mirror] [--dry-run] [--tags] [--receive-pack=<git-receive-pack>] [--repo=all] [-f | --force] [-v] [<repository> <refspec>...]",
+       "git push [--all | --mirror] [--dry-run] [--tags] [--receive-pack=<git-receive-pack>] [--repo=<repository>] [-f | --force] [-v] [<repository> <refspec>...]",
        NULL,
  };
  
@@@ -59,17 -59,8 +59,17 @@@ static int do_push(const char *repo, in
        if (remote->mirror)
                flags |= (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE);
  
 -      if ((flags & (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) && refspec)
 -              return -1;
 +      if ((flags & TRANSPORT_PUSH_ALL) && refspec) {
 +              if (!strcmp(*refspec, "refs/tags/*"))
 +                      return error("--all and --tags are incompatible");
 +              return error("--all can't be combined with refspecs");
 +      }
 +
 +      if ((flags & TRANSPORT_PUSH_MIRROR) && refspec) {
 +              if (!strcmp(*refspec, "refs/tags/*"))
 +                      return error("--mirror and --tags are incompatible");
 +              return error("--mirror can't be combined with refspecs");
 +      }
  
        if ((flags & (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) ==
                                (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) {
diff --combined index-pack.c
index 2e4c0885f2c6f6907481dfefe7e0761c3957d8a6,c45ae20e8ffacefa43c5d0ab9daf0ff6ef181d4a..73860bf3da062d283c266f6b83fdf3f613af26e7
@@@ -67,7 -67,7 +67,7 @@@ static struct progress *progress
  static unsigned char input_buffer[4096];
  static unsigned int input_offset, input_len;
  static off_t consumed_bytes;
 -static SHA_CTX input_ctx;
 +static git_SHA_CTX input_ctx;
  static uint32_t input_crc32;
  static int input_fd, output_fd, pack_fd;
  
@@@ -119,7 -119,7 +119,7 @@@ static void flush(void
        if (input_offset) {
                if (output_fd >= 0)
                        write_or_die(output_fd, input_buffer, input_offset);
 -              SHA1_Update(&input_ctx, input_buffer, input_offset);
 +              git_SHA1_Update(&input_ctx, input_buffer, input_offset);
                memmove(input_buffer, input_buffer + input_offset, input_len);
                input_offset = 0;
        }
@@@ -188,7 -188,7 +188,7 @@@ static char *open_pack_file(char *pack_
                output_fd = -1;
                pack_fd = input_fd;
        }
 -      SHA1_Init(&input_ctx);
 +      git_SHA1_Init(&input_ctx);
        return pack_name;
  }
  
@@@ -365,8 -365,11 +365,11 @@@ static void *get_data_from_pack(struct 
        data = src;
        do {
                ssize_t n = pread(pack_fd, data + rdy, len - rdy, from + rdy);
-               if (n <= 0)
+               if (n < 0)
                        die("cannot pread pack file: %s", strerror(errno));
+               if (!n)
+                       die("premature end of pack file, %lu bytes missing",
+                           len - rdy);
                rdy += n;
        } while (rdy < len);
        data = xmalloc(obj->size);
@@@ -588,7 -591,7 +591,7 @@@ static void parse_pack_objects(unsigne
  
        /* Check pack integrity */
        flush();
 -      SHA1_Final(sha1, &input_ctx);
 +      git_SHA1_Final(sha1, &input_ctx);
        if (hashcmp(fill(20), sha1))
                die("pack is corrupted (SHA1 mismatch)");
        use(20);