Skip to content
  • Aaron Schrab's avatar
    hooks: Add function to check if a hook exists · 5a7da2dc
    Aaron Schrab authored and Junio C Hamano's avatar Junio C Hamano committed
    
    
    Create find_hook() function to determine if a given hook exists and is
    executable.  If it is, the path to the script will be returned,
    otherwise NULL is returned.
    
    This encapsulates the tests that are used to check for the existence of
    a hook in one place, making it easier to modify those checks if that is
    found to be necessary.  This also makes it simple for places that can
    use a hook to check if a hook exists before doing, possibly lengthy,
    setup work which would be pointless if no such hook is present.
    
    The returned value is left as a static value from get_pathname() rather
    than a duplicate because it is anticipated that the return value will
    either be used as a boolean, immediately added to an argv_array list
    which would result in it being duplicated at that point, or used to
    actually run the command without much intervening work.  Callers which
    need to hold onto the returned value for a longer time are expected to
    duplicate the return value themselves.
    
    Signed-off-by: default avatarAaron Schrab <aaron@schrab.com>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    5a7da2dc