@matheusbsbs / matheus-bagliano / commits / 95bf4bd4f7
Fork 0

git-clean: make "Would remove ..." path relative to cwd again

The rewrite changed the output to use the path relative to the top of the work tree without a good reason. This fixes it. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Jan 3, 2008 at 19:04 UTC 95bf4bd4f7280312571e642339f3571310d0d660
1 file changed +15 -6
builtin-clean.c
+15 -6
@@ -34,6 +34,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
34 struct dir_struct dir;
35 const char *path, *base;
36 static const char **pathspec;
37 + int prefix_offset = 0;
38 char *seen = NULL;
39 struct option options[] = {
40 OPT__QUIET(&quiet),
@@ -71,6 +72,8 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
72 if (!ignored)
73 setup_standard_excludes(&dir);
74
75 + if (prefix)
76 + prefix_offset = strlen(prefix);
77 pathspec = get_pathspec(prefix, argv);
78 read_cache();
79
@@ -132,26 +135,32 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
135 if (S_ISDIR(st.st_mode)) {
136 strbuf_addstr(&directory, ent->name);
137 if (show_only && (remove_directories || matches)) {
135 - printf("Would remove %s\n", directory.buf);
138 + printf("Would remove %s\n",
139 + directory.buf + prefix_offset);
140 } else if (quiet && (remove_directories || matches)) {
141 remove_dir_recursively(&directory, 0);
142 } else if (remove_directories || matches) {
139 - printf("Removing %s\n", directory.buf);
143 + printf("Removing %s\n",
144 + directory.buf + prefix_offset);
145 remove_dir_recursively(&directory, 0);
146 } else if (show_only) {
142 - printf("Would not remove %s\n", directory.buf);
147 + printf("Would not remove %s\n",
148 + directory.buf + prefix_offset);
149 } else {
144 - printf("Not removing %s\n", directory.buf);
150 + printf("Not removing %s\n",
151 + directory.buf + prefix_offset);
152 }
153 strbuf_reset(&directory);
154 } else {
155 if (pathspec && !matches)
156 continue;
157 if (show_only) {
151 - printf("Would remove %s\n", ent->name);
158 + printf("Would remove %s\n",
159 + ent->name + prefix_offset);
160 continue;
161 } else if (!quiet) {
154 - printf("Removing %s\n", ent->name);
162 + printf("Removing %s\n",
163 + ent->name + prefix_offset);
164 }
165 unlink(ent->name);
166 }