-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Avoid traversing NTFS junction points in git clean -dfx
#1976
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
Changes from all commits
b494e36
81e4da1
d9fdb5b
c6a539e
e004e1b
0a121c3
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 | ||||
---|---|---|---|---|---|---|
|
@@ -1250,6 +1250,45 @@ char *strip_path_suffix(const char *path, const char *suffix) | |||||
return xstrndup(path, chomp_trailing_dir_sep(path, path_len)); | ||||||
} | ||||||
|
||||||
int is_mount_point_via_stat(struct strbuf *path) | ||||||
{ | ||||||
size_t len = path->len; | ||||||
unsigned int current_dev; | ||||||
struct stat st; | ||||||
|
||||||
if (!strcmp("/", path->buf)) | ||||||
return 1; | ||||||
|
||||||
strbuf_addstr(path, "/."); | ||||||
if (lstat(path->buf, &st)) { | ||||||
/* | ||||||
* If we cannot access the current directory, we cannot say | ||||||
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. If we cannot access the current directory, and return false here, will we then proceed to clean files in this directory even though it might actually be a mount point? If so, maybe we should act on the side of caution and check 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. This is for Linux mount points, right? Let's ignore this is a corner case. |
||||||
* that it is a bind mount. | ||||||
*/ | ||||||
strbuf_setlen(path, len); | ||||||
return 0; | ||||||
} | ||||||
current_dev = st.st_dev; | ||||||
|
||||||
/* Now look at the current directoru */ | ||||||
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.
Suggested change
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. I think it really is the current directory, not the parent directory, that we're looking at... but of course, it is a directory, not a directoru... 😄 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. The code obscures this a bit, but I am positive that this is the parent directory. We append '/.' to path above, then we append '.' here, which makes '/..'. If the '/.' above is not needed, I suggest removing it. Maybe a 'dirname' method (which strips the tail component from a path which must not end on '/..') would make this more readable. |
||||||
strbuf_addch(path, '.'); | ||||||
if (lstat(path->buf, &st)) { | ||||||
/* | ||||||
* If we cannot access the parent directory, we cannot say | ||||||
* that it is a bind mount. | ||||||
*/ | ||||||
strbuf_setlen(path, len); | ||||||
return 0; | ||||||
} | ||||||
strbuf_setlen(path, len); | ||||||
|
||||||
/* | ||||||
* If the device ID differs between current and parent directory, | ||||||
* then it is a bind mount. | ||||||
*/ | ||||||
return current_dev != st.st_dev; | ||||||
} | ||||||
|
||||||
int daemon_avoid_alias(const char *p) | ||||||
{ | ||||||
int sl, ndot; | ||||||
|
Uh oh!
There was an error while loading. Please reload this page.