author | Clemens Buchacher <drizzd@aon.at> | |
Mon, 1 Aug 2011 21:19:58 +0000 (23:19 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 11 Aug 2011 20:04:16 +0000 (13:04 -0700) | ||
commit | 0f64bfa9567f697d6152ef9ea937d4b573029a08 | |
tree | fa7e4a84d1918c4c389d6239b6a736818a69288d | tree | snapshot |
parent | d5b66299040969706dd675c021f4336a26a6cc82 | commit | diff |
ls-files: fix pathspec display on error
The following sequence of commands reveals an issue with error
reporting of relative paths:
$ mkdir sub
$ cd sub
$ git ls-files --error-unmatch ../bbbbb
error: pathspec 'b' did not match any file(s) known to git.
$ git commit --error-unmatch ../bbbbb
error: pathspec 'b' did not match any file(s) known to git.
This bug is visible only if the normalized path (i.e., the relative
path from the repository root) is longer than the prefix.
Otherwise, the code skips over the normalized path and reads from
an unused memory location which still contains a leftover of the
original command line argument.
So instead, use the existing facilities to deal with relative paths
correctly.
Also fix inconsistency between "checkout" and "commit", e.g.
$ cd Documentation
$ git checkout nosuch.txt
error: pathspec 'Documentation/nosuch.txt' did not match...
$ git commit nosuch.txt
error: pathspec 'nosuch.txt' did not match...
by propagating the prefix down the codepath that reports the error.
Signed-off-by: Clemens Buchacher <drizzd@aon.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
The following sequence of commands reveals an issue with error
reporting of relative paths:
$ mkdir sub
$ cd sub
$ git ls-files --error-unmatch ../bbbbb
error: pathspec 'b' did not match any file(s) known to git.
$ git commit --error-unmatch ../bbbbb
error: pathspec 'b' did not match any file(s) known to git.
This bug is visible only if the normalized path (i.e., the relative
path from the repository root) is longer than the prefix.
Otherwise, the code skips over the normalized path and reads from
an unused memory location which still contains a leftover of the
original command line argument.
So instead, use the existing facilities to deal with relative paths
correctly.
Also fix inconsistency between "checkout" and "commit", e.g.
$ cd Documentation
$ git checkout nosuch.txt
error: pathspec 'Documentation/nosuch.txt' did not match...
$ git commit nosuch.txt
error: pathspec 'nosuch.txt' did not match...
by propagating the prefix down the codepath that reports the error.
Signed-off-by: Clemens Buchacher <drizzd@aon.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/checkout.c | diff | blob | history | |
builtin/commit.c | diff | blob | history | |
builtin/ls-files.c | diff | blob | history | |
cache.h | diff | blob | history | |
quote.c | diff | blob | history | |
t/t3005-ls-files-relative.sh | [new file with mode: 0755] | blob |