check_filename(): refactor ":/" handling
commita08cbcda1782993d83cf8763a394dab24e2c52b3
authorJeff King <peff@peff.net>
Fri, 26 May 2017 19:07:31 +0000 (26 15:07 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 29 May 2017 02:36:54 +0000 (29 11:36 +0900)
tree47d1648ed9d0150353644bd46c549be69bcf4915
parentbe6ed3f3346a24f4be2d771384528b1c87952b8f
check_filename(): refactor ":/" handling

We handle arguments with the ":/" pathspec magic specially,
making sure the name exists at the top-level.  We'll want to
handle more pathspec magic in future patches, so let's do a
little rearranging to make that easier.

Instead of relying on an if/else cascade to avoid the
prefix_filename() call, we'll just set prefix to NULL.
Likewise, we'll get rid of the "name" variable entirely, and
just push the "arg" pointer forward to skip past the magic.
That means by the time we get to the prefix-handling, we're
set up appropriately whether we saw ":/" or not.

Note that this does impact the final error message we
produce when stat() fails, as it shows "arg" (which we'll
have modified to skip magic and include the prefix). This is
a good thing; the original message would say something like
"failed to stat ':/foo'", which is confusing (we tried to
stat "foo").

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
setup.c