about summary refs log tree commit diff
path: root/third_party/git/read-cache.c
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-25T23·06+0100
committerVincent Ambo <tazjin@google.com>2020-05-25T23·06+0100
commit93ba78d6f4632ef1c5228965e3edc8c0faf88c1e (patch)
tree85730c182a9f5f492ade8e8ccdb1c2356f9900bd /third_party/git/read-cache.c
parent6f8fbf4aa4b1654ab27d4829e114538761817de0 (diff)
revert(3p/git): Revert merge of git upstream at v2.26.2 r/852
This causes cgit to serve error pages, which is undesirable.

This reverts commit 5229c9b232de5bfa959ad6ebbb4c8192ac513352, reversing
changes made to f2b211131f2347342dde63975b09cf603149f1a3.
Diffstat (limited to 'third_party/git/read-cache.c')
-rw-r--r--third_party/git/read-cache.c75
1 files changed, 19 insertions, 56 deletions
diff --git a/third_party/git/read-cache.c b/third_party/git/read-cache.c
index aa427c5c17..52ffa8a313 100644
--- a/third_party/git/read-cache.c
+++ b/third_party/git/read-cache.c
@@ -959,14 +959,11 @@ static int verify_dotfile(const char *rest, unsigned mode)
 
 int verify_path(const char *path, unsigned mode)
 {
-	char c = 0;
+	char c;
 
 	if (has_dos_drive_prefix(path))
 		return 0;
 
-	if (!is_valid_path(path))
-		return 0;
-
 	goto inside;
 	for (;;) {
 		if (!c)
@@ -974,7 +971,6 @@ int verify_path(const char *path, unsigned mode)
 		if (is_dir_sep(c)) {
 inside:
 			if (protect_hfs) {
-
 				if (is_hfs_dotgit(path))
 					return 0;
 				if (S_ISLNK(mode)) {
@@ -983,10 +979,6 @@ inside:
 				}
 			}
 			if (protect_ntfs) {
-#ifdef GIT_WINDOWS_NATIVE
-				if (c == '\\')
-					return 0;
-#endif
 				if (is_ntfs_dotgit(path))
 					return 0;
 				if (S_ISLNK(mode)) {
@@ -999,15 +991,7 @@ inside:
 			if ((c == '.' && !verify_dotfile(path, mode)) ||
 			    is_dir_sep(c) || c == '\0')
 				return 0;
-		} else if (c == '\\' && protect_ntfs) {
-			if (is_ntfs_dotgit(path))
-				return 0;
-			if (S_ISLNK(mode)) {
-				if (is_ntfs_dotgitmodules(path))
-					return 0;
-			}
 		}
-
 		c = *path++;
 	}
 }
@@ -1292,7 +1276,7 @@ static int add_index_entry_with_check(struct index_state *istate, struct cache_e
 	 */
 	if (istate->cache_nr > 0 &&
 		strcmp(ce->name, istate->cache[istate->cache_nr - 1]->name) > 0)
-		pos = index_pos_to_insert_pos(istate->cache_nr);
+		pos = -istate->cache_nr - 1;
 	else
 		pos = index_name_stage_pos(istate, ce->name, ce_namelen(ce), ce_stage(ce));
 
@@ -1488,27 +1472,6 @@ static void show_file(const char * fmt, const char * name, int in_porcelain,
 	printf(fmt, name);
 }
 
-int repo_refresh_and_write_index(struct repository *repo,
-				 unsigned int refresh_flags,
-				 unsigned int write_flags,
-				 int gentle,
-				 const struct pathspec *pathspec,
-				 char *seen, const char *header_msg)
-{
-	struct lock_file lock_file = LOCK_INIT;
-	int fd, ret = 0;
-
-	fd = repo_hold_locked_index(repo, &lock_file, 0);
-	if (!gentle && fd < 0)
-		return -1;
-	if (refresh_index(repo->index, refresh_flags, pathspec, seen, header_msg))
-		ret = 1;
-	if (0 <= fd && write_locked_index(repo->index, &lock_file, COMMIT_LOCK | write_flags))
-		ret = -1;
-	return ret;
-}
-
-
 int refresh_index(struct index_state *istate, unsigned int flags,
 		  const struct pathspec *pathspec,
 		  char *seen, const char *header_msg)
@@ -1636,17 +1599,16 @@ struct cache_entry *refresh_cache_entry(struct index_state *istate,
 
 #define INDEX_FORMAT_DEFAULT 3
 
-static unsigned int get_index_format_default(struct repository *r)
+static unsigned int get_index_format_default(void)
 {
 	char *envversion = getenv("GIT_INDEX_VERSION");
 	char *endp;
+	int value;
 	unsigned int version = INDEX_FORMAT_DEFAULT;
 
 	if (!envversion) {
-		prepare_repo_settings(r);
-
-		if (r->settings.index_version >= 0)
-			version = r->settings.index_version;
+		if (!git_config_get_int("index.version", &value))
+			version = value;
 		if (version < INDEX_FORMAT_LB || INDEX_FORMAT_UB < version) {
 			warning(_("index.version set, but the value is invalid.\n"
 				  "Using version %i"), INDEX_FORMAT_DEFAULT);
@@ -1806,7 +1768,7 @@ static struct cache_entry *create_from_disk(struct mem_pool *ce_mem_pool,
 		const unsigned char *cp = (const unsigned char *)name;
 		size_t strip_len, previous_len;
 
-		/* If we're at the beginning of a block, ignore the previous name */
+		/* If we're at the begining of a block, ignore the previous name */
 		strip_len = decode_varint(&cp);
 		if (previous_ce) {
 			previous_len = previous_ce->ce_namelen;
@@ -1882,17 +1844,18 @@ static void check_ce_order(struct index_state *istate)
 
 static void tweak_untracked_cache(struct index_state *istate)
 {
-	struct repository *r = the_repository;
-
-	prepare_repo_settings(r);
-
-	if (r->settings.core_untracked_cache  == UNTRACKED_CACHE_REMOVE) {
+	switch (git_config_get_untracked_cache()) {
+	case -1: /* keep: do nothing */
+		break;
+	case 0: /* false */
 		remove_untracked_cache(istate);
-		return;
-	}
-
-	if (r->settings.core_untracked_cache == UNTRACKED_CACHE_WRITE)
+		break;
+	case 1: /* true */
 		add_untracked_cache(istate);
+		break;
+	default: /* unknown value: do nothing */
+		break;
+	}
 }
 
 static void tweak_split_index(struct index_state *istate)
@@ -1931,7 +1894,7 @@ static size_t estimate_cache_size(size_t ondisk_size, unsigned int entries)
 	/*
 	 * Account for potential alignment differences.
 	 */
-	per_entry += align_padding_size(per_entry, 0);
+	per_entry += align_padding_size(sizeof(struct cache_entry), -sizeof(struct ondisk_cache_entry));
 	return ondisk_size + entries * per_entry;
 }
 
@@ -2802,7 +2765,7 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
 	}
 
 	if (!istate->version) {
-		istate->version = get_index_format_default(the_repository);
+		istate->version = get_index_format_default();
 		if (git_env_bool("GIT_TEST_SPLIT_INDEX", 0))
 			init_split_index(istate);
 	}