Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/attr.c
diff options
context:
space:
mode:
authorDerrick Stolee <dstolee@microsoft.com>2021-09-08 04:42:31 +0300
committerJunio C Hamano <gitster@pobox.com>2021-09-08 08:41:10 +0300
commit77efbb366abe53792511580b96a39c636c5b0401 (patch)
tree513cca56b1d692cffe8383b84c158a69cbcd5080 /attr.c
parent02155c8c005d0f8ee20a38245e9a065e8b5cc7dc (diff)
attr: be careful about sparse directories
Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Reviewed-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'attr.c')
-rw-r--r--attr.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/attr.c b/attr.c
index d029e681f2..79adaa50ea 100644
--- a/attr.c
+++ b/attr.c
@@ -14,6 +14,7 @@
#include "utf8.h"
#include "quote.h"
#include "thread-utils.h"
+#include "dir.h"
const char git_attr__true[] = "(builtin)true";
const char git_attr__false[] = "\0(builtin)false";
@@ -744,6 +745,20 @@ static struct attr_stack *read_attr_from_index(struct index_state *istate,
if (!istate)
return NULL;
+ /*
+ * The .gitattributes file only applies to files within its
+ * parent directory. In the case of cone-mode sparse-checkout,
+ * the .gitattributes file is sparse if and only if all paths
+ * within that directory are also sparse. Thus, don't load the
+ * .gitattributes file since it will not matter.
+ *
+ * In the case of a sparse index, it is critical that we don't go
+ * looking for a .gitattributes file, as doing so would cause the
+ * index to expand.
+ */
+ if (!path_in_cone_mode_sparse_checkout(path, istate))
+ return NULL;
+
buf = read_blob_data_from_index(istate, path, NULL);
if (!buf)
return NULL;