Skip to content

Feature: Add git diff#18

Open
GabrielSSAlmeida wants to merge 6 commits into
mainfrom
feature-add-git-diff
Open

Feature: Add git diff#18
GabrielSSAlmeida wants to merge 6 commits into
mainfrom
feature-add-git-diff

Conversation

@GabrielSSAlmeida
Copy link
Copy Markdown
Contributor

@GabrielSSAlmeida GabrielSSAlmeida commented May 19, 2026

Refers to #1

This PR is related to a new feature in Arkanjo. Now, it is possible to see the diff, like the git diff command, between two functions marked as similar from the Arkanjo preprocessor. For this resource, it was used the libgit2 project as git tool.

How to use:

After running the arkanjo preprocessor command, the git-diff command is ready to be used. The syntax is arkanjo git-diff <function_1_name> <function_2_name>.

image

For those cases when there are multiple functions with the same name, it is also possible to pass the full path provided by the tool to see the git diff.

image

@GabrielSSAlmeida GabrielSSAlmeida linked an issue May 19, 2026 that may be closed by this pull request
@GabrielSSAlmeida GabrielSSAlmeida removed the request for review from guilhermeivo May 19, 2026 00:51
@GabrielSSAlmeida GabrielSSAlmeida marked this pull request as draft May 19, 2026 00:51
@GabrielSSAlmeida GabrielSSAlmeida marked this pull request as ready for review May 19, 2026 01:34
@guilhermeivo
Copy link
Copy Markdown
Contributor

The diff generation using libgit2 turned out really nice :)

@guilhermeivo
Copy link
Copy Markdown
Contributor

It's also possible to use the system-installed libgit2 via:

find_package(libgit2 CONFIG REQUIRED)

This comes from libgit2-dev, which pulls the required dependencies (like libhttp-parser-dev and libmbedtls-dev).

Not sure which approach is better -- system package vs FetchContent.

@guilhermeivo
Copy link
Copy Markdown
Contributor

guilhermeivo commented May 19, 2026

This is just a suggestion

For the diff output, it could be a nice optional improvement to include the full unified diff header (including hunk information), so tools like delta or batcat can parse it more reliably.

@@ -10,7 +10,7 @@
(echo "@@ -10,7 +10,7 @@"; arkanjo git-diff temperature_read_raw humidity_read_raw;) | delta
image

@GabrielSSAlmeida
Copy link
Copy Markdown
Contributor Author

It's also possible to use the system-installed libgit2 via:

find_package(libgit2 CONFIG REQUIRED)

This comes from libgit2-dev, which pulls the required dependencies (like libhttp-parser-dev and libmbedtls-dev).

Not sure which approach is better -- system package vs FetchContent.

Yes, using a system-installed library seems like a good idea as well. I think we can leave this decision to the end user. Therefore, if a user already has libgit2-dev installed, we can use the find_package approach; otherwise, we can use FetchContent. What do you think? Let me know your opinion about it.

@GabrielSSAlmeida
Copy link
Copy Markdown
Contributor Author

This is just a suggestion

For the diff output, it could be a nice optional improvement to include the full unified diff header (including hunk information), so tools like delta or batcat can parse it more reliably.

@@ -10,7 +10,7 @@
(echo "@@ -10,7 +10,7 @@"; arkanjo git-diff temperature_read_raw humidity_read_raw;) | delta

Yeah, it sounds good to me. I'll update the PR with this new feature.

@guilhermeivo
Copy link
Copy Markdown
Contributor

Yes, using a system-installed library seems like a good idea as well. I think we can leave this decision to the end user. Therefore, if a user already has libgit2-dev installed, we can use the find_package approach; otherwise, we can use FetchContent. What do you think? Let me know your opinion about it.

I liked this solution of having a callback for FetchContent, but if it is already installed, use libgit2-dev.

Introduce the git-diff command to compare duplicate functions
through a unified git-style patch output powered by libgit2.

The command resolves function name patterns against the
similarity table, validates that both functions are marked as
duplicates, and renders a colored diff directly in the CLI.

Add support for:
- function pattern normalization using :: separators
- ambiguity detection for multiple matches
- git-style hunk and file headers
- colored additions and deletions
- empty diff reporting

Also register the new command in the orchestrator command map
and expose the corresponding CLI metadata and help text.

Signed-off-by: Gabriel Almeida <gabrielsousa230@gmail.com>
Signed-off-by: Gabriel Almeida <gabrielsousa230@gmail.com>
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.

Enable git diff view between two functions

2 participants