Skip to content
  • Jeff King's avatar
    bundle: use prefix_filename with bundle path · 3b754eed
    Jeff King authored and Junio C Hamano's avatar Junio C Hamano committed
    
    
    We may take the path to a bundle file as an argument, and
    need to adjust the filename based on the prefix we
    discovered while setting up the git directory. We do so
    manually into a fixed-size buffer, but using
    prefix_filename() is the normal way.
    
    Besides being more concise, there are two subtle
    improvements:
    
      1. The original inserted a "/" between the two paths, even
         though the "prefix" argument always has the "/"
         appended. That means that:
    
           cd subdir && git bundle verify ../foo.bundle
    
         was looking at (and reporting) subdir//../foo.bundle.
         Harmless, but ugly.  Using prefix_filename() gets this
         right.
    
      2. The original checked for an absolute path by looking
         for a leading '/'. It should have been using
         is_absolute_path(), which also covers more cases on
         Windows (backslashes and dos drive prefixes).
    
         But it's easier still to just pass the name to
         prefix_filename(), which handles this case
         automatically.
    
    Note that we'll just leak the resulting buffer in the name
    of simplicity, since it needs to last through the duration
    of the program anyway.
    
    Signed-off-by: default avatarJeff King <peff@peff.net>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    3b754eed