git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] quote_path: convert empty path to "./"
@ 2007-12-07 16:57 Jeff King
  2007-12-07 18:54 ` Johannes Schindelin
  0 siblings, 1 reply; 12+ messages in thread
From: Jeff King @ 2007-12-07 16:57 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Johannes Schindelin, git

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

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2007-12-08  8:46 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-07 16:57 [PATCH] quote_path: convert empty path to "./" Jeff King
2007-12-07 18:54 ` Johannes Schindelin
2007-12-07 19:05   ` Thomas Harning
2007-12-07 20:49     ` Jeff King
2007-12-07 21:26       ` [PATCH] add status.relativePaths config variable Jeff King
2007-12-08  7:34         ` Junio C Hamano
2007-12-08  7:47           ` Junio C Hamano
2007-12-08  8:02             ` Jeff King
2007-12-08  8:05               ` Junio C Hamano
2007-12-08  8:45                 ` Jeff King
2007-12-08  7:55           ` Jeff King
2007-12-08  8:14             ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).