Linus Torvalds | 8695c8b | 2005-04-11 18:55:38 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This merges the file listing in the directory cache index |
| 3 | * with the actual working directory list, and shows different |
| 4 | * combinations of the two. |
| 5 | * |
| 6 | * Copyright (C) Linus Torvalds, 2005 |
| 7 | */ |
Linus Torvalds | 8695c8b | 2005-04-11 18:55:38 -0700 | [diff] [blame] | 8 | #include "cache.h" |
Junio C Hamano | 22ddf71 | 2005-10-14 21:56:46 -0700 | [diff] [blame] | 9 | #include "quote.h" |
Linus Torvalds | 453ec4b | 2006-05-16 19:02:14 -0700 | [diff] [blame] | 10 | #include "dir.h" |
Peter Eriksen | 0864f26 | 2006-05-23 14:15:29 +0200 | [diff] [blame] | 11 | #include "builtin.h" |
Junio C Hamano | 64586e7 | 2007-09-12 16:04:22 -0700 | [diff] [blame] | 12 | #include "tree.h" |
Linus Torvalds | 8695c8b | 2005-04-11 18:55:38 -0700 | [diff] [blame] | 13 | |
David Rientjes | 96f1e58 | 2006-08-15 10:23:48 -0700 | [diff] [blame] | 14 | static int abbrev; |
| 15 | static int show_deleted; |
| 16 | static int show_cached; |
| 17 | static int show_others; |
| 18 | static int show_stage; |
| 19 | static int show_unmerged; |
| 20 | static int show_modified; |
| 21 | static int show_killed; |
| 22 | static int show_valid_bit; |
Junio C Hamano | b83c834 | 2005-04-15 11:11:01 -0700 | [diff] [blame] | 23 | static int line_terminator = '\n'; |
Linus Torvalds | 8695c8b | 2005-04-11 18:55:38 -0700 | [diff] [blame] | 24 | |
David Rientjes | 96f1e58 | 2006-08-15 10:23:48 -0700 | [diff] [blame] | 25 | static int prefix_len; |
| 26 | static int prefix_offset; |
| 27 | static const char **pathspec; |
| 28 | static int error_unmatch; |
| 29 | static char *ps_matched; |
Junio C Hamano | 64586e7 | 2007-09-12 16:04:22 -0700 | [diff] [blame] | 30 | static const char *with_tree; |
Linus Torvalds | 5be4efb | 2005-08-21 12:55:33 -0700 | [diff] [blame] | 31 | |
Petr Baudis | 20d37ef | 2005-04-21 19:47:08 -0700 | [diff] [blame] | 32 | static const char *tag_cached = ""; |
| 33 | static const char *tag_unmerged = ""; |
| 34 | static const char *tag_removed = ""; |
| 35 | static const char *tag_other = ""; |
Junio C Hamano | 6ca4594 | 2005-05-12 17:17:54 -0700 | [diff] [blame] | 36 | static const char *tag_killed = ""; |
Junio C Hamano | b039189 | 2005-09-19 15:11:15 -0700 | [diff] [blame] | 37 | static const char *tag_modified = ""; |
Petr Baudis | 20d37ef | 2005-04-21 19:47:08 -0700 | [diff] [blame] | 38 | |
Junio C Hamano | 6ca4594 | 2005-05-12 17:17:54 -0700 | [diff] [blame] | 39 | |
Linus Torvalds | 56fc510 | 2005-08-21 17:27:50 -0700 | [diff] [blame] | 40 | /* |
Junio C Hamano | ee425e4 | 2007-11-18 01:13:32 -0800 | [diff] [blame] | 41 | * Match a pathspec against a filename. The first "skiplen" characters |
Linus Torvalds | 56fc510 | 2005-08-21 17:27:50 -0700 | [diff] [blame] | 42 | * are the common prefix |
| 43 | */ |
Junio C Hamano | ee425e4 | 2007-11-18 01:13:32 -0800 | [diff] [blame] | 44 | int pathspec_match(const char **spec, char *ps_matched, |
| 45 | const char *filename, int skiplen) |
Linus Torvalds | 56fc510 | 2005-08-21 17:27:50 -0700 | [diff] [blame] | 46 | { |
| 47 | const char *m; |
| 48 | |
| 49 | while ((m = *spec++) != NULL) { |
Junio C Hamano | ee425e4 | 2007-11-18 01:13:32 -0800 | [diff] [blame] | 50 | int matchlen = strlen(m + skiplen); |
Linus Torvalds | 56fc510 | 2005-08-21 17:27:50 -0700 | [diff] [blame] | 51 | |
| 52 | if (!matchlen) |
Junio C Hamano | bba319b | 2006-02-14 12:40:20 -0800 | [diff] [blame] | 53 | goto matched; |
Junio C Hamano | ee425e4 | 2007-11-18 01:13:32 -0800 | [diff] [blame] | 54 | if (!strncmp(m + skiplen, filename + skiplen, matchlen)) { |
| 55 | if (m[skiplen + matchlen - 1] == '/') |
Junio C Hamano | bba319b | 2006-02-14 12:40:20 -0800 | [diff] [blame] | 56 | goto matched; |
Junio C Hamano | ee425e4 | 2007-11-18 01:13:32 -0800 | [diff] [blame] | 57 | switch (filename[skiplen + matchlen]) { |
Linus Torvalds | 56fc510 | 2005-08-21 17:27:50 -0700 | [diff] [blame] | 58 | case '/': case '\0': |
Junio C Hamano | bba319b | 2006-02-14 12:40:20 -0800 | [diff] [blame] | 59 | goto matched; |
Linus Torvalds | 56fc510 | 2005-08-21 17:27:50 -0700 | [diff] [blame] | 60 | } |
| 61 | } |
Junio C Hamano | ee425e4 | 2007-11-18 01:13:32 -0800 | [diff] [blame] | 62 | if (!fnmatch(m + skiplen, filename + skiplen, 0)) |
Junio C Hamano | bba319b | 2006-02-14 12:40:20 -0800 | [diff] [blame] | 63 | goto matched; |
| 64 | if (ps_matched) |
| 65 | ps_matched++; |
| 66 | continue; |
| 67 | matched: |
| 68 | if (ps_matched) |
| 69 | *ps_matched = 1; |
| 70 | return 1; |
Linus Torvalds | 56fc510 | 2005-08-21 17:27:50 -0700 | [diff] [blame] | 71 | } |
| 72 | return 0; |
| 73 | } |
| 74 | |
Linus Torvalds | 453ec4b | 2006-05-16 19:02:14 -0700 | [diff] [blame] | 75 | static void show_dir_entry(const char *tag, struct dir_entry *ent) |
Linus Torvalds | 5be4efb | 2005-08-21 12:55:33 -0700 | [diff] [blame] | 76 | { |
| 77 | int len = prefix_len; |
| 78 | int offset = prefix_offset; |
| 79 | |
| 80 | if (len >= ent->len) |
| 81 | die("git-ls-files: internal error - directory entry not superset of prefix"); |
| 82 | |
Junio C Hamano | ee425e4 | 2007-11-18 01:13:32 -0800 | [diff] [blame] | 83 | if (pathspec && !pathspec_match(pathspec, ps_matched, ent->name, len)) |
Linus Torvalds | 5be4efb | 2005-08-21 12:55:33 -0700 | [diff] [blame] | 84 | return; |
| 85 | |
Junio C Hamano | 22ddf71 | 2005-10-14 21:56:46 -0700 | [diff] [blame] | 86 | fputs(tag, stdout); |
Pierre Habouzit | 663af34 | 2007-09-20 00:42:15 +0200 | [diff] [blame] | 87 | write_name_quoted(ent->name + offset, stdout, line_terminator); |
Linus Torvalds | 5be4efb | 2005-08-21 12:55:33 -0700 | [diff] [blame] | 88 | } |
| 89 | |
Linus Torvalds | 453ec4b | 2006-05-16 19:02:14 -0700 | [diff] [blame] | 90 | static void show_other_files(struct dir_struct *dir) |
Junio C Hamano | fcbc308 | 2005-11-06 17:26:31 -0800 | [diff] [blame] | 91 | { |
| 92 | int i; |
Linus Torvalds | 5698454 | 2007-04-14 16:22:08 -0700 | [diff] [blame] | 93 | |
| 94 | |
| 95 | /* |
| 96 | * Skip matching and unmerged entries for the paths, |
| 97 | * since we want just "others". |
| 98 | * |
| 99 | * (Matching entries are normally pruned during |
| 100 | * the directory tree walk, but will show up for |
| 101 | * gitlinks because we don't necessarily have |
| 102 | * dir->show_other_directories set to suppress |
| 103 | * them). |
| 104 | */ |
Linus Torvalds | 453ec4b | 2006-05-16 19:02:14 -0700 | [diff] [blame] | 105 | for (i = 0; i < dir->nr; i++) { |
Linus Torvalds | 453ec4b | 2006-05-16 19:02:14 -0700 | [diff] [blame] | 106 | struct dir_entry *ent = dir->entries[i]; |
Linus Torvalds | 5698454 | 2007-04-14 16:22:08 -0700 | [diff] [blame] | 107 | int len, pos; |
Junio C Hamano | fcbc308 | 2005-11-06 17:26:31 -0800 | [diff] [blame] | 108 | struct cache_entry *ce; |
Linus Torvalds | 5698454 | 2007-04-14 16:22:08 -0700 | [diff] [blame] | 109 | |
| 110 | /* |
| 111 | * Remove the '/' at the end that directory |
| 112 | * walking adds for directory entries. |
| 113 | */ |
| 114 | len = ent->len; |
| 115 | if (len && ent->name[len-1] == '/') |
| 116 | len--; |
| 117 | pos = cache_name_pos(ent->name, len); |
Junio C Hamano | fcbc308 | 2005-11-06 17:26:31 -0800 | [diff] [blame] | 118 | if (0 <= pos) |
Linus Torvalds | 5698454 | 2007-04-14 16:22:08 -0700 | [diff] [blame] | 119 | continue; /* exact match */ |
Junio C Hamano | fcbc308 | 2005-11-06 17:26:31 -0800 | [diff] [blame] | 120 | pos = -pos - 1; |
Junio C Hamano | a6080a0 | 2007-06-07 00:04:01 -0700 | [diff] [blame] | 121 | if (pos < active_nr) { |
Junio C Hamano | fcbc308 | 2005-11-06 17:26:31 -0800 | [diff] [blame] | 122 | ce = active_cache[pos]; |
Linus Torvalds | 5698454 | 2007-04-14 16:22:08 -0700 | [diff] [blame] | 123 | if (ce_namelen(ce) == len && |
| 124 | !memcmp(ce->name, ent->name, len)) |
Junio C Hamano | fcbc308 | 2005-11-06 17:26:31 -0800 | [diff] [blame] | 125 | continue; /* Yup, this one exists unmerged */ |
| 126 | } |
| 127 | show_dir_entry(tag_other, ent); |
| 128 | } |
| 129 | } |
| 130 | |
Linus Torvalds | 453ec4b | 2006-05-16 19:02:14 -0700 | [diff] [blame] | 131 | static void show_killed_files(struct dir_struct *dir) |
Junio C Hamano | 6ca4594 | 2005-05-12 17:17:54 -0700 | [diff] [blame] | 132 | { |
| 133 | int i; |
Linus Torvalds | 453ec4b | 2006-05-16 19:02:14 -0700 | [diff] [blame] | 134 | for (i = 0; i < dir->nr; i++) { |
| 135 | struct dir_entry *ent = dir->entries[i]; |
Junio C Hamano | 6ca4594 | 2005-05-12 17:17:54 -0700 | [diff] [blame] | 136 | char *cp, *sp; |
| 137 | int pos, len, killed = 0; |
| 138 | |
| 139 | for (cp = ent->name; cp - ent->name < ent->len; cp = sp + 1) { |
| 140 | sp = strchr(cp, '/'); |
| 141 | if (!sp) { |
| 142 | /* If ent->name is prefix of an entry in the |
| 143 | * cache, it will be killed. |
| 144 | */ |
| 145 | pos = cache_name_pos(ent->name, ent->len); |
| 146 | if (0 <= pos) |
| 147 | die("bug in show-killed-files"); |
| 148 | pos = -pos - 1; |
| 149 | while (pos < active_nr && |
| 150 | ce_stage(active_cache[pos])) |
| 151 | pos++; /* skip unmerged */ |
| 152 | if (active_nr <= pos) |
| 153 | break; |
| 154 | /* pos points at a name immediately after |
| 155 | * ent->name in the cache. Does it expect |
| 156 | * ent->name to be a directory? |
| 157 | */ |
| 158 | len = ce_namelen(active_cache[pos]); |
| 159 | if ((ent->len < len) && |
| 160 | !strncmp(active_cache[pos]->name, |
| 161 | ent->name, ent->len) && |
| 162 | active_cache[pos]->name[ent->len] == '/') |
| 163 | killed = 1; |
| 164 | break; |
| 165 | } |
| 166 | if (0 <= cache_name_pos(ent->name, sp - ent->name)) { |
| 167 | /* If any of the leading directories in |
| 168 | * ent->name is registered in the cache, |
| 169 | * ent->name will be killed. |
| 170 | */ |
| 171 | killed = 1; |
| 172 | break; |
| 173 | } |
| 174 | } |
| 175 | if (killed) |
Linus Torvalds | 453ec4b | 2006-05-16 19:02:14 -0700 | [diff] [blame] | 176 | show_dir_entry(tag_killed, dir->entries[i]); |
Junio C Hamano | 6ca4594 | 2005-05-12 17:17:54 -0700 | [diff] [blame] | 177 | } |
Linus Torvalds | 8695c8b | 2005-04-11 18:55:38 -0700 | [diff] [blame] | 178 | } |
| 179 | |
Linus Torvalds | 5be4efb | 2005-08-21 12:55:33 -0700 | [diff] [blame] | 180 | static void show_ce_entry(const char *tag, struct cache_entry *ce) |
| 181 | { |
| 182 | int len = prefix_len; |
| 183 | int offset = prefix_offset; |
| 184 | |
| 185 | if (len >= ce_namelen(ce)) |
| 186 | die("git-ls-files: internal error - cache entry not superset of prefix"); |
| 187 | |
Junio C Hamano | ee425e4 | 2007-11-18 01:13:32 -0800 | [diff] [blame] | 188 | if (pathspec && !pathspec_match(pathspec, ps_matched, ce->name, len)) |
Linus Torvalds | 5be4efb | 2005-08-21 12:55:33 -0700 | [diff] [blame] | 189 | return; |
| 190 | |
Junio C Hamano | 8bb2e03 | 2006-02-12 01:47:57 -0800 | [diff] [blame] | 191 | if (tag && *tag && show_valid_bit && |
| 192 | (ce->ce_flags & htons(CE_VALID))) { |
Junio C Hamano | 2bcab24 | 2006-02-08 21:50:18 -0800 | [diff] [blame] | 193 | static char alttag[4]; |
| 194 | memcpy(alttag, tag, 3); |
| 195 | if (isalpha(tag[0])) |
| 196 | alttag[0] = tolower(tag[0]); |
| 197 | else if (tag[0] == '?') |
| 198 | alttag[0] = '!'; |
| 199 | else { |
| 200 | alttag[0] = 'v'; |
| 201 | alttag[1] = tag[0]; |
| 202 | alttag[2] = ' '; |
| 203 | alttag[3] = 0; |
| 204 | } |
| 205 | tag = alttag; |
| 206 | } |
| 207 | |
Junio C Hamano | 22ddf71 | 2005-10-14 21:56:46 -0700 | [diff] [blame] | 208 | if (!show_stage) { |
| 209 | fputs(tag, stdout); |
Pierre Habouzit | 663af34 | 2007-09-20 00:42:15 +0200 | [diff] [blame] | 210 | } else { |
Junio C Hamano | 22ddf71 | 2005-10-14 21:56:46 -0700 | [diff] [blame] | 211 | printf("%s%06o %s %d\t", |
Linus Torvalds | 5be4efb | 2005-08-21 12:55:33 -0700 | [diff] [blame] | 212 | tag, |
| 213 | ntohl(ce->ce_mode), |
Eric Wong | ad0cae4 | 2006-03-07 11:59:17 -0800 | [diff] [blame] | 214 | abbrev ? find_unique_abbrev(ce->sha1,abbrev) |
| 215 | : sha1_to_hex(ce->sha1), |
Junio C Hamano | 22ddf71 | 2005-10-14 21:56:46 -0700 | [diff] [blame] | 216 | ce_stage(ce)); |
Junio C Hamano | 22ddf71 | 2005-10-14 21:56:46 -0700 | [diff] [blame] | 217 | } |
Pierre Habouzit | 663af34 | 2007-09-20 00:42:15 +0200 | [diff] [blame] | 218 | write_name_quoted(ce->name + offset, stdout, line_terminator); |
Linus Torvalds | 5be4efb | 2005-08-21 12:55:33 -0700 | [diff] [blame] | 219 | } |
| 220 | |
Linus Torvalds | 3e04228 | 2006-07-31 13:13:55 -0700 | [diff] [blame] | 221 | static void show_files(struct dir_struct *dir, const char *prefix) |
Linus Torvalds | 8695c8b | 2005-04-11 18:55:38 -0700 | [diff] [blame] | 222 | { |
| 223 | int i; |
| 224 | |
| 225 | /* For cached/deleted files we don't need to even do the readdir */ |
Junio C Hamano | 6ca4594 | 2005-05-12 17:17:54 -0700 | [diff] [blame] | 226 | if (show_others || show_killed) { |
Linus Torvalds | 5be4efb | 2005-08-21 12:55:33 -0700 | [diff] [blame] | 227 | const char *path = ".", *base = ""; |
| 228 | int baselen = prefix_len; |
| 229 | |
Linus Torvalds | b4189aa | 2006-05-16 19:46:16 -0700 | [diff] [blame] | 230 | if (baselen) |
Linus Torvalds | 5be4efb | 2005-08-21 12:55:33 -0700 | [diff] [blame] | 231 | path = base = prefix; |
Linus Torvalds | 9fc42d6 | 2007-03-30 20:39:30 -0700 | [diff] [blame] | 232 | read_directory(dir, path, base, baselen, pathspec); |
Junio C Hamano | 6ca4594 | 2005-05-12 17:17:54 -0700 | [diff] [blame] | 233 | if (show_others) |
Linus Torvalds | 453ec4b | 2006-05-16 19:02:14 -0700 | [diff] [blame] | 234 | show_other_files(dir); |
Junio C Hamano | 6ca4594 | 2005-05-12 17:17:54 -0700 | [diff] [blame] | 235 | if (show_killed) |
Linus Torvalds | 453ec4b | 2006-05-16 19:02:14 -0700 | [diff] [blame] | 236 | show_killed_files(dir); |
Linus Torvalds | 8695c8b | 2005-04-11 18:55:38 -0700 | [diff] [blame] | 237 | } |
Junio C Hamano | aee4619 | 2005-04-16 08:33:23 -0700 | [diff] [blame] | 238 | if (show_cached | show_stage) { |
Linus Torvalds | 8695c8b | 2005-04-11 18:55:38 -0700 | [diff] [blame] | 239 | for (i = 0; i < active_nr; i++) { |
| 240 | struct cache_entry *ce = active_cache[i]; |
Linus Torvalds | 453ec4b | 2006-05-16 19:02:14 -0700 | [diff] [blame] | 241 | if (excluded(dir, ce->name) != dir->show_ignored) |
Nicolas Pitre | 9ff768e | 2005-04-28 11:44:04 -0700 | [diff] [blame] | 242 | continue; |
Linus Torvalds | eec8c63 | 2005-04-16 12:43:32 -0700 | [diff] [blame] | 243 | if (show_unmerged && !ce_stage(ce)) |
| 244 | continue; |
Junio C Hamano | 64586e7 | 2007-09-12 16:04:22 -0700 | [diff] [blame] | 245 | if (ce->ce_flags & htons(CE_UPDATE)) |
| 246 | continue; |
Linus Torvalds | 5be4efb | 2005-08-21 12:55:33 -0700 | [diff] [blame] | 247 | show_ce_entry(ce_stage(ce) ? tag_unmerged : tag_cached, ce); |
Linus Torvalds | 8695c8b | 2005-04-11 18:55:38 -0700 | [diff] [blame] | 248 | } |
| 249 | } |
Junio C Hamano | b039189 | 2005-09-19 15:11:15 -0700 | [diff] [blame] | 250 | if (show_deleted | show_modified) { |
Linus Torvalds | 8695c8b | 2005-04-11 18:55:38 -0700 | [diff] [blame] | 251 | for (i = 0; i < active_nr; i++) { |
| 252 | struct cache_entry *ce = active_cache[i]; |
| 253 | struct stat st; |
Junio C Hamano | b039189 | 2005-09-19 15:11:15 -0700 | [diff] [blame] | 254 | int err; |
Linus Torvalds | 453ec4b | 2006-05-16 19:02:14 -0700 | [diff] [blame] | 255 | if (excluded(dir, ce->name) != dir->show_ignored) |
Nicolas Pitre | 9ff768e | 2005-04-28 11:44:04 -0700 | [diff] [blame] | 256 | continue; |
Junio C Hamano | b039189 | 2005-09-19 15:11:15 -0700 | [diff] [blame] | 257 | err = lstat(ce->name, &st); |
| 258 | if (show_deleted && err) |
| 259 | show_ce_entry(tag_removed, ce); |
Junio C Hamano | 2bcab24 | 2006-02-08 21:50:18 -0800 | [diff] [blame] | 260 | if (show_modified && ce_modified(ce, &st, 0)) |
Junio C Hamano | b039189 | 2005-09-19 15:11:15 -0700 | [diff] [blame] | 261 | show_ce_entry(tag_modified, ce); |
Linus Torvalds | 8695c8b | 2005-04-11 18:55:38 -0700 | [diff] [blame] | 262 | } |
| 263 | } |
Linus Torvalds | 8695c8b | 2005-04-11 18:55:38 -0700 | [diff] [blame] | 264 | } |
| 265 | |
Linus Torvalds | 5be4efb | 2005-08-21 12:55:33 -0700 | [diff] [blame] | 266 | /* |
| 267 | * Prune the index to only contain stuff starting with "prefix" |
| 268 | */ |
Linus Torvalds | 3e04228 | 2006-07-31 13:13:55 -0700 | [diff] [blame] | 269 | static void prune_cache(const char *prefix) |
Linus Torvalds | 5be4efb | 2005-08-21 12:55:33 -0700 | [diff] [blame] | 270 | { |
| 271 | int pos = cache_name_pos(prefix, prefix_len); |
| 272 | unsigned int first, last; |
| 273 | |
| 274 | if (pos < 0) |
| 275 | pos = -pos-1; |
Keith Packard | 95af39f | 2007-10-02 22:44:15 -0700 | [diff] [blame] | 276 | memmove(active_cache, active_cache + pos, |
| 277 | (active_nr - pos) * sizeof(struct cache_entry *)); |
Linus Torvalds | 5be4efb | 2005-08-21 12:55:33 -0700 | [diff] [blame] | 278 | active_nr -= pos; |
| 279 | first = 0; |
| 280 | last = active_nr; |
| 281 | while (last > first) { |
| 282 | int next = (last + first) >> 1; |
| 283 | struct cache_entry *ce = active_cache[next]; |
| 284 | if (!strncmp(ce->name, prefix, prefix_len)) { |
| 285 | first = next+1; |
| 286 | continue; |
| 287 | } |
| 288 | last = next; |
| 289 | } |
| 290 | active_nr = last; |
| 291 | } |
| 292 | |
Linus Torvalds | 3e04228 | 2006-07-31 13:13:55 -0700 | [diff] [blame] | 293 | static const char *verify_pathspec(const char *prefix) |
Linus Torvalds | 5be4efb | 2005-08-21 12:55:33 -0700 | [diff] [blame] | 294 | { |
Linus Torvalds | 56fc510 | 2005-08-21 17:27:50 -0700 | [diff] [blame] | 295 | const char **p, *n, *prev; |
Linus Torvalds | 56fc510 | 2005-08-21 17:27:50 -0700 | [diff] [blame] | 296 | unsigned long max; |
Linus Torvalds | 5be4efb | 2005-08-21 12:55:33 -0700 | [diff] [blame] | 297 | |
Linus Torvalds | 56fc510 | 2005-08-21 17:27:50 -0700 | [diff] [blame] | 298 | prev = NULL; |
| 299 | max = PATH_MAX; |
| 300 | for (p = pathspec; (n = *p) != NULL; p++) { |
| 301 | int i, len = 0; |
| 302 | for (i = 0; i < max; i++) { |
| 303 | char c = n[i]; |
| 304 | if (prev && prev[i] != c) |
| 305 | break; |
Linus Torvalds | 5690614 | 2005-08-23 17:14:13 -0700 | [diff] [blame] | 306 | if (!c || c == '*' || c == '?') |
Linus Torvalds | 56fc510 | 2005-08-21 17:27:50 -0700 | [diff] [blame] | 307 | break; |
| 308 | if (c == '/') |
| 309 | len = i+1; |
| 310 | } |
| 311 | prev = n; |
| 312 | if (len < max) { |
| 313 | max = len; |
| 314 | if (!max) |
| 315 | break; |
| 316 | } |
Linus Torvalds | 5be4efb | 2005-08-21 12:55:33 -0700 | [diff] [blame] | 317 | } |
Linus Torvalds | 56fc510 | 2005-08-21 17:27:50 -0700 | [diff] [blame] | 318 | |
| 319 | if (prefix_offset > max || memcmp(prev, prefix, prefix_offset)) |
| 320 | die("git-ls-files: cannot generate relative filenames containing '..'"); |
| 321 | |
Linus Torvalds | 56fc510 | 2005-08-21 17:27:50 -0700 | [diff] [blame] | 322 | prefix_len = max; |
Pierre Habouzit | 182af83 | 2007-09-16 00:32:36 +0200 | [diff] [blame] | 323 | return max ? xmemdupz(prev, max) : NULL; |
Linus Torvalds | 5be4efb | 2005-08-21 12:55:33 -0700 | [diff] [blame] | 324 | } |
| 325 | |
Junio C Hamano | 64586e7 | 2007-09-12 16:04:22 -0700 | [diff] [blame] | 326 | /* |
| 327 | * Read the tree specified with --with-tree option |
| 328 | * (typically, HEAD) into stage #1 and then |
| 329 | * squash them down to stage #0. This is used for |
| 330 | * --error-unmatch to list and check the path patterns |
| 331 | * that were given from the command line. We are not |
| 332 | * going to write this index out. |
| 333 | */ |
Junio C Hamano | ee425e4 | 2007-11-18 01:13:32 -0800 | [diff] [blame] | 334 | void overlay_tree_on_cache(const char *tree_name, const char *prefix) |
Junio C Hamano | 64586e7 | 2007-09-12 16:04:22 -0700 | [diff] [blame] | 335 | { |
| 336 | struct tree *tree; |
| 337 | unsigned char sha1[20]; |
| 338 | const char **match; |
| 339 | struct cache_entry *last_stage0 = NULL; |
| 340 | int i; |
| 341 | |
| 342 | if (get_sha1(tree_name, sha1)) |
| 343 | die("tree-ish %s not found.", tree_name); |
| 344 | tree = parse_tree_indirect(sha1); |
| 345 | if (!tree) |
| 346 | die("bad tree-ish %s", tree_name); |
| 347 | |
| 348 | /* Hoist the unmerged entries up to stage #3 to make room */ |
| 349 | for (i = 0; i < active_nr; i++) { |
| 350 | struct cache_entry *ce = active_cache[i]; |
| 351 | if (!ce_stage(ce)) |
| 352 | continue; |
| 353 | ce->ce_flags |= htons(CE_STAGEMASK); |
| 354 | } |
| 355 | |
| 356 | if (prefix) { |
| 357 | static const char *(matchbuf[2]); |
| 358 | matchbuf[0] = prefix; |
| 359 | matchbuf [1] = NULL; |
| 360 | match = matchbuf; |
| 361 | } else |
| 362 | match = NULL; |
| 363 | if (read_tree(tree, 1, match)) |
| 364 | die("unable to read tree entries %s", tree_name); |
| 365 | |
| 366 | for (i = 0; i < active_nr; i++) { |
| 367 | struct cache_entry *ce = active_cache[i]; |
| 368 | switch (ce_stage(ce)) { |
| 369 | case 0: |
| 370 | last_stage0 = ce; |
| 371 | /* fallthru */ |
| 372 | default: |
| 373 | continue; |
| 374 | case 1: |
| 375 | /* |
| 376 | * If there is stage #0 entry for this, we do not |
| 377 | * need to show it. We use CE_UPDATE bit to mark |
| 378 | * such an entry. |
| 379 | */ |
| 380 | if (last_stage0 && |
| 381 | !strcmp(last_stage0->name, ce->name)) |
| 382 | ce->ce_flags |= htons(CE_UPDATE); |
| 383 | } |
| 384 | } |
| 385 | } |
| 386 | |
Junio C Hamano | ee425e4 | 2007-11-18 01:13:32 -0800 | [diff] [blame] | 387 | int report_path_error(const char *ps_matched, const char **pathspec, int prefix_offset) |
| 388 | { |
| 389 | /* |
| 390 | * Make sure all pathspec matched; otherwise it is an error. |
| 391 | */ |
| 392 | int num, errors = 0; |
| 393 | for (num = 0; pathspec[num]; num++) { |
| 394 | int other, found_dup; |
| 395 | |
| 396 | if (ps_matched[num]) |
| 397 | continue; |
| 398 | /* |
| 399 | * The caller might have fed identical pathspec |
| 400 | * twice. Do not barf on such a mistake. |
| 401 | */ |
| 402 | for (found_dup = other = 0; |
| 403 | !found_dup && pathspec[other]; |
| 404 | other++) { |
| 405 | if (other == num || !ps_matched[other]) |
| 406 | continue; |
| 407 | if (!strcmp(pathspec[other], pathspec[num])) |
| 408 | /* |
| 409 | * Ok, we have a match already. |
| 410 | */ |
| 411 | found_dup = 1; |
| 412 | } |
| 413 | if (found_dup) |
| 414 | continue; |
| 415 | |
| 416 | error("pathspec '%s' did not match any file(s) known to git.", |
| 417 | pathspec[num] + prefix_offset); |
| 418 | errors++; |
| 419 | } |
| 420 | return errors; |
| 421 | } |
| 422 | |
Petr Baudis | 4d1f119 | 2005-07-29 11:01:26 +0200 | [diff] [blame] | 423 | static const char ls_files_usage[] = |
Junio C Hamano | 8bb2e03 | 2006-02-12 01:47:57 -0800 | [diff] [blame] | 424 | "git-ls-files [-z] [-t] [-v] (--[cached|deleted|others|stage|unmerged|killed|modified])* " |
Junio C Hamano | f87f949 | 2005-07-24 15:26:09 -0700 | [diff] [blame] | 425 | "[ --ignored ] [--exclude=<pattern>] [--exclude-from=<file>] " |
Jeff King | 8e7b07c | 2007-11-15 02:04:30 -0500 | [diff] [blame] | 426 | "[ --exclude-per-directory=<filename> ] [--exclude-standard] " |
| 427 | "[--full-name] [--abbrev] [--] [<file>]*"; |
Nicolas Pitre | cf9a113 | 2005-04-28 15:06:25 -0700 | [diff] [blame] | 428 | |
Linus Torvalds | a633fca | 2006-07-28 22:44:25 -0700 | [diff] [blame] | 429 | int cmd_ls_files(int argc, const char **argv, const char *prefix) |
Linus Torvalds | 8695c8b | 2005-04-11 18:55:38 -0700 | [diff] [blame] | 430 | { |
| 431 | int i; |
Johannes Schindelin | 6d9ba67 | 2007-01-23 13:30:20 +0100 | [diff] [blame] | 432 | int exc_given = 0, require_work_tree = 0; |
Linus Torvalds | 453ec4b | 2006-05-16 19:02:14 -0700 | [diff] [blame] | 433 | struct dir_struct dir; |
Linus Torvalds | 8695c8b | 2005-04-11 18:55:38 -0700 | [diff] [blame] | 434 | |
Linus Torvalds | 453ec4b | 2006-05-16 19:02:14 -0700 | [diff] [blame] | 435 | memset(&dir, 0, sizeof(dir)); |
Linus Torvalds | 5be4efb | 2005-08-21 12:55:33 -0700 | [diff] [blame] | 436 | if (prefix) |
Linus Torvalds | 56fc510 | 2005-08-21 17:27:50 -0700 | [diff] [blame] | 437 | prefix_offset = strlen(prefix); |
Alex Riesen | 39b4ac9 | 2005-11-08 09:23:37 +0100 | [diff] [blame] | 438 | git_config(git_default_config); |
Linus Torvalds | 5be4efb | 2005-08-21 12:55:33 -0700 | [diff] [blame] | 439 | |
Linus Torvalds | 8695c8b | 2005-04-11 18:55:38 -0700 | [diff] [blame] | 440 | for (i = 1; i < argc; i++) { |
Junio C Hamano | 6b5ee13 | 2005-09-21 00:00:47 -0700 | [diff] [blame] | 441 | const char *arg = argv[i]; |
Linus Torvalds | 8695c8b | 2005-04-11 18:55:38 -0700 | [diff] [blame] | 442 | |
Fredrik Kuivinen | 500b97e | 2005-10-02 17:33:38 +0200 | [diff] [blame] | 443 | if (!strcmp(arg, "--")) { |
| 444 | i++; |
| 445 | break; |
| 446 | } |
Junio C Hamano | b83c834 | 2005-04-15 11:11:01 -0700 | [diff] [blame] | 447 | if (!strcmp(arg, "-z")) { |
| 448 | line_terminator = 0; |
Linus Torvalds | 5be4efb | 2005-08-21 12:55:33 -0700 | [diff] [blame] | 449 | continue; |
| 450 | } |
Junio C Hamano | 8bb2e03 | 2006-02-12 01:47:57 -0800 | [diff] [blame] | 451 | if (!strcmp(arg, "-t") || !strcmp(arg, "-v")) { |
Petr Baudis | 20d37ef | 2005-04-21 19:47:08 -0700 | [diff] [blame] | 452 | tag_cached = "H "; |
| 453 | tag_unmerged = "M "; |
| 454 | tag_removed = "R "; |
Junio C Hamano | b039189 | 2005-09-19 15:11:15 -0700 | [diff] [blame] | 455 | tag_modified = "C "; |
Petr Baudis | 20d37ef | 2005-04-21 19:47:08 -0700 | [diff] [blame] | 456 | tag_other = "? "; |
Junio C Hamano | 6ca4594 | 2005-05-12 17:17:54 -0700 | [diff] [blame] | 457 | tag_killed = "K "; |
Junio C Hamano | 8bb2e03 | 2006-02-12 01:47:57 -0800 | [diff] [blame] | 458 | if (arg[1] == 'v') |
| 459 | show_valid_bit = 1; |
Linus Torvalds | 5be4efb | 2005-08-21 12:55:33 -0700 | [diff] [blame] | 460 | continue; |
| 461 | } |
| 462 | if (!strcmp(arg, "-c") || !strcmp(arg, "--cached")) { |
Linus Torvalds | 8695c8b | 2005-04-11 18:55:38 -0700 | [diff] [blame] | 463 | show_cached = 1; |
Linus Torvalds | 5be4efb | 2005-08-21 12:55:33 -0700 | [diff] [blame] | 464 | continue; |
| 465 | } |
| 466 | if (!strcmp(arg, "-d") || !strcmp(arg, "--deleted")) { |
Linus Torvalds | 8695c8b | 2005-04-11 18:55:38 -0700 | [diff] [blame] | 467 | show_deleted = 1; |
Linus Torvalds | 5be4efb | 2005-08-21 12:55:33 -0700 | [diff] [blame] | 468 | continue; |
| 469 | } |
Junio C Hamano | b039189 | 2005-09-19 15:11:15 -0700 | [diff] [blame] | 470 | if (!strcmp(arg, "-m") || !strcmp(arg, "--modified")) { |
| 471 | show_modified = 1; |
Johannes Schindelin | 6d9ba67 | 2007-01-23 13:30:20 +0100 | [diff] [blame] | 472 | require_work_tree = 1; |
Junio C Hamano | b039189 | 2005-09-19 15:11:15 -0700 | [diff] [blame] | 473 | continue; |
| 474 | } |
Linus Torvalds | 5be4efb | 2005-08-21 12:55:33 -0700 | [diff] [blame] | 475 | if (!strcmp(arg, "-o") || !strcmp(arg, "--others")) { |
Linus Torvalds | 8695c8b | 2005-04-11 18:55:38 -0700 | [diff] [blame] | 476 | show_others = 1; |
Johannes Schindelin | 6d9ba67 | 2007-01-23 13:30:20 +0100 | [diff] [blame] | 477 | require_work_tree = 1; |
Linus Torvalds | 5be4efb | 2005-08-21 12:55:33 -0700 | [diff] [blame] | 478 | continue; |
| 479 | } |
| 480 | if (!strcmp(arg, "-i") || !strcmp(arg, "--ignored")) { |
Linus Torvalds | 453ec4b | 2006-05-16 19:02:14 -0700 | [diff] [blame] | 481 | dir.show_ignored = 1; |
Johannes Schindelin | 6d9ba67 | 2007-01-23 13:30:20 +0100 | [diff] [blame] | 482 | require_work_tree = 1; |
Linus Torvalds | 5be4efb | 2005-08-21 12:55:33 -0700 | [diff] [blame] | 483 | continue; |
| 484 | } |
| 485 | if (!strcmp(arg, "-s") || !strcmp(arg, "--stage")) { |
Junio C Hamano | aee4619 | 2005-04-16 08:33:23 -0700 | [diff] [blame] | 486 | show_stage = 1; |
Linus Torvalds | 5be4efb | 2005-08-21 12:55:33 -0700 | [diff] [blame] | 487 | continue; |
| 488 | } |
| 489 | if (!strcmp(arg, "-k") || !strcmp(arg, "--killed")) { |
Junio C Hamano | 6ca4594 | 2005-05-12 17:17:54 -0700 | [diff] [blame] | 490 | show_killed = 1; |
Johannes Schindelin | 6d9ba67 | 2007-01-23 13:30:20 +0100 | [diff] [blame] | 491 | require_work_tree = 1; |
Linus Torvalds | 5be4efb | 2005-08-21 12:55:33 -0700 | [diff] [blame] | 492 | continue; |
| 493 | } |
Linus Torvalds | 9518eb2 | 2006-01-04 13:31:25 -0800 | [diff] [blame] | 494 | if (!strcmp(arg, "--directory")) { |
Linus Torvalds | 453ec4b | 2006-05-16 19:02:14 -0700 | [diff] [blame] | 495 | dir.show_other_directories = 1; |
Linus Torvalds | 9518eb2 | 2006-01-04 13:31:25 -0800 | [diff] [blame] | 496 | continue; |
| 497 | } |
Petr Baudis | b0a3de4 | 2006-03-26 16:59:52 +0200 | [diff] [blame] | 498 | if (!strcmp(arg, "--no-empty-directory")) { |
Linus Torvalds | 453ec4b | 2006-05-16 19:02:14 -0700 | [diff] [blame] | 499 | dir.hide_empty_directories = 1; |
Petr Baudis | b0a3de4 | 2006-03-26 16:59:52 +0200 | [diff] [blame] | 500 | continue; |
| 501 | } |
Linus Torvalds | 5be4efb | 2005-08-21 12:55:33 -0700 | [diff] [blame] | 502 | if (!strcmp(arg, "-u") || !strcmp(arg, "--unmerged")) { |
Petr Baudis | 20d37ef | 2005-04-21 19:47:08 -0700 | [diff] [blame] | 503 | /* There's no point in showing unmerged unless |
| 504 | * you also show the stage information. |
| 505 | */ |
Linus Torvalds | eec8c63 | 2005-04-16 12:43:32 -0700 | [diff] [blame] | 506 | show_stage = 1; |
| 507 | show_unmerged = 1; |
Linus Torvalds | 5be4efb | 2005-08-21 12:55:33 -0700 | [diff] [blame] | 508 | continue; |
| 509 | } |
| 510 | if (!strcmp(arg, "-x") && i+1 < argc) { |
Junio C Hamano | fee8825 | 2005-07-28 23:32:20 -0700 | [diff] [blame] | 511 | exc_given = 1; |
Linus Torvalds | 453ec4b | 2006-05-16 19:02:14 -0700 | [diff] [blame] | 512 | add_exclude(argv[++i], "", 0, &dir.exclude_list[EXC_CMDL]); |
Linus Torvalds | 5be4efb | 2005-08-21 12:55:33 -0700 | [diff] [blame] | 513 | continue; |
| 514 | } |
Junio C Hamano | cc44c76 | 2007-02-20 01:53:29 -0800 | [diff] [blame] | 515 | if (!prefixcmp(arg, "--exclude=")) { |
Junio C Hamano | fee8825 | 2005-07-28 23:32:20 -0700 | [diff] [blame] | 516 | exc_given = 1; |
Linus Torvalds | 453ec4b | 2006-05-16 19:02:14 -0700 | [diff] [blame] | 517 | add_exclude(arg+10, "", 0, &dir.exclude_list[EXC_CMDL]); |
Linus Torvalds | 5be4efb | 2005-08-21 12:55:33 -0700 | [diff] [blame] | 518 | continue; |
| 519 | } |
| 520 | if (!strcmp(arg, "-X") && i+1 < argc) { |
Junio C Hamano | fee8825 | 2005-07-28 23:32:20 -0700 | [diff] [blame] | 521 | exc_given = 1; |
Linus Torvalds | 453ec4b | 2006-05-16 19:02:14 -0700 | [diff] [blame] | 522 | add_excludes_from_file(&dir, argv[++i]); |
Linus Torvalds | 5be4efb | 2005-08-21 12:55:33 -0700 | [diff] [blame] | 523 | continue; |
| 524 | } |
Junio C Hamano | cc44c76 | 2007-02-20 01:53:29 -0800 | [diff] [blame] | 525 | if (!prefixcmp(arg, "--exclude-from=")) { |
Junio C Hamano | fee8825 | 2005-07-28 23:32:20 -0700 | [diff] [blame] | 526 | exc_given = 1; |
Linus Torvalds | 453ec4b | 2006-05-16 19:02:14 -0700 | [diff] [blame] | 527 | add_excludes_from_file(&dir, arg+15); |
Linus Torvalds | 5be4efb | 2005-08-21 12:55:33 -0700 | [diff] [blame] | 528 | continue; |
| 529 | } |
Junio C Hamano | cc44c76 | 2007-02-20 01:53:29 -0800 | [diff] [blame] | 530 | if (!prefixcmp(arg, "--exclude-per-directory=")) { |
Junio C Hamano | fee8825 | 2005-07-28 23:32:20 -0700 | [diff] [blame] | 531 | exc_given = 1; |
Linus Torvalds | 453ec4b | 2006-05-16 19:02:14 -0700 | [diff] [blame] | 532 | dir.exclude_per_dir = arg + 24; |
Linus Torvalds | 5be4efb | 2005-08-21 12:55:33 -0700 | [diff] [blame] | 533 | continue; |
| 534 | } |
Jeff King | 8e7b07c | 2007-11-15 02:04:30 -0500 | [diff] [blame] | 535 | if (!strcmp(arg, "--exclude-standard")) { |
| 536 | exc_given = 1; |
| 537 | setup_standard_excludes(&dir); |
| 538 | continue; |
| 539 | } |
Linus Torvalds | 5be4efb | 2005-08-21 12:55:33 -0700 | [diff] [blame] | 540 | if (!strcmp(arg, "--full-name")) { |
| 541 | prefix_offset = 0; |
| 542 | continue; |
| 543 | } |
Junio C Hamano | bba319b | 2006-02-14 12:40:20 -0800 | [diff] [blame] | 544 | if (!strcmp(arg, "--error-unmatch")) { |
| 545 | error_unmatch = 1; |
| 546 | continue; |
| 547 | } |
Junio C Hamano | 64586e7 | 2007-09-12 16:04:22 -0700 | [diff] [blame] | 548 | if (!prefixcmp(arg, "--with-tree=")) { |
| 549 | with_tree = arg + 12; |
| 550 | continue; |
| 551 | } |
Junio C Hamano | cc44c76 | 2007-02-20 01:53:29 -0800 | [diff] [blame] | 552 | if (!prefixcmp(arg, "--abbrev=")) { |
Eric Wong | ad0cae4 | 2006-03-07 11:59:17 -0800 | [diff] [blame] | 553 | abbrev = strtoul(arg+9, NULL, 10); |
| 554 | if (abbrev && abbrev < MINIMUM_ABBREV) |
| 555 | abbrev = MINIMUM_ABBREV; |
| 556 | else if (abbrev > 40) |
| 557 | abbrev = 40; |
| 558 | continue; |
| 559 | } |
| 560 | if (!strcmp(arg, "--abbrev")) { |
| 561 | abbrev = DEFAULT_ABBREV; |
| 562 | continue; |
| 563 | } |
Linus Torvalds | 56fc510 | 2005-08-21 17:27:50 -0700 | [diff] [blame] | 564 | if (*arg == '-') |
Nicolas Pitre | 1771039 | 2005-04-30 13:59:38 -0700 | [diff] [blame] | 565 | usage(ls_files_usage); |
Linus Torvalds | 56fc510 | 2005-08-21 17:27:50 -0700 | [diff] [blame] | 566 | break; |
Nicolas Pitre | 9ff768e | 2005-04-28 11:44:04 -0700 | [diff] [blame] | 567 | } |
| 568 | |
Mike Hommey | 7d8ae93 | 2007-11-03 12:23:12 +0100 | [diff] [blame] | 569 | if (require_work_tree && !is_inside_work_tree()) |
| 570 | setup_work_tree(); |
Johannes Schindelin | 6d9ba67 | 2007-01-23 13:30:20 +0100 | [diff] [blame] | 571 | |
Linus Torvalds | 56fc510 | 2005-08-21 17:27:50 -0700 | [diff] [blame] | 572 | pathspec = get_pathspec(prefix, argv + i); |
| 573 | |
| 574 | /* Verify that the pathspec matches the prefix */ |
| 575 | if (pathspec) |
Linus Torvalds | 3e04228 | 2006-07-31 13:13:55 -0700 | [diff] [blame] | 576 | prefix = verify_pathspec(prefix); |
Linus Torvalds | 5be4efb | 2005-08-21 12:55:33 -0700 | [diff] [blame] | 577 | |
Junio C Hamano | bba319b | 2006-02-14 12:40:20 -0800 | [diff] [blame] | 578 | /* Treat unmatching pathspec elements as errors */ |
| 579 | if (pathspec && error_unmatch) { |
| 580 | int num; |
| 581 | for (num = 0; pathspec[num]; num++) |
| 582 | ; |
| 583 | ps_matched = xcalloc(1, num); |
| 584 | } |
| 585 | |
Linus Torvalds | 453ec4b | 2006-05-16 19:02:14 -0700 | [diff] [blame] | 586 | if (dir.show_ignored && !exc_given) { |
Petr Baudis | 20d37ef | 2005-04-21 19:47:08 -0700 | [diff] [blame] | 587 | fprintf(stderr, "%s: --ignored needs some exclude pattern\n", |
| 588 | argv[0]); |
Nicolas Pitre | 9ff768e | 2005-04-28 11:44:04 -0700 | [diff] [blame] | 589 | exit(1); |
Linus Torvalds | 8695c8b | 2005-04-11 18:55:38 -0700 | [diff] [blame] | 590 | } |
| 591 | |
| 592 | /* With no flags, we default to showing the cached files */ |
Junio C Hamano | b039189 | 2005-09-19 15:11:15 -0700 | [diff] [blame] | 593 | if (!(show_stage | show_deleted | show_others | show_unmerged | |
| 594 | show_killed | show_modified)) |
Linus Torvalds | 8695c8b | 2005-04-11 18:55:38 -0700 | [diff] [blame] | 595 | show_cached = 1; |
| 596 | |
| 597 | read_cache(); |
Linus Torvalds | 5be4efb | 2005-08-21 12:55:33 -0700 | [diff] [blame] | 598 | if (prefix) |
Linus Torvalds | 3e04228 | 2006-07-31 13:13:55 -0700 | [diff] [blame] | 599 | prune_cache(prefix); |
Junio C Hamano | 64586e7 | 2007-09-12 16:04:22 -0700 | [diff] [blame] | 600 | if (with_tree) { |
| 601 | /* |
| 602 | * Basic sanity check; show-stages and show-unmerged |
| 603 | * would not make any sense with this option. |
| 604 | */ |
| 605 | if (show_stage || show_unmerged) |
| 606 | die("ls-files --with-tree is incompatible with -s or -u"); |
Junio C Hamano | ee425e4 | 2007-11-18 01:13:32 -0800 | [diff] [blame] | 607 | overlay_tree_on_cache(with_tree, prefix); |
Junio C Hamano | 64586e7 | 2007-09-12 16:04:22 -0700 | [diff] [blame] | 608 | } |
Linus Torvalds | 3e04228 | 2006-07-31 13:13:55 -0700 | [diff] [blame] | 609 | show_files(&dir, prefix); |
Junio C Hamano | bba319b | 2006-02-14 12:40:20 -0800 | [diff] [blame] | 610 | |
| 611 | if (ps_matched) { |
Junio C Hamano | ee425e4 | 2007-11-18 01:13:32 -0800 | [diff] [blame] | 612 | int bad; |
| 613 | bad = report_path_error(ps_matched, pathspec, prefix_offset); |
| 614 | if (bad) |
Andreas Ericsson | ced7b82 | 2006-11-30 12:28:28 +0100 | [diff] [blame] | 615 | fprintf(stderr, "Did you forget to 'git add'?\n"); |
| 616 | |
Junio C Hamano | ee425e4 | 2007-11-18 01:13:32 -0800 | [diff] [blame] | 617 | return bad ? 1 : 0; |
Junio C Hamano | bba319b | 2006-02-14 12:40:20 -0800 | [diff] [blame] | 618 | } |
| 619 | |
Linus Torvalds | 8695c8b | 2005-04-11 18:55:38 -0700 | [diff] [blame] | 620 | return 0; |
| 621 | } |