bundle: use prefix_filename with bundle path
commit3b754eedd58636926d07b14a34799a3aa7b8ebc2
authorJeff King <peff@peff.net>
Tue, 21 Mar 2017 01:31:27 +0000 (20 21:31 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 21 Mar 2017 18:18:41 +0000 (21 11:18 -0700)
tree4019a9f90e18676fe1cf6f1df37f8b67df0e5754
parentaf10e8b1559790d5c78fcc2a1aae5c42f3930a00
bundle: use prefix_filename with bundle path

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: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/bundle.c