-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sparse index: delete ignored files outside sparse cone #1009
Changes from all commits
c407b2c
8660877
edb00d3
c8620de
3717161
98b4cae
6ec3cb2
d57f48c
91b53f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -210,6 +210,16 @@ case-insensitive check. This corrects for case mismatched filenames in the | |
'git sparse-checkout set' command to reflect the expected cone in the working | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Johannes Schindelin wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Derrick Stolee wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Elijah Newren wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Elijah Newren wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Johannes Schindelin wrote (reply to this):
|
||
directory. | ||
|
||
When changing the sparse-checkout patterns in cone mode, Git will inspect each | ||
tracked directory that is not within the sparse-checkout cone to see if it | ||
contains any untracked files. If all of those files are ignored due to the | ||
`.gitignore` patterns, then the directory will be deleted. If any of the | ||
untracked files within that directory is not ignored, then no deletions will | ||
occur within that directory and a warning message will appear. If these files | ||
are important, then reset your sparse-checkout definition so they are included, | ||
use `git add` and `git commit` to store them, then remove any remaining files | ||
manually to ensure Git can behave optimally. | ||
|
||
|
||
SUBMODULES | ||
---------- | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
#include "utf8.h" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Johannes Schindelin wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Derrick Stolee wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Elijah Newren wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Derrick Stolee wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Elijah Newren wrote (reply to this):
|
||
#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; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -190,21 +190,16 @@ static int refresh(int verbose, const struct pathspec *pathspec) | |
struct string_list only_match_skip_worktree = STRING_LIST_INIT_NODUP; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Derrick Stolee wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Johannes Schindelin wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Derrick Stolee wrote (reply to this):
|
||
int flags = REFRESH_IGNORE_SKIP_WORKTREE | | ||
(verbose ? REFRESH_IN_PORCELAIN : REFRESH_QUIET); | ||
struct pattern_list pl = { 0 }; | ||
int sparse_checkout_enabled = !get_sparse_checkout_patterns(&pl); | ||
|
||
seen = xcalloc(pathspec->nr, 1); | ||
refresh_index(&the_index, flags, pathspec, seen, | ||
_("Unstaged changes after refreshing the index:")); | ||
for (i = 0; i < pathspec->nr; i++) { | ||
if (!seen[i]) { | ||
const char *path = pathspec->items[i].original; | ||
int dtype = DT_REG; | ||
|
||
if (matches_skip_worktree(pathspec, i, &skip_worktree_seen) || | ||
(sparse_checkout_enabled && | ||
!path_matches_pattern_list(path, strlen(path), NULL, | ||
&dtype, &pl, &the_index))) { | ||
!path_in_sparse_checkout(path, &the_index)) { | ||
string_list_append(&only_match_skip_worktree, | ||
pathspec->items[i].original); | ||
} else { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3069,7 +3069,7 @@ static int do_write_locked_index(struct index_state *istate, struct lock_file *l | |
int ret; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Derrick Stolee wrote (reply to this):
|
||
int was_full = !istate->sparse_index; | ||
|
||
ret = convert_to_sparse(istate); | ||
ret = convert_to_sparse(istate, 0); | ||
|
||
if (ret) { | ||
warning(_("failed to convert to a sparse-index")); | ||
|
@@ -3182,7 +3182,7 @@ static int write_shared_index(struct index_state *istate, | |
int ret, was_full = !istate->sparse_index; | ||
|
||
move_cache_to_base_index(istate); | ||
convert_to_sparse(istate); | ||
convert_to_sparse(istate, 0); | ||
|
||
trace2_region_enter_printf("index", "shared/do_write_index", | ||
the_repository, "%s", get_tempfile_path(*temp)); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the Git mailing list, Elijah Newren wrote (reply to this):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the Git mailing list, Derrick Stolee wrote (reply to this):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the Git mailing list, Elijah Newren wrote (reply to this):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the Git mailing list, Derrick Stolee wrote (reply to this):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the Git mailing list, Elijah Newren wrote (reply to this):