From 2a9533cb4daf4f36f40dcd2f3416d423749aa98f Mon Sep 17 00:00:00 2001 From: Johan Mabille Date: Thu, 4 Sep 2025 16:04:16 +0200 Subject: [PATCH 1/2] Fixed most of commands creating a git repo instead of throwing an error --- src/subcommand/add_subcommand.cpp | 3 +-- src/subcommand/commit_subcommand.cpp | 3 +-- src/subcommand/log_subcommand.cpp | 3 +-- src/subcommand/reset_subcommand.cpp | 3 +-- src/subcommand/status_subcommand.cpp | 3 +-- .../48/e0bfd8a7f3ce1af86b7f7b855b25af8386ea54 | Bin 0 -> 173 bytes .../56/9457b1226e4b332b86e5e8f7af1bba77e201c3 | Bin 0 -> 172 bytes .../93/064f8896c3de87fcfd1b4d990298e868eb56b9 | Bin 0 -> 151 bytes .../e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 | Bin 0 -> 15 bytes test/test_add.py | 8 ++++++++ test/test_branch.py | 5 +++++ test/test_log.py | 5 +++++ test/test_reset.py | 6 ++++++ test/test_status.py | 4 ++++ 14 files changed, 33 insertions(+), 10 deletions(-) create mode 100644 test/data/status_data/embedded_git/objects/48/e0bfd8a7f3ce1af86b7f7b855b25af8386ea54 create mode 100644 test/data/status_data/embedded_git/objects/56/9457b1226e4b332b86e5e8f7af1bba77e201c3 create mode 100644 test/data/status_data/embedded_git/objects/93/064f8896c3de87fcfd1b4d990298e868eb56b9 create mode 100644 test/data/status_data/embedded_git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/subcommand/add_subcommand.cpp b/src/subcommand/add_subcommand.cpp index 9988d25..51f57c1 100644 --- a/src/subcommand/add_subcommand.cpp +++ b/src/subcommand/add_subcommand.cpp @@ -23,8 +23,7 @@ add_subcommand::add_subcommand(const libgit2_object&, CLI::App& app) void add_subcommand::run() { auto directory = get_current_git_path(); - auto bare = false; - auto repo = repository_wrapper::init(directory, bare); + auto repo = repository_wrapper::open(directory); index_wrapper index = repo.make_index(); diff --git a/src/subcommand/commit_subcommand.cpp b/src/subcommand/commit_subcommand.cpp index e70f424..d281ec6 100644 --- a/src/subcommand/commit_subcommand.cpp +++ b/src/subcommand/commit_subcommand.cpp @@ -19,8 +19,7 @@ commit_subcommand::commit_subcommand(const libgit2_object&, CLI::App& app) void commit_subcommand::run() { auto directory = get_current_git_path(); - auto bare = false; - auto repo = repository_wrapper::init(directory, bare); + auto repo = repository_wrapper::open(directory); auto author_committer_signatures = signature_wrapper::get_default_signature_from_env(repo); if (m_commit_message.empty()) diff --git a/src/subcommand/log_subcommand.cpp b/src/subcommand/log_subcommand.cpp index c25e270..490569b 100644 --- a/src/subcommand/log_subcommand.cpp +++ b/src/subcommand/log_subcommand.cpp @@ -80,8 +80,7 @@ void print_commit(const commit_wrapper& commit, std::string m_format_flag) void log_subcommand::run() { auto directory = get_current_git_path(); - auto bare = false; - auto repo = repository_wrapper::init(directory, bare); + auto repo = repository_wrapper::open(directory); // auto branch_name = repo.head().short_name(); git_revwalk* walker; diff --git a/src/subcommand/reset_subcommand.cpp b/src/subcommand/reset_subcommand.cpp index b862e78..61fa0ae 100644 --- a/src/subcommand/reset_subcommand.cpp +++ b/src/subcommand/reset_subcommand.cpp @@ -27,8 +27,7 @@ reset_subcommand::reset_subcommand(const libgit2_object&, CLI::App& app) void reset_subcommand::run() { auto directory = get_current_git_path(); - auto bare = false; - auto repo = repository_wrapper::init(directory, bare); + auto repo = repository_wrapper::open(directory); auto target = repo.revparse_single(m_commit); if (!target) diff --git a/src/subcommand/status_subcommand.cpp b/src/subcommand/status_subcommand.cpp index 83ebd6d..88a8783 100644 --- a/src/subcommand/status_subcommand.cpp +++ b/src/subcommand/status_subcommand.cpp @@ -183,8 +183,7 @@ void print_not_tracked(const std::vector& entries_to_print, const s void status_subcommand::run() { auto directory = get_current_git_path(); - auto bare = false; - auto repo = repository_wrapper::init(directory, bare); + auto repo = repository_wrapper::open(directory); auto sl = status_list_wrapper::status_list(repo); auto branch_name = repo.head().short_name(); diff --git a/test/data/status_data/embedded_git/objects/48/e0bfd8a7f3ce1af86b7f7b855b25af8386ea54 b/test/data/status_data/embedded_git/objects/48/e0bfd8a7f3ce1af86b7f7b855b25af8386ea54 new file mode 100644 index 0000000000000000000000000000000000000000..89b5d6e53b2f1a5d72c1598e94990caa6d4dd259 GIT binary patch literal 173 zcmV;e08;;W0i}*P4#F@H0IB_o?Gealyp|B6qCld92l!Z%pg2as{GXsafpVr8O{}F1 z4WyBqHWPtUywe%cbx|ckn`2HQ=;R!i4hcJ?V7lPg%g;15Ai}6)MysRFf>iL zWKjq%&?h35nE$lC&Ty%{pWy1lFpdO==MVQ~#nYqsVcf@Bjv%a2h-kEiEtj0L#V(_b b{z%XiYZ|5p+;8U{GS=wbVC{YZRRvKdx#L#t literal 0 HcmV?d00001 diff --git a/test/data/status_data/embedded_git/objects/56/9457b1226e4b332b86e5e8f7af1bba77e201c3 b/test/data/status_data/embedded_git/objects/56/9457b1226e4b332b86e5e8f7af1bba77e201c3 new file mode 100644 index 0000000000000000000000000000000000000000..1637ef7425c3a15c5aea44300b4a08d28f73dd65 GIT binary patch literal 172 zcmV;d08{^X0i}*R3IZ_{0IhS1*Nc*WUO>dkLa@^VS{a%b8-B)M_0& zNF!H$Ap)G9_JfeFUJis*6G>d*L?$5Em1DOu}}5@ literal 0 HcmV?d00001 diff --git a/test/data/status_data/embedded_git/objects/93/064f8896c3de87fcfd1b4d990298e868eb56b9 b/test/data/status_data/embedded_git/objects/93/064f8896c3de87fcfd1b4d990298e868eb56b9 new file mode 100644 index 0000000000000000000000000000000000000000..e6c229d81d88ea79d1ac627ec5c58fce267d1d8d GIT binary patch literal 151 zcmV;I0BHYs0V^p=O;s>7H)1d}FfcPQQOM2D&yG*a%t_TNsVHH1Huur&O&6~@dv|ND zE04Ny=t)oTM5x02l8n@%_>$D(5`^+OD_0a|fB(8#{)^{6p6Ls`s@6FrL6sLJ=B4E4 zB9z{7=Cjeu6P&!coP|+sXTVG~xuQU*QdBedzIV=Hf7dxzGIeU>r78a5R>u?`002;H FN2|agOHKd) literal 0 HcmV?d00001 diff --git a/test/data/status_data/embedded_git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 b/test/data/status_data/embedded_git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 new file mode 100644 index 0000000000000000000000000000000000000000..711223894375fe1186ac5bfffdc48fb1fa1e65cc GIT binary patch literal 15 Wcmb Date: Fri, 5 Sep 2025 11:04:25 +0200 Subject: [PATCH 2/2] Removed remaining test/data files --- .../48/e0bfd8a7f3ce1af86b7f7b855b25af8386ea54 | Bin 173 -> 0 bytes .../56/9457b1226e4b332b86e5e8f7af1bba77e201c3 | Bin 172 -> 0 bytes .../93/064f8896c3de87fcfd1b4d990298e868eb56b9 | Bin 151 -> 0 bytes .../e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 | Bin 15 -> 0 bytes 4 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 test/data/status_data/embedded_git/objects/48/e0bfd8a7f3ce1af86b7f7b855b25af8386ea54 delete mode 100644 test/data/status_data/embedded_git/objects/56/9457b1226e4b332b86e5e8f7af1bba77e201c3 delete mode 100644 test/data/status_data/embedded_git/objects/93/064f8896c3de87fcfd1b4d990298e868eb56b9 delete mode 100644 test/data/status_data/embedded_git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/test/data/status_data/embedded_git/objects/48/e0bfd8a7f3ce1af86b7f7b855b25af8386ea54 b/test/data/status_data/embedded_git/objects/48/e0bfd8a7f3ce1af86b7f7b855b25af8386ea54 deleted file mode 100644 index 89b5d6e53b2f1a5d72c1598e94990caa6d4dd259..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 173 zcmV;e08;;W0i}*P4#F@H0IB_o?Gealyp|B6qCld92l!Z%pg2as{GXsafpVr8O{}F1 z4WyBqHWPtUywe%cbx|ckn`2HQ=;R!i4hcJ?V7lPg%g;15Ai}6)MysRFf>iL zWKjq%&?h35nE$lC&Ty%{pWy1lFpdO==MVQ~#nYqsVcf@Bjv%a2h-kEiEtj0L#V(_b b{z%XiYZ|5p+;8U{GS=wbVC{YZRRvKdx#L#t diff --git a/test/data/status_data/embedded_git/objects/56/9457b1226e4b332b86e5e8f7af1bba77e201c3 b/test/data/status_data/embedded_git/objects/56/9457b1226e4b332b86e5e8f7af1bba77e201c3 deleted file mode 100644 index 1637ef7425c3a15c5aea44300b4a08d28f73dd65..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 172 zcmV;d08{^X0i}*R3IZ_{0IhS1*Nc*WUO>dkLa@^VS{a%b8-B)M_0& zNF!H$Ap)G9_JfeFUJis*6G>d*L?$5Em1DOu}}5@ diff --git a/test/data/status_data/embedded_git/objects/93/064f8896c3de87fcfd1b4d990298e868eb56b9 b/test/data/status_data/embedded_git/objects/93/064f8896c3de87fcfd1b4d990298e868eb56b9 deleted file mode 100644 index e6c229d81d88ea79d1ac627ec5c58fce267d1d8d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 151 zcmV;I0BHYs0V^p=O;s>7H)1d}FfcPQQOM2D&yG*a%t_TNsVHH1Huur&O&6~@dv|ND zE04Ny=t)oTM5x02l8n@%_>$D(5`^+OD_0a|fB(8#{)^{6p6Ls`s@6FrL6sLJ=B4E4 zB9z{7=Cjeu6P&!coP|+sXTVG~xuQU*QdBedzIV=Hf7dxzGIeU>r78a5R>u?`002;H FN2|agOHKd) diff --git a/test/data/status_data/embedded_git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 b/test/data/status_data/embedded_git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 deleted file mode 100644 index 711223894375fe1186ac5bfffdc48fb1fa1e65cc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 15 Wcmb