-
Notifications
You must be signed in to change notification settings - Fork 305
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
checkout: Provide useful error with checkout -H and incompat mode #779
Closed
Closed
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
a806e30
checkout: Provide useful error with checkout -H and incompat mode
cgwalters 5d48399
fixup! checkout: Provide useful error with checkout -H and incompat mode
cgwalters 054fd76
fixup! checkout: Provide useful error with checkout -H and incompat mode
cgwalters File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -431,7 +431,6 @@ checkout_one_file_at (OstreeRepo *repo, | |
gboolean is_whiteout; | ||
|
||
is_symlink = g_file_info_get_file_type (source_info) == G_FILE_TYPE_SYMBOLIC_LINK; | ||
|
||
checksum = ostree_repo_file_get_checksum ((OstreeRepoFile*)source); | ||
|
||
is_whiteout = !is_symlink && options->process_whiteouts && | ||
|
@@ -468,20 +467,38 @@ checkout_one_file_at (OstreeRepo *repo, | |
|
||
while (current_repo) | ||
{ | ||
gboolean is_bare = ((current_repo->mode == OSTREE_REPO_MODE_BARE | ||
&& options->mode == OSTREE_REPO_CHECKOUT_MODE_NONE) || | ||
(current_repo->mode == OSTREE_REPO_MODE_BARE_USER | ||
&& options->mode == OSTREE_REPO_CHECKOUT_MODE_USER | ||
/* NOTE: bare-user symlinks are not stored as symlinks */ | ||
&& !is_symlink) || | ||
(current_repo->mode == OSTREE_REPO_MODE_BARE_USER_ONLY | ||
&& options->mode == OSTREE_REPO_CHECKOUT_MODE_USER)); | ||
/* TODO - Hoist this up to the toplevel at least for checking out from | ||
* !parent; don't need to compute it for each file. | ||
*/ | ||
gboolean repo_is_usermode = | ||
current_repo->mode == OSTREE_REPO_MODE_BARE_USER || | ||
current_repo->mode == OSTREE_REPO_MODE_BARE_USER_ONLY; | ||
/* We're hardlinkable if the checkout mode matches the repo mode */ | ||
gboolean is_hardlinkable = | ||
(current_repo->mode == OSTREE_REPO_MODE_BARE | ||
&& options->mode == OSTREE_REPO_CHECKOUT_MODE_NONE) || | ||
(repo_is_usermode && options->mode == OSTREE_REPO_CHECKOUT_MODE_USER); | ||
/* NOTE: bare-user symlinks are not stored as symlinks */ | ||
gboolean is_bare_symlink = (repo_is_usermode && is_symlink); | ||
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. Should this be renamed |
||
gboolean is_bare = is_hardlinkable && !is_bare_symlink; | ||
gboolean current_can_cache = (options->enable_uncompressed_cache | ||
&& current_repo->enable_uncompressed_cache); | ||
gboolean is_archive_z2_with_cache = (current_repo->mode == OSTREE_REPO_MODE_ARCHIVE_Z2 | ||
&& options->mode == OSTREE_REPO_CHECKOUT_MODE_USER | ||
&& current_can_cache); | ||
|
||
/* Verify if no_copy_fallback is set that we can hardlink, with a | ||
* special exception for bare-user symlinks. | ||
*/ | ||
if (options->no_copy_fallback && !is_hardlinkable && !is_bare_symlink) | ||
{ | ||
glnx_throw (error, | ||
repo_is_usermode ? | ||
"User repository mode requires user checkout mode to hardlink" : | ||
"Bare repository mode cannot hardlink in user checkout mode"); | ||
goto out; | ||
} | ||
|
||
/* But only under these conditions */ | ||
if (is_bare || is_archive_z2_with_cache) | ||
{ | ||
|
@@ -596,7 +613,13 @@ checkout_one_file_at (OstreeRepo *repo, | |
/* Fall back to copy if we couldn't hardlink */ | ||
if (need_copy) | ||
{ | ||
g_assert (!options->no_copy_fallback); | ||
/* Bare user mode can't hardlink symlinks, so we need to do a copy for | ||
* those. (Although in the future we could hardlink inside checkouts) This | ||
* assertion is intended to ensure that for regular files at least, we | ||
* succeeded at hardlinking above. | ||
*/ | ||
if (!is_symlink) | ||
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. Would the intent here be better expressed as: if (options->no_copy_fallback)
g_assert (is_bare_user_symlink); ? |
||
g_assert (!options->no_copy_fallback); | ||
if (!ostree_repo_load_file (repo, checksum, &input, NULL, &xattrs, | ||
cancellable, error)) | ||
goto out; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can we add a e.g.
(see comment in write_object())
here? It's not intuitive offhand why we can't hardlink symlinks in bare-user mode. It took me some digging through git logs to find 47c612e and the associated comment inwrite_object()
.