Linus Torvalds | 70827b1 | 2006-04-21 10:27:34 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Builtin "git log" and related commands (show, whatchanged) |
| 3 | * |
| 4 | * (C) Copyright 2006 Linus Torvalds |
| 5 | * 2006 Junio Hamano |
| 6 | */ |
| 7 | #include "cache.h" |
| 8 | #include "commit.h" |
| 9 | #include "diff.h" |
| 10 | #include "revision.h" |
| 11 | #include "log-tree.h" |
Junio C Hamano | 91efcf6 | 2006-04-21 13:19:58 -0700 | [diff] [blame] | 12 | #include "builtin.h" |
Johannes Schindelin | 5d7eeee | 2006-12-14 11:31:05 +0100 | [diff] [blame] | 13 | #include "tag.h" |
Linus Torvalds | cf39f54 | 2007-02-08 09:51:56 -0800 | [diff] [blame] | 14 | #include "reflog-walk.h" |
Junio C Hamano | 5d23e13 | 2007-04-09 17:01:27 -0700 | [diff] [blame] | 15 | #include "patch-ids.h" |
Linus Torvalds | ca135e7 | 2007-04-16 16:05:10 -0700 | [diff] [blame] | 16 | #include "refs.h" |
Linus Torvalds | 70827b1 | 2006-04-21 10:27:34 -0700 | [diff] [blame] | 17 | |
Peter Baumann | 0f03ca9 | 2006-11-23 10:36:33 +0100 | [diff] [blame] | 18 | static int default_show_root = 1; |
Alex Riesen | d54276f | 2007-07-04 12:37:27 +0200 | [diff] [blame] | 19 | static const char *fmt_patch_subject_prefix = "PATCH"; |
Peter Baumann | 0f03ca9 | 2006-11-23 10:36:33 +0100 | [diff] [blame] | 20 | |
Linus Torvalds | ca135e7 | 2007-04-16 16:05:10 -0700 | [diff] [blame] | 21 | static void add_name_decoration(const char *prefix, const char *name, struct object *obj) |
| 22 | { |
| 23 | int plen = strlen(prefix); |
| 24 | int nlen = strlen(name); |
| 25 | struct name_decoration *res = xmalloc(sizeof(struct name_decoration) + plen + nlen); |
| 26 | memcpy(res->name, prefix, plen); |
| 27 | memcpy(res->name + plen, name, nlen + 1); |
| 28 | res->next = add_decoration(&name_decoration, obj, res); |
| 29 | } |
| 30 | |
| 31 | static int add_ref_decoration(const char *refname, const unsigned char *sha1, int flags, void *cb_data) |
| 32 | { |
| 33 | struct object *obj = parse_object(sha1); |
| 34 | if (!obj) |
| 35 | return 0; |
| 36 | add_name_decoration("", refname, obj); |
| 37 | while (obj->type == OBJ_TAG) { |
| 38 | obj = ((struct tag *)obj)->tagged; |
| 39 | if (!obj) |
| 40 | break; |
| 41 | add_name_decoration("tag: ", refname, obj); |
| 42 | } |
| 43 | return 0; |
| 44 | } |
| 45 | |
Linus Torvalds | a633fca | 2006-07-28 22:44:25 -0700 | [diff] [blame] | 46 | static void cmd_log_init(int argc, const char **argv, const char *prefix, |
Linus Torvalds | 70827b1 | 2006-04-21 10:27:34 -0700 | [diff] [blame] | 47 | struct rev_info *rev) |
| 48 | { |
Junio C Hamano | 52883fb | 2006-12-25 11:48:35 -0800 | [diff] [blame] | 49 | int i; |
Linus Torvalds | ca135e7 | 2007-04-16 16:05:10 -0700 | [diff] [blame] | 50 | int decorate = 0; |
Junio C Hamano | 52883fb | 2006-12-25 11:48:35 -0800 | [diff] [blame] | 51 | |
Linus Torvalds | 70827b1 | 2006-04-21 10:27:34 -0700 | [diff] [blame] | 52 | rev->abbrev = DEFAULT_ABBREV; |
| 53 | rev->commit_format = CMIT_FMT_DEFAULT; |
| 54 | rev->verbose_header = 1; |
Pierre Habouzit | 8f67f8a | 2007-11-10 20:05:14 +0100 | [diff] [blame] | 55 | DIFF_OPT_SET(&rev->diffopt, RECURSIVE); |
Peter Baumann | 0f03ca9 | 2006-11-23 10:36:33 +0100 | [diff] [blame] | 56 | rev->show_root_diff = default_show_root; |
Alex Riesen | d54276f | 2007-07-04 12:37:27 +0200 | [diff] [blame] | 57 | rev->subject_prefix = fmt_patch_subject_prefix; |
Linus Torvalds | 70827b1 | 2006-04-21 10:27:34 -0700 | [diff] [blame] | 58 | argc = setup_revisions(argc, argv, rev, "HEAD"); |
Timo Hirvonen | 9dafea2 | 2006-06-25 15:39:35 +0300 | [diff] [blame] | 59 | if (rev->diffopt.pickaxe || rev->diffopt.filter) |
| 60 | rev->always_show_header = 0; |
Pierre Habouzit | 8f67f8a | 2007-11-10 20:05:14 +0100 | [diff] [blame] | 61 | if (DIFF_OPT_TST(&rev->diffopt, FOLLOW_RENAMES)) { |
Linus Torvalds | 750f7b6 | 2007-06-19 14:22:46 -0700 | [diff] [blame] | 62 | rev->always_show_header = 0; |
| 63 | if (rev->diffopt.nr_paths != 1) |
| 64 | usage("git logs can only follow renames on one pathname at a time"); |
| 65 | } |
Junio C Hamano | 52883fb | 2006-12-25 11:48:35 -0800 | [diff] [blame] | 66 | for (i = 1; i < argc; i++) { |
| 67 | const char *arg = argv[i]; |
Jeff King | 6668833 | 2007-05-16 07:15:07 -0400 | [diff] [blame] | 68 | if (!strcmp(arg, "--decorate")) { |
Linus Torvalds | ca135e7 | 2007-04-16 16:05:10 -0700 | [diff] [blame] | 69 | if (!decorate) |
| 70 | for_each_ref(add_ref_decoration, NULL); |
| 71 | decorate = 1; |
| 72 | } else |
Junio C Hamano | 52883fb | 2006-12-25 11:48:35 -0800 | [diff] [blame] | 73 | die("unrecognized argument: %s", arg); |
| 74 | } |
Timo Hirvonen | 9dafea2 | 2006-06-25 15:39:35 +0300 | [diff] [blame] | 75 | } |
| 76 | |
Linus Torvalds | 252a7c0 | 2007-11-04 12:12:05 -0800 | [diff] [blame] | 77 | /* |
| 78 | * This gives a rough estimate for how many commits we |
| 79 | * will print out in the list. |
| 80 | */ |
| 81 | static int estimate_commit_count(struct rev_info *rev, struct commit_list *list) |
| 82 | { |
| 83 | int n = 0; |
| 84 | |
| 85 | while (list) { |
| 86 | struct commit *commit = list->item; |
| 87 | unsigned int flags = commit->object.flags; |
Linus Torvalds | 252a7c0 | 2007-11-04 12:12:05 -0800 | [diff] [blame] | 88 | list = list->next; |
Linus Torvalds | 7dc0fe3 | 2007-11-12 23:16:08 -0800 | [diff] [blame] | 89 | if (!(flags & (TREESAME | UNINTERESTING))) |
Linus Torvalds | 53b2c82 | 2007-11-05 13:22:34 -0800 | [diff] [blame] | 90 | n++; |
Linus Torvalds | 252a7c0 | 2007-11-04 12:12:05 -0800 | [diff] [blame] | 91 | } |
| 92 | return n; |
| 93 | } |
| 94 | |
| 95 | static void show_early_header(struct rev_info *rev, const char *stage, int nr) |
| 96 | { |
| 97 | if (rev->shown_one) { |
| 98 | rev->shown_one = 0; |
| 99 | if (rev->commit_format != CMIT_FMT_ONELINE) |
| 100 | putchar(rev->diffopt.line_termination); |
| 101 | } |
| 102 | printf("Final output: %d %s\n", nr, stage); |
| 103 | } |
| 104 | |
| 105 | struct itimerval early_output_timer; |
| 106 | |
Linus Torvalds | cdcefbc | 2007-11-03 11:11:10 -0700 | [diff] [blame] | 107 | static void log_show_early(struct rev_info *revs, struct commit_list *list) |
| 108 | { |
| 109 | int i = revs->early_output; |
Linus Torvalds | 252a7c0 | 2007-11-04 12:12:05 -0800 | [diff] [blame] | 110 | int show_header = 1; |
Linus Torvalds | cdcefbc | 2007-11-03 11:11:10 -0700 | [diff] [blame] | 111 | |
| 112 | sort_in_topological_order(&list, revs->lifo); |
| 113 | while (list && i) { |
| 114 | struct commit *commit = list->item; |
Linus Torvalds | 252a7c0 | 2007-11-04 12:12:05 -0800 | [diff] [blame] | 115 | switch (simplify_commit(revs, commit)) { |
| 116 | case commit_show: |
| 117 | if (show_header) { |
| 118 | int n = estimate_commit_count(revs, list); |
| 119 | show_early_header(revs, "incomplete", n); |
| 120 | show_header = 0; |
| 121 | } |
| 122 | log_tree_commit(revs, commit); |
| 123 | i--; |
| 124 | break; |
| 125 | case commit_ignore: |
| 126 | break; |
| 127 | case commit_error: |
| 128 | return; |
| 129 | } |
Linus Torvalds | cdcefbc | 2007-11-03 11:11:10 -0700 | [diff] [blame] | 130 | list = list->next; |
Linus Torvalds | cdcefbc | 2007-11-03 11:11:10 -0700 | [diff] [blame] | 131 | } |
Linus Torvalds | 252a7c0 | 2007-11-04 12:12:05 -0800 | [diff] [blame] | 132 | |
| 133 | /* Did we already get enough commits for the early output? */ |
| 134 | if (!i) |
| 135 | return; |
| 136 | |
| 137 | /* |
| 138 | * ..if no, then repeat it twice a second until we |
| 139 | * do. |
| 140 | * |
| 141 | * NOTE! We don't use "it_interval", because if the |
| 142 | * reader isn't listening, we want our output to be |
| 143 | * throttled by the writing, and not have the timer |
| 144 | * trigger every second even if we're blocked on a |
| 145 | * reader! |
| 146 | */ |
| 147 | early_output_timer.it_value.tv_sec = 0; |
| 148 | early_output_timer.it_value.tv_usec = 500000; |
| 149 | setitimer(ITIMER_REAL, &early_output_timer, NULL); |
Linus Torvalds | cdcefbc | 2007-11-03 11:11:10 -0700 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | static void early_output(int signal) |
| 153 | { |
| 154 | show_early_output = log_show_early; |
| 155 | } |
| 156 | |
| 157 | static void setup_early_output(struct rev_info *rev) |
| 158 | { |
| 159 | struct sigaction sa; |
Linus Torvalds | cdcefbc | 2007-11-03 11:11:10 -0700 | [diff] [blame] | 160 | |
| 161 | /* |
| 162 | * Set up the signal handler, minimally intrusively: |
| 163 | * we only set a single volatile integer word (not |
| 164 | * using sigatomic_t - trying to avoid unnecessary |
| 165 | * system dependencies and headers), and using |
| 166 | * SA_RESTART. |
| 167 | */ |
| 168 | memset(&sa, 0, sizeof(sa)); |
| 169 | sa.sa_handler = early_output; |
| 170 | sigemptyset(&sa.sa_mask); |
| 171 | sa.sa_flags = SA_RESTART; |
| 172 | sigaction(SIGALRM, &sa, NULL); |
| 173 | |
| 174 | /* |
| 175 | * If we can get the whole output in less than a |
| 176 | * tenth of a second, don't even bother doing the |
| 177 | * early-output thing.. |
| 178 | * |
| 179 | * This is a one-time-only trigger. |
| 180 | */ |
Linus Torvalds | 252a7c0 | 2007-11-04 12:12:05 -0800 | [diff] [blame] | 181 | early_output_timer.it_value.tv_sec = 0; |
| 182 | early_output_timer.it_value.tv_usec = 100000; |
| 183 | setitimer(ITIMER_REAL, &early_output_timer, NULL); |
Linus Torvalds | cdcefbc | 2007-11-03 11:11:10 -0700 | [diff] [blame] | 184 | } |
| 185 | |
| 186 | static void finish_early_output(struct rev_info *rev) |
| 187 | { |
Linus Torvalds | 252a7c0 | 2007-11-04 12:12:05 -0800 | [diff] [blame] | 188 | int n = estimate_commit_count(rev, rev->commits); |
Linus Torvalds | cdcefbc | 2007-11-03 11:11:10 -0700 | [diff] [blame] | 189 | signal(SIGALRM, SIG_IGN); |
Linus Torvalds | 252a7c0 | 2007-11-04 12:12:05 -0800 | [diff] [blame] | 190 | show_early_header(rev, "done", n); |
Linus Torvalds | cdcefbc | 2007-11-03 11:11:10 -0700 | [diff] [blame] | 191 | } |
| 192 | |
Timo Hirvonen | 9dafea2 | 2006-06-25 15:39:35 +0300 | [diff] [blame] | 193 | static int cmd_log_walk(struct rev_info *rev) |
| 194 | { |
| 195 | struct commit *commit; |
Linus Torvalds | 70827b1 | 2006-04-21 10:27:34 -0700 | [diff] [blame] | 196 | |
Linus Torvalds | cdcefbc | 2007-11-03 11:11:10 -0700 | [diff] [blame] | 197 | if (rev->early_output) |
| 198 | setup_early_output(rev); |
| 199 | |
Linus Torvalds | 70827b1 | 2006-04-21 10:27:34 -0700 | [diff] [blame] | 200 | prepare_revision_walk(rev); |
Linus Torvalds | cdcefbc | 2007-11-03 11:11:10 -0700 | [diff] [blame] | 201 | |
| 202 | if (rev->early_output) |
| 203 | finish_early_output(rev); |
| 204 | |
Linus Torvalds | 70827b1 | 2006-04-21 10:27:34 -0700 | [diff] [blame] | 205 | while ((commit = get_revision(rev)) != NULL) { |
| 206 | log_tree_commit(rev, commit); |
Johannes Schindelin | a6c7306 | 2007-01-20 22:28:16 +0100 | [diff] [blame] | 207 | if (!rev->reflog_info) { |
| 208 | /* we allow cycles in reflog ancestry */ |
| 209 | free(commit->buffer); |
| 210 | commit->buffer = NULL; |
| 211 | } |
Linus Torvalds | cb11574 | 2006-06-17 18:47:58 -0700 | [diff] [blame] | 212 | free_commit_list(commit->parents); |
| 213 | commit->parents = NULL; |
Linus Torvalds | 70827b1 | 2006-04-21 10:27:34 -0700 | [diff] [blame] | 214 | } |
| 215 | return 0; |
| 216 | } |
| 217 | |
Peter Baumann | 0f03ca9 | 2006-11-23 10:36:33 +0100 | [diff] [blame] | 218 | static int git_log_config(const char *var, const char *value) |
| 219 | { |
Alex Riesen | d54276f | 2007-07-04 12:37:27 +0200 | [diff] [blame] | 220 | if (!strcmp(var, "format.subjectprefix")) { |
| 221 | if (!value) |
| 222 | die("format.subjectprefix without value"); |
| 223 | fmt_patch_subject_prefix = xstrdup(value); |
| 224 | return 0; |
| 225 | } |
Peter Baumann | 0f03ca9 | 2006-11-23 10:36:33 +0100 | [diff] [blame] | 226 | if (!strcmp(var, "log.showroot")) { |
| 227 | default_show_root = git_config_bool(var, value); |
| 228 | return 0; |
| 229 | } |
| 230 | return git_diff_ui_config(var, value); |
| 231 | } |
| 232 | |
Linus Torvalds | a633fca | 2006-07-28 22:44:25 -0700 | [diff] [blame] | 233 | int cmd_whatchanged(int argc, const char **argv, const char *prefix) |
Linus Torvalds | 70827b1 | 2006-04-21 10:27:34 -0700 | [diff] [blame] | 234 | { |
| 235 | struct rev_info rev; |
| 236 | |
Peter Baumann | 0f03ca9 | 2006-11-23 10:36:33 +0100 | [diff] [blame] | 237 | git_config(git_log_config); |
Linus Torvalds | db6296a | 2006-07-28 21:21:48 -0700 | [diff] [blame] | 238 | init_revisions(&rev, prefix); |
Linus Torvalds | 70827b1 | 2006-04-21 10:27:34 -0700 | [diff] [blame] | 239 | rev.diff = 1; |
Linus Torvalds | 9202434 | 2006-06-11 10:57:35 -0700 | [diff] [blame] | 240 | rev.simplify_history = 0; |
Linus Torvalds | a633fca | 2006-07-28 22:44:25 -0700 | [diff] [blame] | 241 | cmd_log_init(argc, argv, prefix, &rev); |
Timo Hirvonen | 9dafea2 | 2006-06-25 15:39:35 +0300 | [diff] [blame] | 242 | if (!rev.diffopt.output_format) |
| 243 | rev.diffopt.output_format = DIFF_FORMAT_RAW; |
| 244 | return cmd_log_walk(&rev); |
Linus Torvalds | 70827b1 | 2006-04-21 10:27:34 -0700 | [diff] [blame] | 245 | } |
| 246 | |
Johannes Schindelin | 56122ed | 2007-12-18 18:01:33 +0000 | [diff] [blame] | 247 | static void show_tagger(char *buf, int len, struct rev_info *rev) |
| 248 | { |
| 249 | char *email_end, *p; |
| 250 | unsigned long date; |
| 251 | int tz; |
| 252 | |
| 253 | email_end = memchr(buf, '>', len); |
| 254 | if (!email_end) |
| 255 | return; |
| 256 | p = ++email_end; |
| 257 | while (isspace(*p)) |
| 258 | p++; |
| 259 | date = strtoul(p, &p, 10); |
| 260 | while (isspace(*p)) |
| 261 | p++; |
| 262 | tz = (int)strtol(p, NULL, 10); |
| 263 | printf("Tagger: %.*s\nDate: %s\n", (int)(email_end - buf), buf, |
| 264 | show_date(date, tz, rev->date_mode)); |
| 265 | } |
| 266 | |
| 267 | static int show_object(const unsigned char *sha1, int show_tag_object, |
| 268 | struct rev_info *rev) |
Johannes Schindelin | 5d7eeee | 2006-12-14 11:31:05 +0100 | [diff] [blame] | 269 | { |
| 270 | unsigned long size; |
Nicolas Pitre | 21666f1 | 2007-02-26 14:55:59 -0500 | [diff] [blame] | 271 | enum object_type type; |
| 272 | char *buf = read_sha1_file(sha1, &type, &size); |
Johannes Schindelin | 5d7eeee | 2006-12-14 11:31:05 +0100 | [diff] [blame] | 273 | int offset = 0; |
| 274 | |
| 275 | if (!buf) |
| 276 | return error("Could not read object %s", sha1_to_hex(sha1)); |
| 277 | |
Johannes Schindelin | 56122ed | 2007-12-18 18:01:33 +0000 | [diff] [blame] | 278 | if (show_tag_object) |
| 279 | while (offset < size && buf[offset] != '\n') { |
| 280 | int new_offset = offset + 1; |
Johannes Schindelin | 5d7eeee | 2006-12-14 11:31:05 +0100 | [diff] [blame] | 281 | while (new_offset < size && buf[new_offset++] != '\n') |
| 282 | ; /* do nothing */ |
Johannes Schindelin | 56122ed | 2007-12-18 18:01:33 +0000 | [diff] [blame] | 283 | if (!prefixcmp(buf + offset, "tagger ")) |
| 284 | show_tagger(buf + offset + 7, |
| 285 | new_offset - offset - 7, rev); |
Johannes Schindelin | 5d7eeee | 2006-12-14 11:31:05 +0100 | [diff] [blame] | 286 | offset = new_offset; |
| 287 | } |
| 288 | |
| 289 | if (offset < size) |
| 290 | fwrite(buf + offset, size - offset, 1, stdout); |
| 291 | free(buf); |
| 292 | return 0; |
| 293 | } |
| 294 | |
| 295 | static int show_tree_object(const unsigned char *sha1, |
| 296 | const char *base, int baselen, |
| 297 | const char *pathname, unsigned mode, int stage) |
| 298 | { |
| 299 | printf("%s%s\n", pathname, S_ISDIR(mode) ? "/" : ""); |
| 300 | return 0; |
| 301 | } |
| 302 | |
Linus Torvalds | a633fca | 2006-07-28 22:44:25 -0700 | [diff] [blame] | 303 | int cmd_show(int argc, const char **argv, const char *prefix) |
Linus Torvalds | 70827b1 | 2006-04-21 10:27:34 -0700 | [diff] [blame] | 304 | { |
| 305 | struct rev_info rev; |
Johannes Schindelin | 5d7eeee | 2006-12-14 11:31:05 +0100 | [diff] [blame] | 306 | struct object_array_entry *objects; |
| 307 | int i, count, ret = 0; |
Linus Torvalds | 70827b1 | 2006-04-21 10:27:34 -0700 | [diff] [blame] | 308 | |
Peter Baumann | 0f03ca9 | 2006-11-23 10:36:33 +0100 | [diff] [blame] | 309 | git_config(git_log_config); |
Linus Torvalds | db6296a | 2006-07-28 21:21:48 -0700 | [diff] [blame] | 310 | init_revisions(&rev, prefix); |
Linus Torvalds | 70827b1 | 2006-04-21 10:27:34 -0700 | [diff] [blame] | 311 | rev.diff = 1; |
Linus Torvalds | 70827b1 | 2006-04-21 10:27:34 -0700 | [diff] [blame] | 312 | rev.combine_merges = 1; |
| 313 | rev.dense_combined_merges = 1; |
| 314 | rev.always_show_header = 1; |
| 315 | rev.ignore_merges = 0; |
| 316 | rev.no_walk = 1; |
Linus Torvalds | a633fca | 2006-07-28 22:44:25 -0700 | [diff] [blame] | 317 | cmd_log_init(argc, argv, prefix, &rev); |
Johannes Schindelin | 5d7eeee | 2006-12-14 11:31:05 +0100 | [diff] [blame] | 318 | |
| 319 | count = rev.pending.nr; |
| 320 | objects = rev.pending.objects; |
| 321 | for (i = 0; i < count && !ret; i++) { |
| 322 | struct object *o = objects[i].item; |
| 323 | const char *name = objects[i].name; |
| 324 | switch (o->type) { |
| 325 | case OBJ_BLOB: |
Johannes Schindelin | 56122ed | 2007-12-18 18:01:33 +0000 | [diff] [blame] | 326 | ret = show_object(o->sha1, 0, NULL); |
Johannes Schindelin | 5d7eeee | 2006-12-14 11:31:05 +0100 | [diff] [blame] | 327 | break; |
| 328 | case OBJ_TAG: { |
| 329 | struct tag *t = (struct tag *)o; |
| 330 | |
Johannes Schindelin | 56122ed | 2007-12-18 18:01:33 +0000 | [diff] [blame] | 331 | printf("%stag %s%s\n", |
Pierre Habouzit | 8f67f8a | 2007-11-10 20:05:14 +0100 | [diff] [blame] | 332 | diff_get_color_opt(&rev.diffopt, DIFF_COMMIT), |
Johannes Schindelin | 5d7eeee | 2006-12-14 11:31:05 +0100 | [diff] [blame] | 333 | t->tag, |
Pierre Habouzit | 8f67f8a | 2007-11-10 20:05:14 +0100 | [diff] [blame] | 334 | diff_get_color_opt(&rev.diffopt, DIFF_RESET)); |
Johannes Schindelin | 56122ed | 2007-12-18 18:01:33 +0000 | [diff] [blame] | 335 | ret = show_object(o->sha1, 1, &rev); |
Johannes Schindelin | 5d7eeee | 2006-12-14 11:31:05 +0100 | [diff] [blame] | 336 | objects[i].item = (struct object *)t->tagged; |
| 337 | i--; |
| 338 | break; |
| 339 | } |
| 340 | case OBJ_TREE: |
| 341 | printf("%stree %s%s\n\n", |
Pierre Habouzit | 8f67f8a | 2007-11-10 20:05:14 +0100 | [diff] [blame] | 342 | diff_get_color_opt(&rev.diffopt, DIFF_COMMIT), |
Johannes Schindelin | 5d7eeee | 2006-12-14 11:31:05 +0100 | [diff] [blame] | 343 | name, |
Pierre Habouzit | 8f67f8a | 2007-11-10 20:05:14 +0100 | [diff] [blame] | 344 | diff_get_color_opt(&rev.diffopt, DIFF_RESET)); |
Johannes Schindelin | 5d7eeee | 2006-12-14 11:31:05 +0100 | [diff] [blame] | 345 | read_tree_recursive((struct tree *)o, "", 0, 0, NULL, |
| 346 | show_tree_object); |
| 347 | break; |
| 348 | case OBJ_COMMIT: |
| 349 | rev.pending.nr = rev.pending.alloc = 0; |
| 350 | rev.pending.objects = NULL; |
| 351 | add_object_array(o, name, &rev.pending); |
| 352 | ret = cmd_log_walk(&rev); |
| 353 | break; |
| 354 | default: |
| 355 | ret = error("Unknown type: %d", o->type); |
| 356 | } |
| 357 | } |
| 358 | free(objects); |
| 359 | return ret; |
Linus Torvalds | 70827b1 | 2006-04-21 10:27:34 -0700 | [diff] [blame] | 360 | } |
| 361 | |
Linus Torvalds | cf39f54 | 2007-02-08 09:51:56 -0800 | [diff] [blame] | 362 | /* |
| 363 | * This is equivalent to "git log -g --abbrev-commit --pretty=oneline" |
| 364 | */ |
| 365 | int cmd_log_reflog(int argc, const char **argv, const char *prefix) |
| 366 | { |
| 367 | struct rev_info rev; |
| 368 | |
| 369 | git_config(git_log_config); |
| 370 | init_revisions(&rev, prefix); |
| 371 | init_reflog_walk(&rev.reflog_info); |
| 372 | rev.abbrev_commit = 1; |
| 373 | rev.verbose_header = 1; |
| 374 | cmd_log_init(argc, argv, prefix, &rev); |
| 375 | |
| 376 | /* |
| 377 | * This means that we override whatever commit format the user gave |
| 378 | * on the cmd line. Sad, but cmd_log_init() currently doesn't |
| 379 | * allow us to set a different default. |
| 380 | */ |
| 381 | rev.commit_format = CMIT_FMT_ONELINE; |
| 382 | rev.always_show_header = 1; |
| 383 | |
| 384 | /* |
| 385 | * We get called through "git reflog", so unlike the other log |
| 386 | * routines, we need to set up our pager manually.. |
| 387 | */ |
| 388 | setup_pager(); |
| 389 | |
| 390 | return cmd_log_walk(&rev); |
| 391 | } |
| 392 | |
Linus Torvalds | a633fca | 2006-07-28 22:44:25 -0700 | [diff] [blame] | 393 | int cmd_log(int argc, const char **argv, const char *prefix) |
Linus Torvalds | 70827b1 | 2006-04-21 10:27:34 -0700 | [diff] [blame] | 394 | { |
| 395 | struct rev_info rev; |
| 396 | |
Peter Baumann | 0f03ca9 | 2006-11-23 10:36:33 +0100 | [diff] [blame] | 397 | git_config(git_log_config); |
Linus Torvalds | db6296a | 2006-07-28 21:21:48 -0700 | [diff] [blame] | 398 | init_revisions(&rev, prefix); |
Linus Torvalds | 70827b1 | 2006-04-21 10:27:34 -0700 | [diff] [blame] | 399 | rev.always_show_header = 1; |
Linus Torvalds | a633fca | 2006-07-28 22:44:25 -0700 | [diff] [blame] | 400 | cmd_log_init(argc, argv, prefix, &rev); |
Timo Hirvonen | 9dafea2 | 2006-06-25 15:39:35 +0300 | [diff] [blame] | 401 | return cmd_log_walk(&rev); |
Linus Torvalds | 70827b1 | 2006-04-21 10:27:34 -0700 | [diff] [blame] | 402 | } |
Junio C Hamano | 91efcf6 | 2006-04-21 13:19:58 -0700 | [diff] [blame] | 403 | |
Robin Rosenberg | c06d2da | 2007-02-23 23:27:58 +0100 | [diff] [blame] | 404 | /* format-patch */ |
| 405 | #define FORMAT_PATCH_NAME_MAX 64 |
| 406 | |
Johannes Schindelin | 0377db7 | 2006-05-05 01:16:40 +0200 | [diff] [blame] | 407 | static int istitlechar(char c) |
| 408 | { |
| 409 | return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || |
| 410 | (c >= '0' && c <= '9') || c == '.' || c == '_'; |
| 411 | } |
| 412 | |
Johannes Schindelin | 20ff068 | 2006-06-02 15:21:17 +0200 | [diff] [blame] | 413 | static char *extra_headers = NULL; |
| 414 | static int extra_headers_size = 0; |
Junio C Hamano | 917a8f8 | 2007-01-17 15:03:39 -0800 | [diff] [blame] | 415 | static const char *fmt_patch_suffix = ".patch"; |
Brian Gernhardt | 49604a4 | 2007-11-03 23:38:24 -0400 | [diff] [blame] | 416 | static int numbered = 0; |
| 417 | static int auto_number = 0; |
Johannes Schindelin | 20ff068 | 2006-06-02 15:21:17 +0200 | [diff] [blame] | 418 | |
| 419 | static int git_format_config(const char *var, const char *value) |
| 420 | { |
| 421 | if (!strcmp(var, "format.headers")) { |
Junio C Hamano | d7fb91c | 2007-01-17 11:13:02 -0800 | [diff] [blame] | 422 | int len; |
| 423 | |
| 424 | if (!value) |
| 425 | die("format.headers without value"); |
| 426 | len = strlen(value); |
Johannes Schindelin | 20ff068 | 2006-06-02 15:21:17 +0200 | [diff] [blame] | 427 | extra_headers_size += len + 1; |
Jonas Fonseca | 83572c1 | 2006-08-26 16:16:18 +0200 | [diff] [blame] | 428 | extra_headers = xrealloc(extra_headers, extra_headers_size); |
Johannes Schindelin | 20ff068 | 2006-06-02 15:21:17 +0200 | [diff] [blame] | 429 | extra_headers[extra_headers_size - len - 1] = 0; |
| 430 | strcat(extra_headers, value); |
| 431 | return 0; |
| 432 | } |
Junio C Hamano | 03eeaea | 2007-01-17 11:12:03 -0800 | [diff] [blame] | 433 | if (!strcmp(var, "format.suffix")) { |
| 434 | if (!value) |
| 435 | die("format.suffix without value"); |
| 436 | fmt_patch_suffix = xstrdup(value); |
| 437 | return 0; |
| 438 | } |
Andy Parkins | a159ca0 | 2006-12-13 09:13:28 +0000 | [diff] [blame] | 439 | if (!strcmp(var, "diff.color") || !strcmp(var, "color.diff")) { |
Ryan Anderson | f3aafa4 | 2006-07-09 02:28:21 -0400 | [diff] [blame] | 440 | return 0; |
| 441 | } |
Brian Gernhardt | 49604a4 | 2007-11-03 23:38:24 -0400 | [diff] [blame] | 442 | if (!strcmp(var, "format.numbered")) { |
| 443 | if (!strcasecmp(value, "auto")) { |
| 444 | auto_number = 1; |
| 445 | return 0; |
| 446 | } |
| 447 | |
| 448 | numbered = git_config_bool(var, value); |
| 449 | return 0; |
| 450 | } |
Adam Roben | dbd2144 | 2007-07-01 17:48:59 -0700 | [diff] [blame] | 451 | |
Peter Baumann | 0f03ca9 | 2006-11-23 10:36:33 +0100 | [diff] [blame] | 452 | return git_log_config(var, value); |
Johannes Schindelin | 20ff068 | 2006-06-02 15:21:17 +0200 | [diff] [blame] | 453 | } |
| 454 | |
| 455 | |
Johannes Schindelin | 81f3a18 | 2006-05-05 03:33:05 +0200 | [diff] [blame] | 456 | static FILE *realstdout = NULL; |
Junio C Hamano | efd0201 | 2006-06-06 08:46:23 -0700 | [diff] [blame] | 457 | static const char *output_directory = NULL; |
Johannes Schindelin | 81f3a18 | 2006-05-05 03:33:05 +0200 | [diff] [blame] | 458 | |
Jon Loeliger | e6ff0f4 | 2007-06-05 15:06:53 -0500 | [diff] [blame] | 459 | static int reopen_stdout(struct commit *commit, int nr, int keep_subject, |
| 460 | int numbered_files) |
Johannes Schindelin | 0377db7 | 2006-05-05 01:16:40 +0200 | [diff] [blame] | 461 | { |
Robin Rosenberg | c06d2da | 2007-02-23 23:27:58 +0100 | [diff] [blame] | 462 | char filename[PATH_MAX]; |
Johannes Schindelin | 0377db7 | 2006-05-05 01:16:40 +0200 | [diff] [blame] | 463 | char *sol; |
Johannes Schindelin | 2448482 | 2006-05-05 03:33:32 +0200 | [diff] [blame] | 464 | int len = 0; |
Robin Rosenberg | c06d2da | 2007-02-23 23:27:58 +0100 | [diff] [blame] | 465 | int suffix_len = strlen(fmt_patch_suffix) + 1; |
Johannes Schindelin | 0377db7 | 2006-05-05 01:16:40 +0200 | [diff] [blame] | 466 | |
Johannes Schindelin | 2448482 | 2006-05-05 03:33:32 +0200 | [diff] [blame] | 467 | if (output_directory) { |
Robin Rosenberg | c06d2da | 2007-02-23 23:27:58 +0100 | [diff] [blame] | 468 | if (strlen(output_directory) >= |
| 469 | sizeof(filename) - FORMAT_PATCH_NAME_MAX - suffix_len) |
| 470 | return error("name of output directory is too long"); |
| 471 | strlcpy(filename, output_directory, sizeof(filename) - suffix_len); |
Johannes Schindelin | 2448482 | 2006-05-05 03:33:32 +0200 | [diff] [blame] | 472 | len = strlen(filename); |
| 473 | if (filename[len - 1] != '/') |
| 474 | filename[len++] = '/'; |
| 475 | } |
Johannes Schindelin | 0377db7 | 2006-05-05 01:16:40 +0200 | [diff] [blame] | 476 | |
Jon Loeliger | e6ff0f4 | 2007-06-05 15:06:53 -0500 | [diff] [blame] | 477 | if (numbered_files) { |
| 478 | sprintf(filename + len, "%d", nr); |
| 479 | len = strlen(filename); |
Johannes Schindelin | 0377db7 | 2006-05-05 01:16:40 +0200 | [diff] [blame] | 480 | |
Jon Loeliger | e6ff0f4 | 2007-06-05 15:06:53 -0500 | [diff] [blame] | 481 | } else { |
| 482 | sprintf(filename + len, "%04d", nr); |
| 483 | len = strlen(filename); |
Johannes Schindelin | 0377db7 | 2006-05-05 01:16:40 +0200 | [diff] [blame] | 484 | |
Jon Loeliger | e6ff0f4 | 2007-06-05 15:06:53 -0500 | [diff] [blame] | 485 | sol = strstr(commit->buffer, "\n\n"); |
| 486 | if (sol) { |
| 487 | int j, space = 1; |
Johannes Schindelin | 0377db7 | 2006-05-05 01:16:40 +0200 | [diff] [blame] | 488 | |
Jon Loeliger | e6ff0f4 | 2007-06-05 15:06:53 -0500 | [diff] [blame] | 489 | sol += 2; |
| 490 | /* strip [PATCH] or [PATCH blabla] */ |
| 491 | if (!keep_subject && !prefixcmp(sol, "[PATCH")) { |
| 492 | char *eos = strchr(sol + 6, ']'); |
| 493 | if (eos) { |
| 494 | while (isspace(*eos)) |
| 495 | eos++; |
| 496 | sol = eos; |
Johannes Schindelin | 0377db7 | 2006-05-05 01:16:40 +0200 | [diff] [blame] | 497 | } |
Jon Loeliger | e6ff0f4 | 2007-06-05 15:06:53 -0500 | [diff] [blame] | 498 | } |
| 499 | |
| 500 | for (j = 0; |
| 501 | j < FORMAT_PATCH_NAME_MAX - suffix_len - 5 && |
| 502 | len < sizeof(filename) - suffix_len && |
| 503 | sol[j] && sol[j] != '\n'; |
| 504 | j++) { |
| 505 | if (istitlechar(sol[j])) { |
| 506 | if (space) { |
| 507 | filename[len++] = '-'; |
| 508 | space = 0; |
| 509 | } |
| 510 | filename[len++] = sol[j]; |
| 511 | if (sol[j] == '.') |
| 512 | while (sol[j + 1] == '.') |
| 513 | j++; |
| 514 | } else |
| 515 | space = 1; |
| 516 | } |
| 517 | while (filename[len - 1] == '.' |
| 518 | || filename[len - 1] == '-') |
| 519 | len--; |
| 520 | filename[len] = 0; |
Johannes Schindelin | 0377db7 | 2006-05-05 01:16:40 +0200 | [diff] [blame] | 521 | } |
Jon Loeliger | e6ff0f4 | 2007-06-05 15:06:53 -0500 | [diff] [blame] | 522 | if (len + suffix_len >= sizeof(filename)) |
| 523 | return error("Patch pathname too long"); |
| 524 | strcpy(filename + len, fmt_patch_suffix); |
Johannes Schindelin | 0377db7 | 2006-05-05 01:16:40 +0200 | [diff] [blame] | 525 | } |
Jon Loeliger | e6ff0f4 | 2007-06-05 15:06:53 -0500 | [diff] [blame] | 526 | |
Johannes Schindelin | 81f3a18 | 2006-05-05 03:33:05 +0200 | [diff] [blame] | 527 | fprintf(realstdout, "%s\n", filename); |
Robin Rosenberg | c06d2da | 2007-02-23 23:27:58 +0100 | [diff] [blame] | 528 | if (freopen(filename, "w", stdout) == NULL) |
| 529 | return error("Cannot open patch file %s",filename); |
Robin Rosenberg | c06d2da | 2007-02-23 23:27:58 +0100 | [diff] [blame] | 530 | |
Jon Loeliger | e6ff0f4 | 2007-06-05 15:06:53 -0500 | [diff] [blame] | 531 | return 0; |
Johannes Schindelin | 0377db7 | 2006-05-05 01:16:40 +0200 | [diff] [blame] | 532 | } |
| 533 | |
Junio C Hamano | 5d23e13 | 2007-04-09 17:01:27 -0700 | [diff] [blame] | 534 | static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids, const char *prefix) |
Johannes Schindelin | 9c6efa3 | 2006-06-25 03:52:01 +0200 | [diff] [blame] | 535 | { |
| 536 | struct rev_info check_rev; |
| 537 | struct commit *commit; |
| 538 | struct object *o1, *o2; |
| 539 | unsigned flags1, flags2; |
Johannes Schindelin | 9c6efa3 | 2006-06-25 03:52:01 +0200 | [diff] [blame] | 540 | |
| 541 | if (rev->pending.nr != 2) |
| 542 | die("Need exactly one range."); |
| 543 | |
| 544 | o1 = rev->pending.objects[0].item; |
| 545 | flags1 = o1->flags; |
| 546 | o2 = rev->pending.objects[1].item; |
| 547 | flags2 = o2->flags; |
| 548 | |
| 549 | if ((flags1 & UNINTERESTING) == (flags2 & UNINTERESTING)) |
| 550 | die("Not a range."); |
| 551 | |
Junio C Hamano | 5d23e13 | 2007-04-09 17:01:27 -0700 | [diff] [blame] | 552 | init_patch_ids(ids); |
Johannes Schindelin | 9c6efa3 | 2006-06-25 03:52:01 +0200 | [diff] [blame] | 553 | |
| 554 | /* given a range a..b get all patch ids for b..a */ |
Linus Torvalds | db6296a | 2006-07-28 21:21:48 -0700 | [diff] [blame] | 555 | init_revisions(&check_rev, prefix); |
Johannes Schindelin | 9c6efa3 | 2006-06-25 03:52:01 +0200 | [diff] [blame] | 556 | o1->flags ^= UNINTERESTING; |
| 557 | o2->flags ^= UNINTERESTING; |
| 558 | add_pending_object(&check_rev, o1, "o1"); |
| 559 | add_pending_object(&check_rev, o2, "o2"); |
| 560 | prepare_revision_walk(&check_rev); |
| 561 | |
| 562 | while ((commit = get_revision(&check_rev)) != NULL) { |
| 563 | /* ignore merges */ |
| 564 | if (commit->parents && commit->parents->next) |
| 565 | continue; |
| 566 | |
Junio C Hamano | 5d23e13 | 2007-04-09 17:01:27 -0700 | [diff] [blame] | 567 | add_commit_patch_id(commit, ids); |
Johannes Schindelin | 9c6efa3 | 2006-06-25 03:52:01 +0200 | [diff] [blame] | 568 | } |
| 569 | |
| 570 | /* reset for next revision walk */ |
Johannes Schindelin | 81db094 | 2006-06-27 22:38:04 +0200 | [diff] [blame] | 571 | clear_commit_marks((struct commit *)o1, |
| 572 | SEEN | UNINTERESTING | SHOWN | ADDED); |
| 573 | clear_commit_marks((struct commit *)o2, |
| 574 | SEEN | UNINTERESTING | SHOWN | ADDED); |
Johannes Schindelin | 9c6efa3 | 2006-06-25 03:52:01 +0200 | [diff] [blame] | 575 | o1->flags = flags1; |
| 576 | o2->flags = flags2; |
| 577 | } |
| 578 | |
Josh Triplett | d1566f7 | 2006-07-14 17:48:51 -0700 | [diff] [blame] | 579 | static void gen_message_id(char *dest, unsigned int length, char *base) |
| 580 | { |
Junio C Hamano | 774751a | 2007-12-08 17:32:08 -0800 | [diff] [blame] | 581 | const char *committer = git_committer_info(IDENT_WARN_ON_NO_NAME); |
Josh Triplett | d1566f7 | 2006-07-14 17:48:51 -0700 | [diff] [blame] | 582 | const char *email_start = strrchr(committer, '<'); |
| 583 | const char *email_end = strrchr(committer, '>'); |
| 584 | if(!email_start || !email_end || email_start > email_end - 1) |
| 585 | die("Could not extract email from committer identity."); |
Junio C Hamano | 76af073 | 2006-07-14 22:47:53 -0700 | [diff] [blame] | 586 | snprintf(dest, length, "%s.%lu.git.%.*s", base, |
| 587 | (unsigned long) time(NULL), |
| 588 | (int)(email_end - email_start - 1), email_start + 1); |
Josh Triplett | d1566f7 | 2006-07-14 17:48:51 -0700 | [diff] [blame] | 589 | } |
| 590 | |
Junio C Hamano | 8419d2e | 2007-09-13 22:30:45 -0700 | [diff] [blame] | 591 | static const char *clean_message_id(const char *msg_id) |
| 592 | { |
| 593 | char ch; |
| 594 | const char *a, *z, *m; |
Junio C Hamano | 8419d2e | 2007-09-13 22:30:45 -0700 | [diff] [blame] | 595 | |
| 596 | m = msg_id; |
| 597 | while ((ch = *m) && (isspace(ch) || (ch == '<'))) |
| 598 | m++; |
| 599 | a = m; |
| 600 | z = NULL; |
| 601 | while ((ch = *m)) { |
| 602 | if (!isspace(ch) && (ch != '>')) |
| 603 | z = m; |
| 604 | m++; |
| 605 | } |
| 606 | if (!z) |
| 607 | die("insane in-reply-to: %s", msg_id); |
| 608 | if (++z == m) |
| 609 | return a; |
Pierre Habouzit | 182af83 | 2007-09-16 00:32:36 +0200 | [diff] [blame] | 610 | return xmemdupz(a, z - a); |
Junio C Hamano | 8419d2e | 2007-09-13 22:30:45 -0700 | [diff] [blame] | 611 | } |
| 612 | |
Linus Torvalds | a633fca | 2006-07-28 22:44:25 -0700 | [diff] [blame] | 613 | int cmd_format_patch(int argc, const char **argv, const char *prefix) |
Junio C Hamano | 91efcf6 | 2006-04-21 13:19:58 -0700 | [diff] [blame] | 614 | { |
| 615 | struct commit *commit; |
| 616 | struct commit **list = NULL; |
| 617 | struct rev_info rev; |
Johannes Schindelin | 2448482 | 2006-05-05 03:33:32 +0200 | [diff] [blame] | 618 | int nr = 0, total, i, j; |
Johannes Schindelin | 0377db7 | 2006-05-05 01:16:40 +0200 | [diff] [blame] | 619 | int use_stdout = 0; |
Johannes Schindelin | fa0f02d | 2006-05-25 23:55:11 +0200 | [diff] [blame] | 620 | int start_number = -1; |
Johannes Schindelin | 8ac80a5 | 2006-05-05 04:31:29 +0200 | [diff] [blame] | 621 | int keep_subject = 0; |
Jon Loeliger | e6ff0f4 | 2007-06-05 15:06:53 -0500 | [diff] [blame] | 622 | int numbered_files = 0; /* _just_ numbers */ |
Robin H. Johnson | 2d9e4a4 | 2007-04-11 16:58:07 -0700 | [diff] [blame] | 623 | int subject_prefix = 0; |
Johannes Schindelin | 9c6efa3 | 2006-06-25 03:52:01 +0200 | [diff] [blame] | 624 | int ignore_if_in_upstream = 0; |
Josh Triplett | cc35de8 | 2006-07-14 17:49:04 -0700 | [diff] [blame] | 625 | int thread = 0; |
Junio C Hamano | 76af073 | 2006-07-14 22:47:53 -0700 | [diff] [blame] | 626 | const char *in_reply_to = NULL; |
Junio C Hamano | 5d23e13 | 2007-04-09 17:01:27 -0700 | [diff] [blame] | 627 | struct patch_ids ids; |
Junio C Hamano | cf2251b | 2006-05-31 15:11:49 -0700 | [diff] [blame] | 628 | char *add_signoff = NULL; |
Josh Triplett | d1566f7 | 2006-07-14 17:48:51 -0700 | [diff] [blame] | 629 | char message_id[1024]; |
| 630 | char ref_message_id[1024]; |
Junio C Hamano | 91efcf6 | 2006-04-21 13:19:58 -0700 | [diff] [blame] | 631 | |
Eric Wong | 97beb81 | 2006-07-07 03:10:45 -0700 | [diff] [blame] | 632 | git_config(git_format_config); |
Linus Torvalds | db6296a | 2006-07-28 21:21:48 -0700 | [diff] [blame] | 633 | init_revisions(&rev, prefix); |
Junio C Hamano | 91efcf6 | 2006-04-21 13:19:58 -0700 | [diff] [blame] | 634 | rev.commit_format = CMIT_FMT_EMAIL; |
| 635 | rev.verbose_header = 1; |
| 636 | rev.diff = 1; |
Junio C Hamano | 91efcf6 | 2006-04-21 13:19:58 -0700 | [diff] [blame] | 637 | rev.combine_merges = 0; |
| 638 | rev.ignore_merges = 1; |
Junio C Hamano | 27e1b12 | 2006-06-29 00:18:52 -0700 | [diff] [blame] | 639 | rev.diffopt.msg_sep = ""; |
Pierre Habouzit | 8f67f8a | 2007-11-10 20:05:14 +0100 | [diff] [blame] | 640 | DIFF_OPT_SET(&rev.diffopt, RECURSIVE); |
Junio C Hamano | 91efcf6 | 2006-04-21 13:19:58 -0700 | [diff] [blame] | 641 | |
Adam Roben | dbd2144 | 2007-07-01 17:48:59 -0700 | [diff] [blame] | 642 | rev.subject_prefix = fmt_patch_subject_prefix; |
Johannes Schindelin | 20ff068 | 2006-06-02 15:21:17 +0200 | [diff] [blame] | 643 | rev.extra_headers = extra_headers; |
| 644 | |
Johannes Schindelin | 2448482 | 2006-05-05 03:33:32 +0200 | [diff] [blame] | 645 | /* |
| 646 | * Parse the arguments before setup_revisions(), or something |
Frank Lichtenheld | 2dc189a | 2007-05-14 16:44:51 +0200 | [diff] [blame] | 647 | * like "git format-patch -o a123 HEAD^.." may fail; a123 is |
Johannes Schindelin | 2448482 | 2006-05-05 03:33:32 +0200 | [diff] [blame] | 648 | * possibly a valid SHA1. |
| 649 | */ |
| 650 | for (i = 1, j = 1; i < argc; i++) { |
| 651 | if (!strcmp(argv[i], "--stdout")) |
Johannes Schindelin | 0377db7 | 2006-05-05 01:16:40 +0200 | [diff] [blame] | 652 | use_stdout = 1; |
Johannes Schindelin | 596524b | 2006-05-05 04:30:52 +0200 | [diff] [blame] | 653 | else if (!strcmp(argv[i], "-n") || |
| 654 | !strcmp(argv[i], "--numbered")) |
| 655 | numbered = 1; |
Brian Gernhardt | 49604a4 | 2007-11-03 23:38:24 -0400 | [diff] [blame] | 656 | else if (!strcmp(argv[i], "-N") || |
| 657 | !strcmp(argv[i], "--no-numbered")) { |
| 658 | numbered = 0; |
| 659 | auto_number = 0; |
| 660 | } |
Junio C Hamano | cc44c76 | 2007-02-20 01:53:29 -0800 | [diff] [blame] | 661 | else if (!prefixcmp(argv[i], "--start-number=")) |
Johannes Schindelin | fa0f02d | 2006-05-25 23:55:11 +0200 | [diff] [blame] | 662 | start_number = strtol(argv[i] + 15, NULL, 10); |
Jon Loeliger | e6ff0f4 | 2007-06-05 15:06:53 -0500 | [diff] [blame] | 663 | else if (!strcmp(argv[i], "--numbered-files")) |
| 664 | numbered_files = 1; |
Johannes Schindelin | fa0f02d | 2006-05-25 23:55:11 +0200 | [diff] [blame] | 665 | else if (!strcmp(argv[i], "--start-number")) { |
| 666 | i++; |
| 667 | if (i == argc) |
| 668 | die("Need a number for --start-number"); |
| 669 | start_number = strtol(argv[i], NULL, 10); |
Junio C Hamano | cf2251b | 2006-05-31 15:11:49 -0700 | [diff] [blame] | 670 | } |
| 671 | else if (!strcmp(argv[i], "-k") || |
Johannes Schindelin | 8ac80a5 | 2006-05-05 04:31:29 +0200 | [diff] [blame] | 672 | !strcmp(argv[i], "--keep-subject")) { |
| 673 | keep_subject = 1; |
| 674 | rev.total = -1; |
Junio C Hamano | cf2251b | 2006-05-31 15:11:49 -0700 | [diff] [blame] | 675 | } |
Junio C Hamano | efd0201 | 2006-06-06 08:46:23 -0700 | [diff] [blame] | 676 | else if (!strcmp(argv[i], "--output-directory") || |
| 677 | !strcmp(argv[i], "-o")) { |
Johannes Schindelin | 2448482 | 2006-05-05 03:33:32 +0200 | [diff] [blame] | 678 | i++; |
Junio C Hamano | efd0201 | 2006-06-06 08:46:23 -0700 | [diff] [blame] | 679 | if (argc <= i) |
| 680 | die("Which directory?"); |
| 681 | if (output_directory) |
| 682 | die("Two output directories?"); |
| 683 | output_directory = argv[i]; |
Johannes Schindelin | 698ce6f | 2006-05-20 15:40:29 +0200 | [diff] [blame] | 684 | } |
Junio C Hamano | cf2251b | 2006-05-31 15:11:49 -0700 | [diff] [blame] | 685 | else if (!strcmp(argv[i], "--signoff") || |
| 686 | !strcmp(argv[i], "-s")) { |
Eric W. Biederman | 6c4cca1 | 2006-06-12 13:31:38 -0600 | [diff] [blame] | 687 | const char *committer; |
| 688 | const char *endpos; |
Junio C Hamano | 774751a | 2007-12-08 17:32:08 -0800 | [diff] [blame] | 689 | committer = git_committer_info(IDENT_ERROR_ON_NO_NAME); |
Eric W. Biederman | 6c4cca1 | 2006-06-12 13:31:38 -0600 | [diff] [blame] | 690 | endpos = strchr(committer, '>'); |
Junio C Hamano | cf2251b | 2006-05-31 15:11:49 -0700 | [diff] [blame] | 691 | if (!endpos) |
| 692 | die("bogos committer info %s\n", committer); |
Pierre Habouzit | 182af83 | 2007-09-16 00:32:36 +0200 | [diff] [blame] | 693 | add_signoff = xmemdupz(committer, endpos - committer + 1); |
Junio C Hamano | cf2251b | 2006-05-31 15:11:49 -0700 | [diff] [blame] | 694 | } |
Johannes Schindelin | c112f68 | 2007-03-04 00:12:06 +0100 | [diff] [blame] | 695 | else if (!strcmp(argv[i], "--attach")) { |
Johannes Schindelin | 698ce6f | 2006-05-20 15:40:29 +0200 | [diff] [blame] | 696 | rev.mime_boundary = git_version_string; |
Johannes Schindelin | c112f68 | 2007-03-04 00:12:06 +0100 | [diff] [blame] | 697 | rev.no_inline = 1; |
| 698 | } |
| 699 | else if (!prefixcmp(argv[i], "--attach=")) { |
Johannes Schindelin | 698ce6f | 2006-05-20 15:40:29 +0200 | [diff] [blame] | 700 | rev.mime_boundary = argv[i] + 9; |
Johannes Schindelin | c112f68 | 2007-03-04 00:12:06 +0100 | [diff] [blame] | 701 | rev.no_inline = 1; |
| 702 | } |
| 703 | else if (!strcmp(argv[i], "--inline")) { |
| 704 | rev.mime_boundary = git_version_string; |
| 705 | rev.no_inline = 0; |
| 706 | } |
| 707 | else if (!prefixcmp(argv[i], "--inline=")) { |
| 708 | rev.mime_boundary = argv[i] + 9; |
| 709 | rev.no_inline = 0; |
| 710 | } |
Johannes Schindelin | 9c6efa3 | 2006-06-25 03:52:01 +0200 | [diff] [blame] | 711 | else if (!strcmp(argv[i], "--ignore-if-in-upstream")) |
| 712 | ignore_if_in_upstream = 1; |
Josh Triplett | cc35de8 | 2006-07-14 17:49:04 -0700 | [diff] [blame] | 713 | else if (!strcmp(argv[i], "--thread")) |
| 714 | thread = 1; |
Junio C Hamano | cc44c76 | 2007-02-20 01:53:29 -0800 | [diff] [blame] | 715 | else if (!prefixcmp(argv[i], "--in-reply-to=")) |
Josh Triplett | da56645 | 2006-07-14 17:49:08 -0700 | [diff] [blame] | 716 | in_reply_to = argv[i] + 14; |
| 717 | else if (!strcmp(argv[i], "--in-reply-to")) { |
| 718 | i++; |
| 719 | if (i == argc) |
| 720 | die("Need a Message-Id for --in-reply-to"); |
| 721 | in_reply_to = argv[i]; |
Robin H. Johnson | 2d9e4a4 | 2007-04-11 16:58:07 -0700 | [diff] [blame] | 722 | } else if (!prefixcmp(argv[i], "--subject-prefix=")) { |
| 723 | subject_prefix = 1; |
| 724 | rev.subject_prefix = argv[i] + 17; |
| 725 | } else if (!prefixcmp(argv[i], "--suffix=")) |
Junio C Hamano | 03eeaea | 2007-01-17 11:12:03 -0800 | [diff] [blame] | 726 | fmt_patch_suffix = argv[i] + 9; |
Johannes Schindelin | 698ce6f | 2006-05-20 15:40:29 +0200 | [diff] [blame] | 727 | else |
Johannes Schindelin | 2448482 | 2006-05-05 03:33:32 +0200 | [diff] [blame] | 728 | argv[j++] = argv[i]; |
Johannes Schindelin | 0377db7 | 2006-05-05 01:16:40 +0200 | [diff] [blame] | 729 | } |
Johannes Schindelin | 2448482 | 2006-05-05 03:33:32 +0200 | [diff] [blame] | 730 | argc = j; |
| 731 | |
Junio C Hamano | add5c8a | 2006-05-26 11:30:49 -0700 | [diff] [blame] | 732 | if (start_number < 0) |
Johannes Schindelin | fa0f02d | 2006-05-25 23:55:11 +0200 | [diff] [blame] | 733 | start_number = 1; |
Junio C Hamano | 63b398a | 2006-05-28 09:23:29 -0700 | [diff] [blame] | 734 | if (numbered && keep_subject) |
Johannes Schindelin | 8ac80a5 | 2006-05-05 04:31:29 +0200 | [diff] [blame] | 735 | die ("-n and -k are mutually exclusive."); |
Robin H. Johnson | 2d9e4a4 | 2007-04-11 16:58:07 -0700 | [diff] [blame] | 736 | if (keep_subject && subject_prefix) |
| 737 | die ("--subject-prefix and -k are mutually exclusive."); |
Jon Loeliger | e6ff0f4 | 2007-06-05 15:06:53 -0500 | [diff] [blame] | 738 | if (numbered_files && use_stdout) |
| 739 | die ("--numbered-files and --stdout are mutually exclusive."); |
Johannes Schindelin | 8ac80a5 | 2006-05-05 04:31:29 +0200 | [diff] [blame] | 740 | |
Johannes Schindelin | 2448482 | 2006-05-05 03:33:32 +0200 | [diff] [blame] | 741 | argc = setup_revisions(argc, argv, &rev, "HEAD"); |
| 742 | if (argc > 1) |
| 743 | die ("unrecognized argument: %s", argv[1]); |
Johannes Schindelin | 0377db7 | 2006-05-05 01:16:40 +0200 | [diff] [blame] | 744 | |
Timo Hirvonen | c9b5ef9 | 2006-06-24 20:24:14 +0300 | [diff] [blame] | 745 | if (!rev.diffopt.output_format) |
Junio C Hamano | c261e43 | 2007-01-17 13:51:44 -0800 | [diff] [blame] | 746 | rev.diffopt.output_format = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_SUMMARY | DIFF_FORMAT_PATCH; |
Timo Hirvonen | c9b5ef9 | 2006-06-24 20:24:14 +0300 | [diff] [blame] | 747 | |
Pierre Habouzit | 8f67f8a | 2007-11-10 20:05:14 +0100 | [diff] [blame] | 748 | if (!DIFF_OPT_TST(&rev.diffopt, TEXT)) |
| 749 | DIFF_OPT_SET(&rev.diffopt, BINARY); |
Junio C Hamano | e47f306 | 2007-01-17 14:32:52 -0800 | [diff] [blame] | 750 | |
Jeff King | 90f70a9 | 2007-01-22 22:38:28 -0500 | [diff] [blame] | 751 | if (!output_directory && !use_stdout) |
Matthias Lederhofer | 77e565d | 2006-09-28 21:55:35 +0200 | [diff] [blame] | 752 | output_directory = prefix; |
| 753 | |
Junio C Hamano | efd0201 | 2006-06-06 08:46:23 -0700 | [diff] [blame] | 754 | if (output_directory) { |
| 755 | if (use_stdout) |
| 756 | die("standard output, or directory, which one?"); |
| 757 | if (mkdir(output_directory, 0777) < 0 && errno != EEXIST) |
| 758 | die("Could not create directory %s", |
| 759 | output_directory); |
| 760 | } |
| 761 | |
Linus Torvalds | 1f1e895 | 2006-06-19 17:42:35 -0700 | [diff] [blame] | 762 | if (rev.pending.nr == 1) { |
Junio C Hamano | 8a1d076 | 2007-08-28 00:38:48 -0700 | [diff] [blame] | 763 | if (rev.max_count < 0 && !rev.show_root_diff) { |
| 764 | /* |
| 765 | * This is traditional behaviour of "git format-patch |
| 766 | * origin" that prepares what the origin side still |
| 767 | * does not have. |
| 768 | */ |
Junio C Hamano | 7c49628 | 2007-01-17 13:35:13 -0800 | [diff] [blame] | 769 | rev.pending.objects[0].item->flags |= UNINTERESTING; |
Junio C Hamano | 3384a2d | 2007-12-11 10:09:04 -0800 | [diff] [blame] | 770 | add_head_to_pending(&rev); |
Junio C Hamano | 7c49628 | 2007-01-17 13:35:13 -0800 | [diff] [blame] | 771 | } |
Junio C Hamano | 8a1d076 | 2007-08-28 00:38:48 -0700 | [diff] [blame] | 772 | /* |
| 773 | * Otherwise, it is "format-patch -22 HEAD", and/or |
| 774 | * "format-patch --root HEAD". The user wants |
| 775 | * get_revision() to do the usual traversal. |
Junio C Hamano | 7c49628 | 2007-01-17 13:35:13 -0800 | [diff] [blame] | 776 | */ |
Johannes Schindelin | e686eb9 | 2006-05-06 22:56:38 +0200 | [diff] [blame] | 777 | } |
| 778 | |
Johannes Schindelin | 9c6efa3 | 2006-06-25 03:52:01 +0200 | [diff] [blame] | 779 | if (ignore_if_in_upstream) |
Junio C Hamano | 5d23e13 | 2007-04-09 17:01:27 -0700 | [diff] [blame] | 780 | get_patch_ids(&rev, &ids, prefix); |
Johannes Schindelin | 9c6efa3 | 2006-06-25 03:52:01 +0200 | [diff] [blame] | 781 | |
Johannes Schindelin | 81f3a18 | 2006-05-05 03:33:05 +0200 | [diff] [blame] | 782 | if (!use_stdout) |
Jim Meyering | f578825 | 2007-06-27 16:28:53 +0200 | [diff] [blame] | 783 | realstdout = xfdopen(xdup(1), "w"); |
Johannes Schindelin | 81f3a18 | 2006-05-05 03:33:05 +0200 | [diff] [blame] | 784 | |
Junio C Hamano | 91efcf6 | 2006-04-21 13:19:58 -0700 | [diff] [blame] | 785 | prepare_revision_walk(&rev); |
| 786 | while ((commit = get_revision(&rev)) != NULL) { |
Johannes Schindelin | 0377db7 | 2006-05-05 01:16:40 +0200 | [diff] [blame] | 787 | /* ignore merges */ |
| 788 | if (commit->parents && commit->parents->next) |
| 789 | continue; |
Johannes Schindelin | 9c6efa3 | 2006-06-25 03:52:01 +0200 | [diff] [blame] | 790 | |
| 791 | if (ignore_if_in_upstream && |
Junio C Hamano | 5d23e13 | 2007-04-09 17:01:27 -0700 | [diff] [blame] | 792 | has_commit_patch_id(commit, &ids)) |
Johannes Schindelin | 9c6efa3 | 2006-06-25 03:52:01 +0200 | [diff] [blame] | 793 | continue; |
| 794 | |
Junio C Hamano | 91efcf6 | 2006-04-21 13:19:58 -0700 | [diff] [blame] | 795 | nr++; |
Jonas Fonseca | 83572c1 | 2006-08-26 16:16:18 +0200 | [diff] [blame] | 796 | list = xrealloc(list, nr * sizeof(list[0])); |
Junio C Hamano | 91efcf6 | 2006-04-21 13:19:58 -0700 | [diff] [blame] | 797 | list[nr - 1] = commit; |
| 798 | } |
Johannes Schindelin | 0377db7 | 2006-05-05 01:16:40 +0200 | [diff] [blame] | 799 | total = nr; |
Brian Gernhardt | 49604a4 | 2007-11-03 23:38:24 -0400 | [diff] [blame] | 800 | if (!keep_subject && auto_number && total > 1) |
| 801 | numbered = 1; |
Johannes Schindelin | 596524b | 2006-05-05 04:30:52 +0200 | [diff] [blame] | 802 | if (numbered) |
Johannes Schindelin | fa0f02d | 2006-05-25 23:55:11 +0200 | [diff] [blame] | 803 | rev.total = total + start_number - 1; |
Junio C Hamano | cf2251b | 2006-05-31 15:11:49 -0700 | [diff] [blame] | 804 | rev.add_signoff = add_signoff; |
Junio C Hamano | 8419d2e | 2007-09-13 22:30:45 -0700 | [diff] [blame] | 805 | if (in_reply_to) |
| 806 | rev.ref_message_id = clean_message_id(in_reply_to); |
Junio C Hamano | 91efcf6 | 2006-04-21 13:19:58 -0700 | [diff] [blame] | 807 | while (0 <= --nr) { |
| 808 | int shown; |
| 809 | commit = list[nr]; |
Junio C Hamano | add5c8a | 2006-05-26 11:30:49 -0700 | [diff] [blame] | 810 | rev.nr = total - nr + (start_number - 1); |
Josh Triplett | d1566f7 | 2006-07-14 17:48:51 -0700 | [diff] [blame] | 811 | /* Make the second and subsequent mails replies to the first */ |
Josh Triplett | cc35de8 | 2006-07-14 17:49:04 -0700 | [diff] [blame] | 812 | if (thread) { |
| 813 | if (nr == (total - 2)) { |
| 814 | strncpy(ref_message_id, message_id, |
| 815 | sizeof(ref_message_id)); |
| 816 | ref_message_id[sizeof(ref_message_id)-1]='\0'; |
| 817 | rev.ref_message_id = ref_message_id; |
| 818 | } |
| 819 | gen_message_id(message_id, sizeof(message_id), |
| 820 | sha1_to_hex(commit->object.sha1)); |
| 821 | rev.message_id = message_id; |
Josh Triplett | d1566f7 | 2006-07-14 17:48:51 -0700 | [diff] [blame] | 822 | } |
Johannes Schindelin | 0377db7 | 2006-05-05 01:16:40 +0200 | [diff] [blame] | 823 | if (!use_stdout) |
Jon Loeliger | e6ff0f4 | 2007-06-05 15:06:53 -0500 | [diff] [blame] | 824 | if (reopen_stdout(commit, rev.nr, keep_subject, |
| 825 | numbered_files)) |
Robin Rosenberg | c06d2da | 2007-02-23 23:27:58 +0100 | [diff] [blame] | 826 | die("Failed to create output files"); |
Junio C Hamano | 91efcf6 | 2006-04-21 13:19:58 -0700 | [diff] [blame] | 827 | shown = log_tree_commit(&rev, commit); |
| 828 | free(commit->buffer); |
| 829 | commit->buffer = NULL; |
Junio C Hamano | add5c8a | 2006-05-26 11:30:49 -0700 | [diff] [blame] | 830 | |
| 831 | /* We put one extra blank line between formatted |
| 832 | * patches and this flag is used by log-tree code |
| 833 | * to see if it needs to emit a LF before showing |
| 834 | * the log; when using one file per patch, we do |
| 835 | * not want the extra blank line. |
| 836 | */ |
| 837 | if (!use_stdout) |
| 838 | rev.shown_one = 0; |
Johannes Schindelin | 698ce6f | 2006-05-20 15:40:29 +0200 | [diff] [blame] | 839 | if (shown) { |
| 840 | if (rev.mime_boundary) |
| 841 | printf("\n--%s%s--\n\n\n", |
| 842 | mime_boundary_leader, |
| 843 | rev.mime_boundary); |
| 844 | else |
| 845 | printf("-- \n%s\n\n", git_version_string); |
| 846 | } |
Johannes Schindelin | 0377db7 | 2006-05-05 01:16:40 +0200 | [diff] [blame] | 847 | if (!use_stdout) |
| 848 | fclose(stdout); |
Junio C Hamano | 91efcf6 | 2006-04-21 13:19:58 -0700 | [diff] [blame] | 849 | } |
| 850 | free(list); |
Junio C Hamano | 5d23e13 | 2007-04-09 17:01:27 -0700 | [diff] [blame] | 851 | if (ignore_if_in_upstream) |
| 852 | free_patch_ids(&ids); |
Junio C Hamano | 91efcf6 | 2006-04-21 13:19:58 -0700 | [diff] [blame] | 853 | return 0; |
| 854 | } |
| 855 | |
Rene Scharfe | e827633 | 2006-10-24 01:01:57 +0200 | [diff] [blame] | 856 | static int add_pending_commit(const char *arg, struct rev_info *revs, int flags) |
| 857 | { |
| 858 | unsigned char sha1[20]; |
| 859 | if (get_sha1(arg, sha1) == 0) { |
| 860 | struct commit *commit = lookup_commit_reference(sha1); |
| 861 | if (commit) { |
| 862 | commit->object.flags |= flags; |
| 863 | add_pending_object(revs, &commit->object, arg); |
| 864 | return 0; |
| 865 | } |
| 866 | } |
| 867 | return -1; |
| 868 | } |
| 869 | |
| 870 | static const char cherry_usage[] = |
| 871 | "git-cherry [-v] <upstream> [<head>] [<limit>]"; |
| 872 | int cmd_cherry(int argc, const char **argv, const char *prefix) |
| 873 | { |
| 874 | struct rev_info revs; |
Junio C Hamano | 5d23e13 | 2007-04-09 17:01:27 -0700 | [diff] [blame] | 875 | struct patch_ids ids; |
Rene Scharfe | e827633 | 2006-10-24 01:01:57 +0200 | [diff] [blame] | 876 | struct commit *commit; |
| 877 | struct commit_list *list = NULL; |
| 878 | const char *upstream; |
| 879 | const char *head = "HEAD"; |
| 880 | const char *limit = NULL; |
| 881 | int verbose = 0; |
| 882 | |
| 883 | if (argc > 1 && !strcmp(argv[1], "-v")) { |
| 884 | verbose = 1; |
| 885 | argc--; |
| 886 | argv++; |
| 887 | } |
| 888 | |
| 889 | switch (argc) { |
| 890 | case 4: |
| 891 | limit = argv[3]; |
| 892 | /* FALLTHROUGH */ |
| 893 | case 3: |
| 894 | head = argv[2]; |
| 895 | /* FALLTHROUGH */ |
| 896 | case 2: |
| 897 | upstream = argv[1]; |
| 898 | break; |
| 899 | default: |
| 900 | usage(cherry_usage); |
| 901 | } |
| 902 | |
| 903 | init_revisions(&revs, prefix); |
| 904 | revs.diff = 1; |
| 905 | revs.combine_merges = 0; |
| 906 | revs.ignore_merges = 1; |
Pierre Habouzit | 8f67f8a | 2007-11-10 20:05:14 +0100 | [diff] [blame] | 907 | DIFF_OPT_SET(&revs.diffopt, RECURSIVE); |
Rene Scharfe | e827633 | 2006-10-24 01:01:57 +0200 | [diff] [blame] | 908 | |
| 909 | if (add_pending_commit(head, &revs, 0)) |
| 910 | die("Unknown commit %s", head); |
| 911 | if (add_pending_commit(upstream, &revs, UNINTERESTING)) |
| 912 | die("Unknown commit %s", upstream); |
| 913 | |
| 914 | /* Don't say anything if head and upstream are the same. */ |
| 915 | if (revs.pending.nr == 2) { |
| 916 | struct object_array_entry *o = revs.pending.objects; |
| 917 | if (hashcmp(o[0].item->sha1, o[1].item->sha1) == 0) |
| 918 | return 0; |
| 919 | } |
| 920 | |
Junio C Hamano | 5d23e13 | 2007-04-09 17:01:27 -0700 | [diff] [blame] | 921 | get_patch_ids(&revs, &ids, prefix); |
Rene Scharfe | e827633 | 2006-10-24 01:01:57 +0200 | [diff] [blame] | 922 | |
| 923 | if (limit && add_pending_commit(limit, &revs, UNINTERESTING)) |
| 924 | die("Unknown commit %s", limit); |
| 925 | |
| 926 | /* reverse the list of commits */ |
| 927 | prepare_revision_walk(&revs); |
| 928 | while ((commit = get_revision(&revs)) != NULL) { |
| 929 | /* ignore merges */ |
| 930 | if (commit->parents && commit->parents->next) |
| 931 | continue; |
| 932 | |
| 933 | commit_list_insert(commit, &list); |
| 934 | } |
| 935 | |
| 936 | while (list) { |
Rene Scharfe | e827633 | 2006-10-24 01:01:57 +0200 | [diff] [blame] | 937 | char sign = '+'; |
| 938 | |
| 939 | commit = list->item; |
Junio C Hamano | 5d23e13 | 2007-04-09 17:01:27 -0700 | [diff] [blame] | 940 | if (has_commit_patch_id(commit, &ids)) |
Rene Scharfe | e827633 | 2006-10-24 01:01:57 +0200 | [diff] [blame] | 941 | sign = '-'; |
| 942 | |
| 943 | if (verbose) { |
Pierre Habouzit | 674d172 | 2007-09-10 12:35:06 +0200 | [diff] [blame] | 944 | struct strbuf buf; |
| 945 | strbuf_init(&buf, 0); |
| 946 | pretty_print_commit(CMIT_FMT_ONELINE, commit, |
Junio C Hamano | 4593fb8 | 2007-10-31 14:55:17 -0700 | [diff] [blame] | 947 | &buf, 0, NULL, NULL, 0, 0); |
Rene Scharfe | e827633 | 2006-10-24 01:01:57 +0200 | [diff] [blame] | 948 | printf("%c %s %s\n", sign, |
Pierre Habouzit | 674d172 | 2007-09-10 12:35:06 +0200 | [diff] [blame] | 949 | sha1_to_hex(commit->object.sha1), buf.buf); |
| 950 | strbuf_release(&buf); |
Rene Scharfe | e827633 | 2006-10-24 01:01:57 +0200 | [diff] [blame] | 951 | } |
| 952 | else { |
| 953 | printf("%c %s\n", sign, |
| 954 | sha1_to_hex(commit->object.sha1)); |
| 955 | } |
| 956 | |
| 957 | list = list->next; |
| 958 | } |
| 959 | |
Junio C Hamano | 5d23e13 | 2007-04-09 17:01:27 -0700 | [diff] [blame] | 960 | free_patch_ids(&ids); |
Rene Scharfe | e827633 | 2006-10-24 01:01:57 +0200 | [diff] [blame] | 961 | return 0; |
| 962 | } |