anchor.diff:      " in the package has to be released.
   
       lv_package = ms_item-obj_name.
  +
  +    remove_obsolete_tadir( lv_package ).
   
       IF is_empty( lv_package ) = abap_true.
   
  
positive.code:                             iv_language TYPE spras.
    PROTECTED SECTION.
    PRIVATE SECTION.
      METHODS:
        get_package RETURNING VALUE(ri_package) TYPE REF TO if_package
                    RAISING   zcx_abapgit_exception,
        update_pinf_usages IMPORTING ii_package    TYPE REF TO if_package
                                     it_usage_data TYPE scomppdata
                           RAISING   zcx_abapgit_exception,
        set_lock IMPORTING ii_package TYPE REF TO if_package
                           iv_lock    TYPE abap_bool
                 RAISING   zcx_abapgit_exception,
        is_empty
          IMPORTING iv_package_name    TYPE devclass
          RETURNING VALUE(rv_is_empty) TYPE abap_bool
          RAISING   zcx_abapgit_exception,
        load_package
          IMPORTING iv_package_name   TYPE devclass
          RETURNING VALUE(ri_package) TYPE REF TO if_package
          RAISING   zcx_abapgit_exception.
  
      DATA:
        mv_local_devclass TYPE devclass.
  ENDCLASS.
  
  
  
negative.code:     ELSEIF sy-subrc <> 0.
        zcx_abapgit_exception=>raise_t100( ).
      ENDIF.
  
    ENDMETHOD.
  
  
    METHOD remove_obsolete_tadir.
  
      DATA:
        lv_pack  TYPE devclass,
        lt_pack  TYPE STANDARD TABLE OF devclass,
        ls_tadir TYPE zif_abapgit_definitions=>ty_tadir,
        lt_tadir TYPE zif_abapgit_definitions=>ty_tadir_tt,
        ls_item  TYPE zif_abapgit_definitions=>ty_item.
  
      " TADIR entries must remain for transportable packages
      IF is_local( iv_package_name ) = abap_false.
        RETURN.
      ENDIF.
  
      " Clean-up sub packages first
      SELECT devclass FROM tdevc INTO TABLE lt_pack WHERE parentcl = iv_package_name.
  
      LOOP AT lt_pack INTO lv_pack.
        remove_obsolete_tadir( lv_pack ).
      ENDLOOP.
  
      " Remove TADIR entries for objects that do not exist anymore
      SELECT * FROM tadir INTO CORRESPONDING FIELDS OF TABLE lt_tadir WHERE devclass = iv_package_name.
  
      LOOP AT lt_tadir INTO ls_tadir.
        ls_item-obj_type = ls_tadir-object.
        ls_item-obj_name = ls_tadir-obj_name.
  
        IF zcl_abapgit_objects=>exists( ls_item ) = abap_false.
          CALL FUNCTION 'TR_TADIR_INTERFACE'
            EXPORTING
              wi_delete_tadir_entry = abap_true
              wi_tadir_pgmid        = 'R3TR'
              wi_tadir_object       = ls_tadir-object
              wi_tadir_obj_name     = ls_tadir-obj_name
              wi_test_modus         = abap_false
            EXCEPTIONS
              OTHERS                = 1 ##FM_SUBRC_OK.
        ENDIF.
      ENDLOOP.
  
    ENDMETHOD.
  
  