File tree Expand file tree Collapse file tree 1 file changed +18
-22
lines changed
Expand file tree Collapse file tree 1 file changed +18
-22
lines changed Original file line number Diff line number Diff line change @@ -37,33 +37,29 @@ void revparse_subcommand::run()
3737 auto repo = repository_wrapper::open (directory);
3838
3939 size_t i = 0 ;
40- if (! m_queries_in_order. empty () )
40+ for ( const auto & q : m_queries_in_order)
4141 {
42- for ( const auto & q : m_queries_in_order )
42+ if (q == " is_bare " )
4343 {
44- if (q == " is_bare" )
45- {
46- std::cout << std::boolalpha << repo.is_bare () << std::endl;
47- }
48- else if (q == " is_shallow" )
44+ std::cout << std::boolalpha << repo.is_bare () << std::endl;
45+ }
46+ else if (q == " is_shallow" )
47+ {
48+ std::cout << std::boolalpha << repo.is_shallow () << std::endl;
49+ }
50+ else if (q == " is_rev" )
51+ {
52+ const auto & rev = m_revisions[i];
53+ auto obj = repo.revparse_single (rev.c_str ());
54+
55+ if (!obj.has_value ())
4956 {
50- std::cout << std::boolalpha << repo. is_shallow () << std::endl ;
57+ throw git_exception ( " bad revision ' " + rev + " ' " , git2cpp_error_code::BAD_ARGUMENT) ;
5158 }
52- else if (q == " is_rev" )
53- {
54- const auto & rev = m_revisions[i];
55- auto obj = repo.revparse_single (rev.c_str ());
5659
57- if (!obj.has_value ())
58- {
59- throw git_exception (" bad revision '" + rev + " '" , git2cpp_error_code::BAD_ARGUMENT);
60- }
61-
62- auto oid = obj.value ().oid ();
63- std::cout << git_oid_tostr_s (&oid) << std::endl;
64- i += 1 ;
65- }
60+ auto oid = obj.value ().oid ();
61+ std::cout << git_oid_tostr_s (&oid) << std::endl;
62+ i += 1 ;
6663 }
6764 }
68- return ;
6965}
You can’t perform that action at this time.
0 commit comments