Home / Function/ resolve_git_commondir() — tailwindcss Function Reference

resolve_git_commondir() — tailwindcss Function Reference

Architecture documentation for the resolve_git_commondir() function in dir.rs from the tailwindcss codebase.

Function rust RustCore FileScanner calls 1 called by 1

Entity Profile

Dependency Diagram

graph TD
  09a5f4e6_d619_7ccf_c7d6_95d2d60e1257["resolve_git_commondir()"]
  00fde01e_208e_84d9_5445_fec3bcf2125f["add_child_path()"]
  00fde01e_208e_84d9_5445_fec3bcf2125f -->|calls| 09a5f4e6_d619_7ccf_c7d6_95d2d60e1257
  adeca82e_f912_b4ab_3e4d_e1e8716db084["next()"]
  09a5f4e6_d619_7ccf_c7d6_95d2d60e1257 -->|calls| adeca82e_f912_b4ab_3e4d_e1e8716db084
  style 09a5f4e6_d619_7ccf_c7d6_95d2d60e1257 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

crates/ignore/src/dir.rs lines 857–898

fn resolve_git_commondir(dir: &Path, git_type: Option<FileType>) -> Result<PathBuf, Option<Error>> {
    let git_dir_path = || dir.join(".git");
    let git_dir = git_dir_path();
    if !git_type.map_or(false, |ft| ft.is_file()) {
        return Ok(git_dir);
    }
    let file = match File::open(git_dir) {
        Ok(file) => io::BufReader::new(file),
        Err(err) => {
            return Err(Some(Error::Io(err).with_path(git_dir_path())));
        }
    };
    let dot_git_line = match file.lines().next() {
        Some(Ok(line)) => line,
        Some(Err(err)) => {
            return Err(Some(Error::Io(err).with_path(git_dir_path())));
        }
        None => return Err(None),
    };
    if !dot_git_line.starts_with("gitdir: ") {
        return Err(None);
    }
    let real_git_dir = PathBuf::from(&dot_git_line["gitdir: ".len()..]);
    let git_commondir_file = || real_git_dir.join("commondir");
    let file = match File::open(git_commondir_file()) {
        Ok(file) => io::BufReader::new(file),
        Err(_) => return Err(None),
    };
    let commondir_line = match file.lines().next() {
        Some(Ok(line)) => line,
        Some(Err(err)) => {
            return Err(Some(Error::Io(err).with_path(git_commondir_file())));
        }
        None => return Err(None),
    };
    let commondir_abs = if commondir_line.starts_with(".") {
        real_git_dir.join(commondir_line) // relative commondir
    } else {
        PathBuf::from(commondir_line)
    };
    Ok(commondir_abs)
}

Domain

Subdomains

Calls

Called By

Frequently Asked Questions

What does resolve_git_commondir() do?
resolve_git_commondir() is a function in the tailwindcss codebase.
What does resolve_git_commondir() call?
resolve_git_commondir() calls 1 function(s): next.
What calls resolve_git_commondir()?
resolve_git_commondir() is called by 1 function(s): add_child_path.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free