Skip to content
  • Duy Nguyen's avatar
    attr: remove an implicit dependency on the_index · 7a400a2c
    Duy Nguyen authored and Junio C Hamano's avatar Junio C Hamano committed
    Make the attr API take an index_state instead of assuming the_index in
    attr code. All call sites are converted blindly to keep the patch
    simple and retain current behavior. Individual call sites may receive
    further updates to use the right index instead of the_index.
    
    There is one ugly temporary workaround added in attr.c that needs some
    more explanation.
    
    Commit c24f3aba
    
     (apply: file commited with CRLF should roundtrip
    diff and apply - 2017-08-19) forces one convert_to_git() call to NOT
    read the index at all. But what do you know, we read it anyway by
    falling back to the_index. When "istate" from convert_to_git is now
    propagated down to read_attr_from_array() we will hit segfault
    somewhere inside read_blob_data_from_index.
    
    The right way of dealing with this is to kill "use_index" variable and
    only follow "istate" but at this stage we are not ready for that:
    while most git_attr_set_direction() calls just passes the_index to be
    assigned to use_index, unpack-trees passes a different one which is
    used by entry.c code, which has no way to know what index to use if we
    delete use_index. So this has to be done later.
    
    Signed-off-by: default avatarNguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    7a400a2c