WebSafe 3.7github.com
|
|
🏠
Skip to content

Hs/xdiff algo enum#2196

Draft
HodaSalim wants to merge 3 commits intogit:masterfrom
HodaSalim:hs/xdiff-algo-enum
Draft

Hs/xdiff algo enum#2196
HodaSalim wants to merge 3 commits intogit:masterfrom
HodaSalim:hs/xdiff-algo-enum

Conversation

@HodaSalim
Copy link
Contributor

Thanks for taking the time to contribute to Git! Please be advised that the
Git community does not use github.com for their contributions. Instead, we use
a mailing list (git@vger.kernel.org) for code submissions, code reviews, and
bug reports. Nevertheless, you can use GitGitGadget (https://gitgitgadget.github.io/)
to conveniently send your Pull Requests commits to our mailing list.

For a single-commit pull request, please leave the pull request description
empty
: your commit message itself should describe your changes.

Please read the "guidelines for contributing" linked above!

The diff algorithm is currently selected via bit flags embedded in
thexpparam_t flags field (XDF_PATIENCE_DIFF, XDF_HISTOGRAM_DIFF,
etc.).This requires bit manipulation and masking to change algorithms,
andmakes Myers the implicit default (no bits set) rather than explicit.

Introduce a dedicated xdl_algo_t enum type as the first step towards
cleaner algorithm selection. This follows a suggestion from Junio [1] to
eventually replace the bit flag approach entirely.

[1] https://lore.kernel.org/git/xmqqh5v5hmat.fsf@gitster.g/

Suggested-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Hoda Salim <hoda.s.salim@gmail.com>
Now that xdl_algo_t exists, update the diff algorithm selection code to
use the new enum field instead of bit manipulation.

Replace the pattern:
`xpp->flags = (xpp->flags & ~XDF_DIFF_ALGORITHM_MASK) | algorithm;`

With direct assignment:
`xpp->algo = algorithm;`

This affects set_diff_algorithm(),
blame_diff_algorithm_callback(),blame_diff_algorithm_minimal(), and
fall_back_to_classic_diff().

Signed-off-by: Hoda Salim <hoda.s.salim@gmail.com>
Now that all algorithm selection uses the xdl_algo_t enum, remove
thelegacy bit flag infrastructure:
 - XDF_NEED_MINIMAL (as algorithm selector; keep if used elsewhere)
 - XDF_PATIENCE_DIFF
 - XDF_HISTOGRAM_DIFF
 - XDF_DIFF_ALGORITHM_MASK
 - XDF_DIFF_ALG() macro

This completes the refactoring suggested in [1], making algorithm
selection explicit via enum assignment rather than implicit via bit
manipulation.

[1]https://lore.kernel.org/git/xmqqh5v5hmat.fsf@gitster.g/

Signed-off-by: Hoda Salim <hoda.s.salim@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant

Comments