summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2f02b25)
raw | patch | inline | side by side (parent: 2f02b25)
author | Jeff King <peff@peff.net> | |
Mon, 3 Dec 2007 05:30:01 +0000 (00:30 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 3 Dec 2007 07:35:46 +0000 (23:35 -0800) |
The code tries to collapse identical leading components
between the prefix and the path. So if we're in "dir1", the
path "dir1/file" should become just "file". However, we were
ending up with "../dir1/file". The included test expected
the wrong output.
The "len" parameter to quote_path can be negative to mean
"this is a NUL terminated string". Simply count it so that
the loop can rely on it being the length of the path.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
between the prefix and the path. So if we're in "dir1", the
path "dir1/file" should become just "file". However, we were
ending up with "../dir1/file". The included test expected
the wrong output.
The "len" parameter to quote_path can be negative to mean
"this is a NUL terminated string". Simply count it so that
the loop can rely on it being the length of the path.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t7502-status.sh | patch | blob | history | |
wt-status.c | patch | blob | history |
diff --git a/t/t7502-status.sh b/t/t7502-status.sh
index 269b3341a25f853e14715d747bddd2626fc5fdb6..d6ae69d46e84a3e470d99efaf33bc0f2c83a9037 100755 (executable)
--- a/t/t7502-status.sh
+++ b/t/t7502-status.sh
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
#
-# modified: ../dir1/modified
+# modified: modified
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
diff --git a/wt-status.c b/wt-status.c
index 0e0439f2c2d8f19abba0a683ce1b2ab3db6197ba..52ab41ceb6a5f839a3b0c9ffd69983ea5fdd60f7 100644 (file)
--- a/wt-status.c
+++ b/wt-status.c
}
static char *quote_path(const char *in, int len,
- struct strbuf *out, const char *prefix)
+ struct strbuf *out, const char *prefix)
{
- if (len > 0)
- strbuf_grow(out, len);
- strbuf_setlen(out, 0);
+ if (len < 0)
+ len = strlen(in);
+ strbuf_grow(out, len);
+ strbuf_setlen(out, 0);
if (prefix) {
int off = 0;
while (prefix[off] && off < len && prefix[off] == in[off])
strbuf_addstr(out, "../");
}
- for (; (len < 0 && *in) || len > 0; in++, len--) {
+ for ( ; len > 0; in++, len--) {
int ch = *in;
switch (ch) {