Merge branch 'maint'
authorJunio C Hamano <junkio@cox.net>
Thu, 12 Apr 2007 01:43:01 +0000 (18:43 -0700)
committerJunio C Hamano <junkio@cox.net>
Thu, 12 Apr 2007 01:43:01 +0000 (18:43 -0700)
* maint:
GIT 1.5.1.1
cvsserver: Fix handling of diappeared files on update
fsck: do not complain on detached HEAD.
(encode_85, decode_85): Mark source buffer pointer as "const".

1  2 
builtin-fsck.c
cache.h
diff --combined builtin-fsck.c
index 4d8b66c344422dd60c72c72bbfbc5aa87be7907e,7c3b0a535f81a350d11df112a6a5b5a49b139afb..05d98d2cfc0c8ba5e38482a181fee8115e9bd640
@@@ -14,7 -14,6 +14,7 @@@
  static int show_root;
  static int show_tags;
  static int show_unreachable;
 +static int include_reflogs = 1;
  static int check_full;
  static int check_strict;
  static int keep_cache_objects;
@@@ -349,7 -348,7 +349,7 @@@ static int fsck_tag(struct tag *tag
        return 0;
  }
  
 -static int fsck_sha1(unsigned char *sha1)
 +static int fsck_sha1(const unsigned char *sha1)
  {
        struct object *obj = parse_object(sha1);
        if (!obj) {
@@@ -518,8 -517,7 +518,8 @@@ static int fsck_handle_ref(const char *
  static void get_default_heads(void)
  {
        for_each_ref(fsck_handle_ref, NULL);
 -      for_each_reflog(fsck_handle_reflog, NULL);
 +      if (include_reflogs)
 +              for_each_reflog(fsck_handle_reflog, NULL);
  
        /*
         * Not having any default heads isn't really fatal, but
         * "show_unreachable" flag.
         */
        if (!default_refs) {
-               error("No default references");
+               fprintf(stderr, "notice: No default references\n");
                show_unreachable = 0;
        }
  }
@@@ -554,15 -552,23 +554,23 @@@ static int fsck_head_link(void
  {
        unsigned char sha1[20];
        int flag;
-       const char *head_points_at = resolve_ref("HEAD", sha1, 1, &flag);
-       if (!head_points_at || !(flag & REF_ISSYMREF))
-               return error("HEAD is not a symbolic ref");
-       if (prefixcmp(head_points_at, "refs/heads/"))
+       int null_is_error = 0;
+       const char *head_points_at = resolve_ref("HEAD", sha1, 0, &flag);
+       if (!head_points_at)
+               return error("Invalid HEAD");
+       if (!strcmp(head_points_at, "HEAD"))
+               /* detached HEAD */
+               null_is_error = 1;
+       else if (prefixcmp(head_points_at, "refs/heads/"))
                return error("HEAD points to something strange (%s)",
                             head_points_at);
-       if (is_null_sha1(sha1))
-               return error("HEAD: not a valid git pointer");
+       if (is_null_sha1(sha1)) {
+               if (null_is_error)
+                       return error("HEAD: detached HEAD points at nothing");
+               fprintf(stderr, "notice: HEAD points to an unborn branch (%s)\n",
+                       head_points_at + 11);
+       }
        return 0;
  }
  
@@@ -618,10 -624,6 +626,10 @@@ int cmd_fsck(int argc, char **argv, con
                        keep_cache_objects = 1;
                        continue;
                }
 +              if (!strcmp(arg, "--no-reflogs")) {
 +                      include_reflogs = 0;
 +                      continue;
 +              }
                if (!strcmp(arg, "--full")) {
                        check_full = 1;
                        continue;
  
                for (p = packed_git; p; p = p->next) {
                        uint32_t i, num = num_packed_objects(p);
 -                      for (i = 0; i < num; i++) {
 -                              unsigned char sha1[20];
 -                              nth_packed_object_sha1(p, i, sha1);
 -                              fsck_sha1(sha1);
 -                      }
 +                      for (i = 0; i < num; i++)
 +                              fsck_sha1(nth_packed_object_sha1(p, i));
                }
        }
  
diff --combined cache.h
index eb57507b804019f7d6b27a27a2b262d4b051e43b,1904131f27c2b41609c505fb8f73143619c133fa..b1bd9e46c2bd64e00b671ff5ed512d9c12b53309
+++ b/cache.h
@@@ -128,6 -128,7 +128,6 @@@ static inline unsigned int ce_mode_from
  extern struct cache_entry **active_cache;
  extern unsigned int active_nr, active_alloc, active_cache_changed;
  extern struct cache_tree *active_cache_tree;
 -extern int cache_errno;
  
  enum object_type {
        OBJ_BAD = -1,
@@@ -187,7 -188,7 +187,7 @@@ extern int add_cache_entry(struct cache
  extern struct cache_entry *refresh_cache_entry(struct cache_entry *ce, int really);
  extern int remove_cache_entry_at(int pos);
  extern int remove_file_from_cache(const char *path);
 -extern int add_file_to_index(const char *path, int verbose);
 +extern int add_file_to_cache(const char *path, int verbose);
  extern int ce_same_name(struct cache_entry *a, struct cache_entry *b);
  extern int ce_match_stat(struct cache_entry *ce, struct stat *st, int);
  extern int ce_modified(struct cache_entry *ce, struct stat *st, int);
@@@ -211,11 -212,6 +211,11 @@@ struct lock_file 
  };
  extern int hold_lock_file_for_update(struct lock_file *, const char *path, int);
  extern int commit_lock_file(struct lock_file *);
 +
 +extern int hold_locked_index(struct lock_file *, int);
 +extern int commit_locked_index(struct lock_file *);
 +extern void set_alternate_index_output(const char *);
 +
  extern void rollback_lock_file(struct lock_file *);
  extern int delete_ref(const char *, unsigned char *sha1);
  
@@@ -432,7 -428,7 +432,7 @@@ extern unsigned char* use_pack(struct p
  extern void unuse_pack(struct pack_window **);
  extern struct packed_git *add_packed_git(const char *, int, int);
  extern uint32_t num_packed_objects(const struct packed_git *p);
 -extern int nth_packed_object_sha1(const struct packed_git *, uint32_t, unsigned char*);
 +extern const unsigned char *nth_packed_object_sha1(const struct packed_git *, uint32_t);
  extern off_t find_pack_entry_one(const unsigned char *, struct packed_git *);
  extern void *unpack_entry(struct packed_git *, off_t, enum object_type *, unsigned long *);
  extern unsigned long unpack_object_header_gently(const unsigned char *buf, unsigned long len, enum object_type *type, unsigned long *sizep);
@@@ -472,8 -468,8 +472,8 @@@ extern int pager_in_use
  extern int pager_use_color;
  
  /* base85 */
- int decode_85(char *dst, char *line, int linelen);
- void encode_85(char *buf, unsigned char *data, int bytes);
+ int decode_85(char *dst, const char *line, int linelen);
+ void encode_85(char *buf, const unsigned char *data, int bytes);
  
  /* alloc.c */
  struct blob;
@@@ -496,7 -492,4 +496,7 @@@ extern void trace_argv_printf(const cha
  extern int convert_to_git(const char *path, char **bufp, unsigned long *sizep);
  extern int convert_to_working_tree(const char *path, char **bufp, unsigned long *sizep);
  
 +/* match-trees.c */
 +void shift_tree(const unsigned char *, const unsigned char *, unsigned char *, int);
 +
  #endif /* CACHE_H */