Merge branch 'gl/cleanup'
authorJunio C Hamano <junkio@cox.net>
Sat, 26 Aug 2006 08:06:22 +0000 (01:06 -0700)
committerJunio C Hamano <junkio@cox.net>
Sat, 26 Aug 2006 08:06:22 +0000 (01:06 -0700)
* gl/cleanup:
Convert memset(hash,0,20) to hashclr(hash).
Convert memcpy(a,b,20) to hashcpy(a,b).

1  2 
builtin-update-index.c
cache.h
http-push.c
diff --combined builtin-update-index.c
index 75c0abb96c237ad5d9dce0263990b71d5805898e,867512647195073860f017340ac1ebd0c27fce67..0620e779b04146a01f9e06cbbcd535b106034bd6
@@@ -142,7 -142,7 +142,7 @@@ static int add_cacheinfo(unsigned int m
        size = cache_entry_size(len);
        ce = xcalloc(1, size);
  
-       memcpy(ce->sha1, sha1, 20);
+       hashcpy(ce->sha1, sha1);
        memcpy(ce->name, path, len);
        ce->ce_flags = create_ce_flags(len, stage);
        ce->ce_mode = create_ce_mode(mode);
@@@ -306,7 -306,7 +306,7 @@@ static void read_index_info(int line_te
  }
  
  static const char update_index_usage[] =
 -"git-update-index [-q] [--add] [--replace] [--remove] [--unmerged] [--refresh] [--really-refresh] [--cacheinfo] [--chmod=(+|-)x] [--assume-unchanged] [--info-only] [--force-remove] [--stdin] [--index-info] [--unresolve] [--again] [--ignore-missing] [-z] [--verbose] [--] <file>...";
 +"git-update-index [-q] [--add] [--replace] [--remove] [--unmerged] [--refresh] [--really-refresh] [--cacheinfo] [--chmod=(+|-)x] [--assume-unchanged] [--info-only] [--force-remove] [--stdin] [--index-info] [--unresolve] [--again | -g] [--ignore-missing] [-z] [--verbose] [--] <file>...";
  
  static unsigned char head_sha1[20];
  static unsigned char merge_head_sha1[20];
@@@ -333,7 -333,7 +333,7 @@@ static struct cache_entry *read_one_ent
        size = cache_entry_size(namelen);
        ce = xcalloc(1, size);
  
-       memcpy(ce->sha1, sha1, 20);
+       hashcpy(ce->sha1, sha1);
        memcpy(ce->name, path, namelen);
        ce->ce_flags = create_ce_flags(namelen, stage);
        ce->ce_mode = create_ce_mode(mode);
@@@ -595,7 -595,7 +595,7 @@@ int cmd_update_index(int argc, const ch
                                        active_cache_changed = 0;
                                goto finish;
                        }
 -                      if (!strcmp(path, "--again")) {
 +                      if (!strcmp(path, "--again") || !strcmp(path, "-g")) {
                                has_errors = do_reupdate(argc - i, argv + i,
                                                         prefix, prefix_length);
                                if (has_errors)
diff --combined cache.h
index 30447944686e55eeadcfd7ac96ce88e93309d0c0,e00505a343a2260055f5177bdfd7740e2d5a5e33..1f212d77a4e41009c88c4b599022295b8a12a609
+++ b/cache.h
@@@ -123,7 -123,7 +123,7 @@@ extern int cache_errno
  #define INDEX_ENVIRONMENT "GIT_INDEX_FILE"
  #define GRAFT_ENVIRONMENT "GIT_GRAFT_FILE"
  
 -extern char *get_git_dir(void);
 +extern const char *get_git_dir(void);
  extern char *get_object_directory(void);
  extern char *get_refs_directory(void);
  extern char *get_index_file(void);
@@@ -218,6 -218,14 +218,14 @@@ static inline int hashcmp(const unsigne
  {
        return memcmp(sha1, sha2, 20);
  }
+ static inline void hashcpy(unsigned char *sha_dst, const unsigned char *sha_src)
+ {
+       memcpy(sha_dst, sha_src, 20);
+ }
+ static inline void hashclr(unsigned char *hash)
+ {
+       memset(hash, 0, 20);
+ }
  
  int git_mkstemp(char *path, size_t n, const char *template);
  
diff --combined http-push.c
index 7d12f6975cbb389a59b464138786e46326c6b9d4,8df7a0d576bfacab5ff61e0b6798cb2718401f5d..04cb238e965efdff564a9b57ce1253b274268c46
@@@ -1700,7 -1700,7 +1700,7 @@@ static int locking_available(void
        return lock_flags;
  }
  
 -struct object_list **add_one_object(struct object *obj, struct object_list **p)
 +static struct object_list **add_one_object(struct object *obj, struct object_list **p)
  {
        struct object_list *entry = xmalloc(sizeof(struct object_list));
        entry->item = obj;
@@@ -1874,7 -1874,7 +1874,7 @@@ static int one_local_ref(const char *re
        struct ref *ref;
        int len = strlen(refname) + 1;
        ref = xcalloc(1, sizeof(*ref) + len);
-       memcpy(ref->new_sha1, sha1, 20);
+       hashcpy(ref->new_sha1, sha1);
        memcpy(ref->name, refname, len);
        *local_tail = ref;
        local_tail = &ref->next;
@@@ -1909,7 -1909,7 +1909,7 @@@ static void one_remote_ref(char *refnam
        }
  
        ref = xcalloc(1, sizeof(*ref) + len);
-       memcpy(ref->old_sha1, remote_sha1, 20);
+       hashcpy(ref->old_sha1, remote_sha1);
        memcpy(ref->name, refname, len);
        *remote_tail = ref;
        remote_tail = &ref->next;
@@@ -2164,7 -2164,7 +2164,7 @@@ static void fetch_symref(const char *pa
        if (*symref != NULL)
                free(*symref);
        *symref = NULL;
-       memset(sha1, 0, 20);
+       hashclr(sha1);
  
        if (buffer.posn == 0)
                return;
@@@ -2445,7 -2445,7 +2445,7 @@@ int main(int argc, char **argv
                                continue;
                        }
                }
-               memcpy(ref->new_sha1, ref->peer_ref->new_sha1, 20);
+               hashcpy(ref->new_sha1, ref->peer_ref->new_sha1);
                if (is_zero_sha1(ref->new_sha1)) {
                        error("cannot happen anymore");
                        rc = -3;