• P
    builtin-am: implement patch queue mechanism · 8c3bd9e2
    Paul Tan 提交于
    git-am applies a series of patches. If the process terminates
    abnormally, we want to be able to resume applying the series of patches.
    This requires the session state to be saved in a persistent location.
    
    Implement the mechanism of a "patch queue", represented by 2 integers --
    the index of the current patch we are applying and the index of the last
    patch, as well as its lifecycle through the following functions:
    
    * am_setup(), which will set up the state directory
      $GIT_DIR/rebase-apply. As such, even if the process exits abnormally,
      the last-known state will still persist.
    
    * am_load(), which is called if there is an am session in
      progress, to load the last known state from the state directory so we
      can resume applying patches.
    
    * am_run(), which will do the actual patch application. After applying a
      patch, it calls am_next() to increment the current patch index. The
      logic for applying and committing a patch is not implemented yet.
    
    * am_destroy(), which is finally called when we successfully applied all
      the patches in the queue, to clean up by removing the state directory
      and its contents.
    Helped-by: NJunio C Hamano <gitster@pobox.com>
    Helped-by: NStefan Beller <sbeller@google.com>
    Helped-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
    Signed-off-by: NPaul Tan <pyokagan@gmail.com>
    Signed-off-by: NJunio C Hamano <gitster@pobox.com>
    8c3bd9e2
am.c 4.3 KB