Skip to content
  • Duy Nguyen's avatar
    pack-objects: turn type and in_pack_type to bitfields · fd9b1bae
    Duy Nguyen authored and Junio C Hamano's avatar Junio C Hamano committed
    An extra field type_valid is added to carry the equivalent of OBJ_BAD
    in the original "type" field. in_pack_type always contains a valid
    type so we only need 3 bits for it.
    
    A note about accepting OBJ_NONE as "valid" type. The function
    read_object_list_from_stdin() can pass this value [1] and it
    eventually calls create_object_entry() where current code skip setting
    "type" field if the incoming type is zero. This does not have any bad
    side effects because "type" field should be memset()'d anyway.
    
    But since we also need to set type_valid now, skipping oe_set_type()
    leaves type_valid zero/false, which will make oe_type() return
    OBJ_BAD, not OBJ_NONE anymore. Apparently we do care about OBJ_NONE in
    prepare_pack(). This switch from OBJ_NONE to OBJ_BAD may trigger
    
        fatal: unable to get type of object ...
    
    Accepting OBJ_NONE [2] does sound wrong, but this is how it is has
    been for a very long time and I haven't time to dig in further.
    
    [1] See 5c49c116 (pack-objects: better check_object() performances -
        2007-04-16)
    
    [2] 21666f1a
    
     (convert object type handling from a string to a number
        - 2007-02-26)
    
    Signed-off-by: default avatarNguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    fd9b1bae