Don't add paths outside the repository even with --force

dblsaiko
Mar 27, 2024, 2:58 PM
RJ4UL56TQT6LYME46FAI65RNX3T5AG3KGBJVLSK363JDYDZ5F4JAC

Dependencies

  • [2] 3SJ3DJNF Adding a --force option to `pijul add`, to include otherwise ignored files
  • [3] TPQHDDNC pijul add --force know adds ignored files
  • [4] 3J6IK4W2 Explicitly adding .pijul is now forbidden
  • [5] 4VWXL6KQ Correct handling of ignore files
  • [6] AFWNXPBK Prevent the addition of .pijul to the repository
  • [7] ZHABNS3S Canonicalize all paths
  • [8] 4OCC6D42 Recursive add
  • [*] SXEYMYF7 Fixing the bad changes in history (unfortunately, by rebooting).

Change contents

  • replacement in pijul/src/commands/file_operations.rs at line 141
    [3.226][3.59:299]()
    if !self.force
    && !libpijul::working_copy::filesystem::filter_ignore(
    repo_path.as_ref(),
    path.as_ref(),
    meta.is_dir(),
    )
    {
    [3.226]
    [3.222]
    if !libpijul::working_copy::filesystem::filter_path(
    repo_path.as_ref(),
    path.as_ref(),
    meta.is_dir(),
    !self.force,
    ) {
  • edit in libpijul/src/working_copy/filesystem.rs at line 11
    [10.209107]
    [3.1013]
    }
    /// Returns whether `path` is eligible to be tracked in the repository under `root`.
    pub fn filter_path(
    root: &CanonicalPath,
    path: &CanonicalPath,
    is_dir: bool,
    use_ignore: bool,
    ) -> bool {
    if !path.starts_with(root) {
    return false;
    }
    if use_ignore && !filter_ignore(root, path, is_dir) {
    return false;
    }
    true
  • replacement in libpijul/src/working_copy/filesystem.rs at line 272
    [2.523][2.523:846]()
    if !force {
    if !filter_ignore(
    &repo_path.as_canonical_path(),
    &full.as_canonical_path(),
    meta.is_dir(),
    ) {
    return Ok(Untracked {
    join: None,
    receiver,
    });
    }
    [2.523]
    [3.175]
    if !filter_path(
    &repo_path.as_canonical_path(),
    &full.as_canonical_path(),
    meta.is_dir(),
    !force,
    ) {
    return Ok(Untracked {
    join: None,
    receiver,
    });