+static int add_cacheinfo(char *arg1, char *arg2, char *arg3)
+{
+ int size, len, option;
+ unsigned int mode;
+ unsigned char sha1[20];
+ struct cache_entry *ce;
+
+ if (sscanf(arg1, "%o", &mode) != 1)
+ return -1;
+ if (get_sha1_hex(arg2, sha1))
+ return -1;
+ if (!verify_path(arg3))
+ return -1;
+
+ len = strlen(arg3);
+ size = cache_entry_size(len);
+ ce = xmalloc(size);
+ memset(ce, 0, size);
+
+ memcpy(ce->sha1, sha1, 20);
+ memcpy(ce->name, arg3, len);
+ ce->ce_flags = htons(len);
+ ce->ce_mode = create_ce_mode(mode);
+ option = allow_add ? ADD_CACHE_OK_TO_ADD : 0;
+ option |= allow_replace ? ADD_CACHE_OK_TO_REPLACE : 0;
+ return add_cache_entry(ce, option);
+}
+
+static const char *lockfile_name = NULL;