From: Junio C Hamano Date: Sat, 26 Aug 2006 08:06:22 +0000 (-0700) Subject: Merge branch 'gl/cleanup' X-Git-Tag: v1.4.3-rc1~189 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/a7f051987c5f020e60da1e5d6ddefc3d443d3299?ds=inline;hp=-c Merge branch 'gl/cleanup' * gl/cleanup: Convert memset(hash,0,20) to hashclr(hash). Convert memcpy(a,b,20) to hashcpy(a,b). --- a7f051987c5f020e60da1e5d6ddefc3d443d3299 diff --combined builtin-update-index.c index 75c0abb96c,8675126471..0620e779b0 --- a/builtin-update-index.c +++ b/builtin-update-index.c @@@ -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] [--] ..."; +"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] [--] ..."; 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 3044794468,e00505a343..1f212d77a4 --- a/cache.h +++ 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 7d12f6975c,8df7a0d576..04cb238e96 --- a/http-push.c +++ b/http-push.c @@@ -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;