{"thread":{"id":"11462","subject":"[PATCH] git-clean: make \"Would remove ...\" path relative to cwd again","startedAt":"2008-01-04T04:47:50Z","lastAt":"2008-01-04T15:41:06Z","messageCount":2,"participants":["Junio C Hamano","Miklos Vajna"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"64408","messageId":"7vmyrmmc21.fsf@gitster.siamese.dyndns.org","threadId":"11462","inReplyTo":null,"subject":"[PATCH] git-clean: make \"Would remove ...\" path relative to cwd again","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-01-04T04:47:50Z","receivedAt":"2008-01-04T04:47:50Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The rewrite changed the output to use the path relative to the\ntop of the work tree without a good reason.  This fixes it.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin-clean.c |   21 +++++++++++++++------\n 1 files changed, 15 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin-clean.c b/builtin-clean.c\nindex ae30d4e..6cad8ea 100644\n--- a/builtin-clean.c\n+++ b/builtin-clean.c\n@@ -34,6 +34,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)\n \tstruct dir_struct dir;\n \tconst char *path, *base;\n \tstatic const char **pathspec;\n+\tint prefix_offset = 0;\n \tchar *seen = NULL;\n \tstruct option options[] = {\n \t\tOPT__QUIET(&quiet),\n@@ -71,6 +72,8 @@ int cmd_clean(int argc, const char **argv, const char *prefix)\n \tif (!ignored)\n \t\tsetup_standard_excludes(&dir);\n \n+\tif (prefix)\n+\t\tprefix_offset = strlen(prefix);\n \tpathspec = get_pathspec(prefix, argv);\n \tread_cache();\n \n@@ -132,26 +135,32 @@ int cmd_clean(int argc, const char **argv, const char *prefix)\n \t\tif (S_ISDIR(st.st_mode)) {\n \t\t\tstrbuf_addstr(&directory, ent->name);\n \t\t\tif (show_only && (remove_directories || matches)) {\n-\t\t\t\tprintf(\"Would remove %s\\n\", directory.buf);\n+\t\t\t\tprintf(\"Would remove %s\\n\",\n+\t\t\t\t       directory.buf + prefix_offset);\n \t\t\t} else if (quiet && (remove_directories || matches)) {\n \t\t\t\tremove_dir_recursively(&directory, 0);\n \t\t\t} else if (remove_directories || matches) {\n-\t\t\t\tprintf(\"Removing %s\\n\", directory.buf);\n+\t\t\t\tprintf(\"Removing %s\\n\",\n+\t\t\t\t       directory.buf + prefix_offset);\n \t\t\t\tremove_dir_recursively(&directory, 0);\n \t\t\t} else if (show_only) {\n-\t\t\t\tprintf(\"Would not remove %s\\n\", directory.buf);\n+\t\t\t\tprintf(\"Would not remove %s\\n\",\n+\t\t\t\t       directory.buf + prefix_offset);\n \t\t\t} else {\n-\t\t\t\tprintf(\"Not removing %s\\n\", directory.buf);\n+\t\t\t\tprintf(\"Not removing %s\\n\",\n+\t\t\t\t       directory.buf + prefix_offset);\n \t\t\t}\n \t\t\tstrbuf_reset(&directory);\n \t\t} else {\n \t\t\tif (pathspec && !matches)\n \t\t\t\tcontinue;\n \t\t\tif (show_only) {\n-\t\t\t\tprintf(\"Would remove %s\\n\", ent->name);\n+\t\t\t\tprintf(\"Would remove %s\\n\",\n+\t\t\t\t       ent->name + prefix_offset);\n \t\t\t\tcontinue;\n \t\t\t} else if (!quiet) {\n-\t\t\t\tprintf(\"Removing %s\\n\", ent->name);\n+\t\t\t\tprintf(\"Removing %s\\n\",\n+\t\t\t\t       ent->name + prefix_offset);\n \t\t\t}\n \t\t\tunlink(ent->name);\n \t\t}\n-- \n1.5.4.rc2.17.g257f\n"},{"id":"64437","messageId":"20080104154106.GP29972@genesis.frugalware.org","threadId":"11462","inReplyTo":"7vmyrmmc21.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] git-clean: make \"Would remove ...\" path relative to cwd again","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2008-01-04T15:41:06Z","receivedAt":"2008-01-04T15:41:06Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"On Thu, Jan 03, 2008 at 08:47:50PM -0800, Junio C Hamano <gitster@pobox.com> wrote:\n> The rewrite changed the output to use the path relative to the\n> top of the work tree without a good reason.  This fixes it.\n\nworks here fine.\n\nthanks,\n- VMiklos\n"}]}