Skip to content

Add --show-function support#993

Open
joshkehn wants to merge 1 commit into
Wilfred:masterfrom
joshkehn:add-show-function
Open

Add --show-function support#993
joshkehn wants to merge 1 commit into
Wilfred:masterfrom
joshkehn:add-show-function

Conversation

@joshkehn

Copy link
Copy Markdown

Add support for -p/--show-function. This mirror's -p in diff. See #666

I tested this by running the debug build with git diff and checked the output (subset below):

❯ DFT_SHOW_FUNCTION=1 git -c diff.external=target/debug/difft diff 49e5cff6b035431421709dc1f74363d8d14638b9 0e7abbcc3dab432fce1bb0f96ef2a86f03d3979e -- src/main.rs
src/main.rs --- 3/9 --- Rust
577 579 fn check_only_text(
595 597         rhs_src: FileContent::Text(rhs_src.into()),
596 598         lhs_positions: vec![],
597 599         rhs_positions: vec![],
... 600         lhs_fn_spans: vec![],
... 601         rhs_fn_spans: vec![],
598 602         hunks: vec![],
599 603         has_byte_changes,
600 604         has_syntactic_changes: lhs_src != rhs_src,

src/main.rs --- 4/9 --- Rust
604 608 fn diff_file_content(
636 640             rhs_src: FileContent::Text("".into()),
637 641             lhs_positions: vec![],
638 642             rhs_positions: vec![],
... 643             lhs_fn_spans: vec![],
... 644             rhs_fn_spans: vec![],
639 645             hunks: vec![],
640 646             has_byte_changes: None,
641 647             has_syntactic_changes: false,
642 648         };
643 649     }
... 650
... 651     // Populated below (only when --show-function is set and we have a
... 652     // tree-sitter parse) and carried into the DiffResult.
... 653     let mut lhs_fn_spans: FunctionSpans = Vec::new();
... 654     let mut rhs_fn_spans: FunctionSpans = Vec::new();
644 655
645 656     let (file_format, lhs_positions, rhs_positions) = match lang_config {
646 657         None => {

src/main.rs --- 5/9 --- Rust
604 608 fn diff_file_content(
684 695                                     rhs_src: FileContent::Text(rhs_src.to_owned()),
685 696                                     lhs_positions: vec![],
686 697                                     rhs_positions: vec![],
... 698                                     lhs_fn_spans: vec![],
... 699                                     rhs_fn_spans: vec![],
687 700                                     hunks: vec![],
688 701                                     has_byte_changes,
689 702                                     has_syntactic_changes,

src/main.rs --- 6/9 --- Rust
604 608 fn diff_file_content(
744 757                                     rhs_positions.extend(rhs_comments);
745 758                                 }
... 759
... 760                                 if display_options.show_function.is_some() {
... 761                                     lhs_fn_spans = tsp::function_spans(&lhs_tree);
... 762                                     rhs_fn_spans = tsp::function_spans(&rhs_tree);
... 763                                 }
746 764
747 765                                 (
748 766                                     FileFormat::SupportedLanguage(language),

@joshkehn joshkehn force-pushed the add-show-function branch 2 times, most recently from 759ee45 to e4eb359 Compare June 15, 2026 18:00
Add support for `-p/--show-function`. This mirror's `-p` in `diff`.
@joshkehn joshkehn force-pushed the add-show-function branch from e4eb359 to 68dd860 Compare June 15, 2026 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant