Skip to content

Commit

Permalink
wt-status.c:quote_path(): convert empty path to "./"
Browse files Browse the repository at this point in the history
Now that we are correctly removing leading prefixes from files in git
status, there is a degenerate case: the directory matching the prefix.
Because we show only the directory name for a directory that contains
only untracked files, it gets collapsed to an empty string.

Example:

  $ git init
  $ mkdir subdir
  $ touch subdir/file
  $ git status
  ...
  # Untracked files:
  #   (use "git add <file>..." to include in what will be committed)
  #
  #       subdir/

  So far, so good.

  $ cd subdir
  $ git status
  ....
  # Untracked files:
  #   (use "git add <file>..." to include in what will be committed)
  #
  #

  Oops, that's a bit confusing.

  This patch prints './' to show that there is some output.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Dec 8, 2007
1 parent 235997c commit c3ce326
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions wt-status.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ static char *quote_path(const char *in, int len,
}
}

if (!out->len)
strbuf_addstr(out, "./");

return out->buf;
}

Expand Down

0 comments on commit c3ce326

Please sign in to comment.