[PATCH] quote_path: convert empty path to "./"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

---
I think it looks a bit ugly because it is so small (though just '.' was
even worse). But I don't see what else would make sense.

 wt-status.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/wt-status.c b/wt-status.c
index 02dbb75..31d83bf 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -121,6 +121,9 @@ static char *quote_path(const char *in, int len,
 		}
 	}
 
+	if (!out->len)
+		strbuf_addstr(out, "./");
+
 	return out->buf;
 }
 
-- 
1.5.3.7.2156.g3d791-dirty
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux