~ubuntu-branches/ubuntu/intrepid/git-core/intrepid-security

« back to all changes in this revision

Viewing changes to revision.c

  • Committer: Package Import Robot
  • Author(s): Gerrit Pape
  • Date: 2007-10-04 08:27:01 UTC
  • mfrom: (1.1.23)
  • Revision ID: package-import@ubuntu.com-20071004082701-rsd058ontoqz4i30
Tags: 1:1.5.3.4-1
new upstream point release (closes: #445188).

Show diffs side-by-side

added added

removed removed

Lines of Context:
114
114
        }
115
115
}
116
116
 
117
 
void add_pending_object(struct rev_info *revs, struct object *obj, const char *name)
118
 
{
119
 
        add_pending_object_with_mode(revs, obj, name, S_IFINVALID);
120
 
}
121
 
 
122
 
void add_pending_object_with_mode(struct rev_info *revs, struct object *obj, const char *name, unsigned mode)
 
117
static void add_pending_object_with_mode(struct rev_info *revs, struct object *obj, const char *name, unsigned mode)
123
118
{
124
119
        if (revs->no_walk && (obj->flags & UNINTERESTING))
125
120
                die("object ranges do not make sense when not walking revisions");
 
121
        if (revs->reflog_info && obj->type == OBJ_COMMIT &&
 
122
                        add_reflog_for_walk(revs->reflog_info,
 
123
                                (struct commit *)obj, name))
 
124
                return;
126
125
        add_object_array_with_mode(obj, name, &revs->pending, mode);
127
 
        if (revs->reflog_info && obj->type == OBJ_COMMIT)
128
 
                add_reflog_for_walk(revs->reflog_info,
129
 
                                (struct commit *)obj, name);
 
126
}
 
127
 
 
128
void add_pending_object(struct rev_info *revs, struct object *obj, const char *name)
 
129
{
 
130
        add_pending_object_with_mode(revs, obj, name, S_IFINVALID);
130
131
}
131
132
 
132
133
static struct object *get_reference(struct rev_info *revs, const char *name, const unsigned char *sha1, unsigned int flags)
262
263
        options->has_changes = 1;
263
264
}
264
265
 
265
 
int rev_compare_tree(struct rev_info *revs, struct tree *t1, struct tree *t2)
 
266
static int rev_compare_tree(struct rev_info *revs, struct tree *t1, struct tree *t2)
266
267
{
267
268
        if (!t1)
268
269
                return REV_TREE_NEW;
276
277
        return tree_difference;
277
278
}
278
279
 
279
 
int rev_same_tree_as_empty(struct rev_info *revs, struct tree *t1)
 
280
static int rev_same_tree_as_empty(struct rev_info *revs, struct tree *t1)
280
281
{
281
282
        int retval;
282
283
        void *tree;
437
438
        return 0;
438
439
}
439
440
 
440
 
static void cherry_pick_list(struct commit_list *list)
 
441
static void cherry_pick_list(struct commit_list *list, struct rev_info *revs)
441
442
{
442
443
        struct commit_list *p;
443
444
        int left_count = 0, right_count = 0;
458
459
 
459
460
        left_first = left_count < right_count;
460
461
        init_patch_ids(&ids);
 
462
        if (revs->diffopt.nr_paths) {
 
463
                ids.diffopts.nr_paths = revs->diffopt.nr_paths;
 
464
                ids.diffopts.paths = revs->diffopt.paths;
 
465
                ids.diffopts.pathlens = revs->diffopt.pathlens;
 
466
        }
461
467
 
462
468
        /* Compute patch-ids for one side */
463
469
        for (p = list; p; p = p->next) {
546
552
                p = &commit_list_insert(commit, p)->next;
547
553
        }
548
554
        if (revs->cherry_pick)
549
 
                cherry_pick_list(newlist);
 
555
                cherry_pick_list(newlist, revs);
550
556
 
551
557
        revs->commits = newlist;
552
558
        return 0;
667
673
        revs->min_age = -1;
668
674
        revs->skip_count = -1;
669
675
        revs->max_count = -1;
670
 
        revs->subject_prefix = "PATCH";
671
676
 
672
677
        revs->prune_fn = NULL;
673
678
        revs->prune_data = NULL;
881
886
        const char **unrecognized = argv + 1;
882
887
        int left = 1;
883
888
        int all_match = 0;
 
889
        int regflags = 0;
884
890
 
885
891
        /* First, search for "--" */
886
892
        seen_dashdash = 0;
890
896
                        continue;
891
897
                argv[i] = NULL;
892
898
                argc = i;
893
 
                revs->prune_data = get_pathspec(revs->prefix, argv + i + 1);
 
899
                if (argv[i + 1])
 
900
                        revs->prune_data = get_pathspec(revs->prefix, argv + i + 1);
894
901
                seen_dashdash = 1;
895
902
                break;
896
903
        }
1017
1024
                        }
1018
1025
                        if (!strcmp(arg, "--cherry-pick")) {
1019
1026
                                revs->cherry_pick = 1;
 
1027
                                revs->limited = 1;
1020
1028
                                continue;
1021
1029
                        }
1022
1030
                        if (!strcmp(arg, "--objects")) {
1128
1136
                        if (!strncmp(arg, "--date=", 7)) {
1129
1137
                                if (!strcmp(arg + 7, "relative"))
1130
1138
                                        revs->date_mode = DATE_RELATIVE;
 
1139
                                else if (!strcmp(arg + 7, "iso8601") ||
 
1140
                                         !strcmp(arg + 7, "iso"))
 
1141
                                        revs->date_mode = DATE_ISO8601;
 
1142
                                else if (!strcmp(arg + 7, "rfc2822") ||
 
1143
                                         !strcmp(arg + 7, "rfc"))
 
1144
                                        revs->date_mode = DATE_RFC2822;
 
1145
                                else if (!strcmp(arg + 7, "short"))
 
1146
                                        revs->date_mode = DATE_SHORT;
1131
1147
                                else if (!strcmp(arg + 7, "local"))
1132
1148
                                        revs->date_mode = DATE_LOCAL;
1133
1149
                                else if (!strcmp(arg + 7, "default"))
1136
1152
                                        die("unknown date format %s", arg);
1137
1153
                                continue;
1138
1154
                        }
 
1155
                        if (!strcmp(arg, "--log-size")) {
 
1156
                                revs->show_log_size = 1;
 
1157
                                continue;
 
1158
                        }
1139
1159
 
1140
1160
                        /*
1141
1161
                         * Grepping the commit log
1152
1172
                                add_message_grep(revs, arg+7);
1153
1173
                                continue;
1154
1174
                        }
 
1175
                        if (!strcmp(arg, "--extended-regexp") ||
 
1176
                            !strcmp(arg, "-E")) {
 
1177
                                regflags |= REG_EXTENDED;
 
1178
                                continue;
 
1179
                        }
 
1180
                        if (!strcmp(arg, "--regexp-ignore-case") ||
 
1181
                            !strcmp(arg, "-i")) {
 
1182
                                regflags |= REG_ICASE;
 
1183
                                continue;
 
1184
                        }
1155
1185
                        if (!strcmp(arg, "--all-match")) {
1156
1186
                                all_match = 1;
1157
1187
                                continue;
1168
1198
                                revs->reverse ^= 1;
1169
1199
                                continue;
1170
1200
                        }
 
1201
                        if (!strcmp(arg, "--no-walk")) {
 
1202
                                revs->no_walk = 1;
 
1203
                                continue;
 
1204
                        }
 
1205
                        if (!strcmp(arg, "--do-walk")) {
 
1206
                                revs->no_walk = 0;
 
1207
                                continue;
 
1208
                        }
1171
1209
 
1172
1210
                        opts = diff_opt_parse(&revs->diffopt, argv+i, argc-i);
1173
1211
                        if (opts > 0) {
1174
 
                                if (strcmp(argv[i], "-z"))
1175
 
                                        revs->diff = 1;
1176
1212
                                i += opts - 1;
1177
1213
                                continue;
1178
1214
                        }
1201
1237
                }
1202
1238
        }
1203
1239
 
 
1240
        if (revs->grep_filter)
 
1241
                revs->grep_filter->regflags |= regflags;
 
1242
 
1204
1243
        if (show_merge)
1205
1244
                prepare_show_merge(revs);
1206
1245
        if (def && !revs->pending.nr) {
1213
1252
                add_pending_object_with_mode(revs, object, def, mode);
1214
1253
        }
1215
1254
 
 
1255
        /* Did the user ask for any diff output? Run the diff! */
 
1256
        if (revs->diffopt.output_format & ~DIFF_FORMAT_NO_OUTPUT)
 
1257
                revs->diff = 1;
 
1258
 
 
1259
        /* Pickaxe needs diffs */
 
1260
        if (revs->diffopt.pickaxe)
 
1261
                revs->diff = 1;
 
1262
 
1216
1263
        if (revs->topo_order)
1217
1264
                revs->limited = 1;
1218
1265
 
1219
1266
        if (revs->prune_data) {
1220
1267
                diff_tree_setup_paths(revs->prune_data, &revs->pruning);
1221
 
                revs->prune_fn = try_to_simplify_commit;
 
1268
                /* Can't prune commits with rename following: the paths change.. */
 
1269
                if (!revs->diffopt.follow_renames)
 
1270
                        revs->prune_fn = try_to_simplify_commit;
1222
1271
                if (!revs->full_diff)
1223
1272
                        diff_tree_setup_paths(revs->prune_data, &revs->diffopt);
1224
1273
        }
1236
1285
                compile_grep_patterns(revs->grep_filter);
1237
1286
        }
1238
1287
 
 
1288
        if (revs->reverse && revs->reflog_info)
 
1289
                die("cannot combine --reverse with --walk-reflogs");
 
1290
 
1239
1291
        return left;
1240
1292
}
1241
1293
 
1295
1347
        }
1296
1348
}
1297
1349
 
 
1350
static void remove_duplicate_parents(struct commit *commit)
 
1351
{
 
1352
        struct commit_list **pp, *p;
 
1353
 
 
1354
        /* Examine existing parents while marking ones we have seen... */
 
1355
        pp = &commit->parents;
 
1356
        while ((p = *pp) != NULL) {
 
1357
                struct commit *parent = p->item;
 
1358
                if (parent->object.flags & TMP_MARK) {
 
1359
                        *pp = p->next;
 
1360
                        continue;
 
1361
                }
 
1362
                parent->object.flags |= TMP_MARK;
 
1363
                pp = &p->next;
 
1364
        }
 
1365
        /* ... and clear the temporary mark */
 
1366
        for (p = commit->parents; p; p = p->next)
 
1367
                p->item->object.flags &= ~TMP_MARK;
 
1368
}
 
1369
 
1298
1370
static int rewrite_parents(struct rev_info *revs, struct commit *commit)
1299
1371
{
1300
1372
        struct commit_list **pp = &commit->parents;
1311
1383
                }
1312
1384
                pp = &parent->next;
1313
1385
        }
 
1386
        remove_duplicate_parents(commit);
1314
1387
        return 0;
1315
1388
}
1316
1389