From 21f88ac84a024fcc73a22547e51509aa1459ab03 Mon Sep 17 00:00:00 2001 From: Andy Parkins Date: Thu, 2 Nov 2006 12:12:26 +0100 Subject: [PATCH 1/2] Improve git-prune -n output prune_object() in show_only mode would previously just show the path to the object that would be deleted. The path the object is stored in shouldn't be shown to users, they only know about sha1 identifiers so show that instead. Further, the sha1 alone isn't that useful for examining what is going to be deleted. This patch also adds the object type to the output, which makes it easy to pick out, say, the commits and use git-show to display them. Signed-off-by: Andy Parkins Signed-off-by: Junio C Hamano --- builtin-prune.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/builtin-prune.c b/builtin-prune.c index d853902c51..286a94c3fc 100644 --- a/builtin-prune.c +++ b/builtin-prune.c @@ -16,8 +16,14 @@ static struct rev_info revs; static int prune_object(char *path, const char *filename, const unsigned char *sha1) { + char buf[20]; + const char *type; + if (show_only) { - printf("would prune %s/%s\n", path, filename); + type = buf; + if (sha1_object_info(sha1, type, NULL)) + type = "unknown"; + printf("%s %s\n", sha1_to_hex(sha1), type ); return 0; } unlink(mkpath("%s/%s", path, filename)); From ac1471b39f1413046d4e338d898a93e403cbd3e5 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 24 Nov 2006 02:54:37 -0800 Subject: [PATCH 2/2] Typefix builtin-prune.c::prune_object() It passed (const char*) to a function that took a (char *); the buffer itself was of course writable, so pass the buffer itself. Signed-off-by: Junio C Hamano --- builtin-prune.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/builtin-prune.c b/builtin-prune.c index 286a94c3fc..8591d28b8e 100644 --- a/builtin-prune.c +++ b/builtin-prune.c @@ -20,10 +20,11 @@ static int prune_object(char *path, const char *filename, const unsigned char *s const char *type; if (show_only) { - type = buf; - if (sha1_object_info(sha1, type, NULL)) + if (sha1_object_info(sha1, buf, NULL)) type = "unknown"; - printf("%s %s\n", sha1_to_hex(sha1), type ); + else + type = buf; + printf("%s %s\n", sha1_to_hex(sha1), type); return 0; } unlink(mkpath("%s/%s", path, filename));