grep: recurse in-process using 'struct repository'
Convert grep to use 'struct repository' which enables recursing into submodules to be handled in-process. Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Brandon Williams committed
Aug 2, 2017 at 12:49 UTC
f9ee2fcdfa05586b6a4476c7aa5f4f0162e48455
7 files changed
+88
-344
Documentation/git-grep.txt
-7
@@ -95,13 +95,6 @@ OPTIONS
95
<tree> option the prefix of all submodule output will be the name of
96
the parent project's <tree> object.
97
98
---parent-basename <basename>::
99
- For internal use only. In order to produce uniform output with the
100
- --recurse-submodules option, this option can be used to provide the
101
- basename of a parent's <tree> object to a submodule so the submodule
102
- can prefix its output with the parent's name rather than the SHA1 of
103
- the submodule.
104
-
98
-a::
99
--text::
100
Process binary files as if they were text.
builtin/grep.c
+86
-310
@@ -28,13 +28,7 @@ static char const * const grep_usage[] = {
28
NULL
29
};
30
31
-static const char *super_prefix;
31
static int recurse_submodules;
33
-static struct argv_array submodule_options = ARGV_ARRAY_INIT;
34
-static const char *parent_basename;
35
-
36
-static int grep_submodule_launch(struct grep_opt *opt,
37
- const struct grep_source *gs);
32
33
#define GREP_NUM_THREADS_DEFAULT 8
34
static int num_threads;
@@ -186,10 +180,7 @@ static void *run(void *arg)
180
break;
181
182
opt->output_priv = w;
189
- if (w->source.type == GREP_SOURCE_SUBMODULE)
190
- hit |= grep_submodule_launch(opt, &w->source);
191
- else
192
- hit |= grep_source(opt, &w->source);
183
+ hit |= grep_source(opt, &w->source);
184
grep_source_clear_data(&w->source);
185
work_done(w);
186
}
@@ -327,21 +318,13 @@ static int grep_oid(struct grep_opt *opt, const struct object_id *oid,
318
{
319
struct strbuf pathbuf = STRBUF_INIT;
320
330
- if (super_prefix) {
331
- strbuf_add(&pathbuf, filename, tree_name_len);
332
- strbuf_addstr(&pathbuf, super_prefix);
333
- strbuf_addstr(&pathbuf, filename + tree_name_len);
321
+ if (opt->relative && opt->prefix_length) {
322
+ quote_path_relative(filename + tree_name_len, opt->prefix, &pathbuf);
323
+ strbuf_insert(&pathbuf, 0, filename, tree_name_len);
324
} else {
325
strbuf_addstr(&pathbuf, filename);
326
}
327
338
- if (opt->relative && opt->prefix_length) {
339
- char *name = strbuf_detach(&pathbuf, NULL);
340
- quote_path_relative(name + tree_name_len, opt->prefix, &pathbuf);
341
- strbuf_insert(&pathbuf, 0, name, tree_name_len);
342
- free(name);
343
- }
344
-
328
#ifndef NO_PTHREADS
329
if (num_threads) {
330
add_work(opt, GREP_SOURCE_OID, pathbuf.buf, path, oid);
@@ -366,15 +349,10 @@ static int grep_file(struct grep_opt *opt, const char *filename)
349
{
350
struct strbuf buf = STRBUF_INIT;
351
369
- if (super_prefix)
370
- strbuf_addstr(&buf, super_prefix);
371
- strbuf_addstr(&buf, filename);
372
-
373
- if (opt->relative && opt->prefix_length) {
374
- char *name = strbuf_detach(&buf, NULL);
375
- quote_path_relative(name, opt->prefix, &buf);
376
- free(name);
377
- }
352
+ if (opt->relative && opt->prefix_length)
353
+ quote_path_relative(filename, opt->prefix, &buf);
354
+ else
355
+ strbuf_addstr(&buf, filename);
356
357
#ifndef NO_PTHREADS
358
if (num_threads) {
@@ -421,284 +399,89 @@ static void run_pager(struct grep_opt *opt, const char *prefix)
399
exit(status);
400
}
401
424
-static void compile_submodule_options(const struct grep_opt *opt,
425
- const char **argv,
426
- int cached, int untracked,
427
- int opt_exclude, int use_index,
428
- int pattern_type_arg)
429
-{
430
- struct grep_pat *pattern;
431
-
432
- if (recurse_submodules)
433
- argv_array_push(&submodule_options, "--recurse-submodules");
434
-
435
- if (cached)
436
- argv_array_push(&submodule_options, "--cached");
437
- if (!use_index)
438
- argv_array_push(&submodule_options, "--no-index");
439
- if (untracked)
440
- argv_array_push(&submodule_options, "--untracked");
441
- if (opt_exclude > 0)
442
- argv_array_push(&submodule_options, "--exclude-standard");
443
-
444
- if (opt->invert)
445
- argv_array_push(&submodule_options, "-v");
446
- if (opt->ignore_case)
447
- argv_array_push(&submodule_options, "-i");
448
- if (opt->word_regexp)
449
- argv_array_push(&submodule_options, "-w");
450
- switch (opt->binary) {
451
- case GREP_BINARY_NOMATCH:
452
- argv_array_push(&submodule_options, "-I");
453
- break;
454
- case GREP_BINARY_TEXT:
455
- argv_array_push(&submodule_options, "-a");
456
- break;
457
- default:
458
- break;
459
- }
460
- if (opt->allow_textconv)
461
- argv_array_push(&submodule_options, "--textconv");
462
- if (opt->max_depth != -1)
463
- argv_array_pushf(&submodule_options, "--max-depth=%d",
464
- opt->max_depth);
465
- if (opt->linenum)
466
- argv_array_push(&submodule_options, "-n");
467
- if (!opt->pathname)
468
- argv_array_push(&submodule_options, "-h");
469
- if (!opt->relative)
470
- argv_array_push(&submodule_options, "--full-name");
471
- if (opt->name_only)
472
- argv_array_push(&submodule_options, "-l");
473
- if (opt->unmatch_name_only)
474
- argv_array_push(&submodule_options, "-L");
475
- if (opt->null_following_name)
476
- argv_array_push(&submodule_options, "-z");
477
- if (opt->count)
478
- argv_array_push(&submodule_options, "-c");
479
- if (opt->file_break)
480
- argv_array_push(&submodule_options, "--break");
481
- if (opt->heading)
482
- argv_array_push(&submodule_options, "--heading");
483
- if (opt->pre_context)
484
- argv_array_pushf(&submodule_options, "--before-context=%d",
485
- opt->pre_context);
486
- if (opt->post_context)
487
- argv_array_pushf(&submodule_options, "--after-context=%d",
488
- opt->post_context);
489
- if (opt->funcname)
490
- argv_array_push(&submodule_options, "-p");
491
- if (opt->funcbody)
492
- argv_array_push(&submodule_options, "-W");
493
- if (opt->all_match)
494
- argv_array_push(&submodule_options, "--all-match");
495
- if (opt->debug)
496
- argv_array_push(&submodule_options, "--debug");
497
- if (opt->status_only)
498
- argv_array_push(&submodule_options, "-q");
499
-
500
- switch (pattern_type_arg) {
501
- case GREP_PATTERN_TYPE_BRE:
502
- argv_array_push(&submodule_options, "-G");
503
- break;
504
- case GREP_PATTERN_TYPE_ERE:
505
- argv_array_push(&submodule_options, "-E");
506
- break;
507
- case GREP_PATTERN_TYPE_FIXED:
508
- argv_array_push(&submodule_options, "-F");
509
- break;
510
- case GREP_PATTERN_TYPE_PCRE:
511
- argv_array_push(&submodule_options, "-P");
512
- break;
513
- case GREP_PATTERN_TYPE_UNSPECIFIED:
514
- break;
515
- default:
516
- die("BUG: Added a new grep pattern type without updating switch statement");
517
- }
518
-
519
- for (pattern = opt->pattern_list; pattern != NULL;
520
- pattern = pattern->next) {
521
- switch (pattern->token) {
522
- case GREP_PATTERN:
523
- argv_array_pushf(&submodule_options, "-e%s",
524
- pattern->pattern);
525
- break;
526
- case GREP_AND:
527
- case GREP_OPEN_PAREN:
528
- case GREP_CLOSE_PAREN:
529
- case GREP_NOT:
530
- case GREP_OR:
531
- argv_array_push(&submodule_options, pattern->pattern);
532
- break;
533
- /* BODY and HEAD are not used by git-grep */
534
- case GREP_PATTERN_BODY:
535
- case GREP_PATTERN_HEAD:
536
- break;
537
- }
538
- }
539
-
540
- /*
541
- * Limit number of threads for child process to use.
542
- * This is to prevent potential fork-bomb behavior of git-grep as each
543
- * submodule process has its own thread pool.
544
- */
545
- argv_array_pushf(&submodule_options, "--threads=%d",
546
- DIV_ROUND_UP(num_threads, 2));
547
-
548
- /* Add Pathspecs */
549
- argv_array_push(&submodule_options, "--");
550
- for (; *argv; argv++)
551
- argv_array_push(&submodule_options, *argv);
552
-}
402
+static int grep_cache(struct grep_opt *opt, struct repository *repo,
403
+ const struct pathspec *pathspec, int cached);
404
+static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,
405
+ struct tree_desc *tree, struct strbuf *base, int tn_len,
406
+ int check_attr, struct repository *repo);
407
554
-/*
555
- * Launch child process to grep contents of a submodule
556
- */
557
-static int grep_submodule_launch(struct grep_opt *opt,
558
- const struct grep_source *gs)
408
+static int grep_submodule(struct grep_opt *opt, struct repository *superproject,
409
+ const struct pathspec *pathspec,
410
+ const struct object_id *oid,
411
+ const char *filename, const char *path)
412
{
560
- struct child_process cp = CHILD_PROCESS_INIT;
561
- int status, i;
562
- const char *end_of_base;
563
- const char *name;
564
- struct strbuf child_output = STRBUF_INIT;
565
-
566
- end_of_base = strchr(gs->name, ':');
567
- if (gs->identifier && end_of_base)
568
- name = end_of_base + 1;
569
- else
570
- name = gs->name;
413
+ struct repository submodule;
414
+ int hit;
415
572
- prepare_submodule_repo_env(&cp.env_array);
573
- argv_array_push(&cp.env_array, GIT_DIR_ENVIRONMENT);
416
+ if (!is_submodule_active(superproject, path))
417
+ return 0;
418
575
- if (opt->relative && opt->prefix_length)
576
- argv_array_pushf(&cp.env_array, "%s=%s",
577
- GIT_TOPLEVEL_PREFIX_ENVIRONMENT,
578
- opt->prefix);
419
+ if (repo_submodule_init(&submodule, superproject, path))
420
+ return 0;
421
580
- /* Add super prefix */
581
- argv_array_pushf(&cp.args, "--super-prefix=%s%s/",
582
- super_prefix ? super_prefix : "",
583
- name);
584
- argv_array_push(&cp.args, "grep");
422
+ repo_read_gitmodules(&submodule);
423
424
/*
587
- * Add basename of parent project
588
- * When performing grep on a tree object the filename is prefixed
589
- * with the object's name: 'tree-name:filename'. In order to
590
- * provide uniformity of output we want to pass the name of the
591
- * parent project's object name to the submodule so the submodule can
592
- * prefix its output with the parent's name and not its own OID.
425
+ * NEEDSWORK: This adds the submodule's object directory to the list of
426
+ * alternates for the single in-memory object store. This has some bad
427
+ * consequences for memory (processed objects will never be freed) and
428
+ * performance (this increases the number of pack files git has to pay
429
+ * attention to, to the sum of the number of pack files in all the
430
+ * repositories processed so far). This can be removed once the object
431
+ * store is no longer global and instead is a member of the repository
432
+ * object.
433
*/
594
- if (gs->identifier && end_of_base)
595
- argv_array_pushf(&cp.args, "--parent-basename=%.*s",
596
- (int) (end_of_base - gs->name),
597
- gs->name);
434
+ add_to_alternates_memory(submodule.objectdir);
435
599
- /* Add options */
600
- for (i = 0; i < submodule_options.argc; i++) {
601
- /*
602
- * If there is a tree identifier for the submodule, add the
603
- * rev after adding the submodule options but before the
604
- * pathspecs. To do this we listen for the '--' and insert the
605
- * oid before pushing the '--' onto the child process argv
606
- * array.
607
- */
608
- if (gs->identifier &&
609
- !strcmp("--", submodule_options.argv[i])) {
610
- argv_array_push(&cp.args, oid_to_hex(gs->identifier));
611
- }
436
+ if (oid) {
437
+ struct object *object;
438
+ struct tree_desc tree;
439
+ void *data;
440
+ unsigned long size;
441
+ struct strbuf base = STRBUF_INIT;
442
613
- argv_array_push(&cp.args, submodule_options.argv[i]);
614
- }
443
+ object = parse_object_or_die(oid, oid_to_hex(oid));
444
616
- cp.git_cmd = 1;
617
- cp.dir = gs->path;
445
+ grep_read_lock();
446
+ data = read_object_with_reference(object->oid.hash, tree_type,
447
+ &size, NULL);
448
+ grep_read_unlock();
449
619
- /*
620
- * Capture output to output buffer and check the return code from the
621
- * child process. A '0' indicates a hit, a '1' indicates no hit and
622
- * anything else is an error.
623
- */
624
- status = capture_command(&cp, &child_output, 0);
625
- if (status && (status != 1)) {
626
- /* flush the buffer */
627
- write_or_die(1, child_output.buf, child_output.len);
628
- die("process for submodule '%s' failed with exit code: %d",
629
- gs->name, status);
630
- }
450
+ if (!data)
451
+ die(_("unable to read tree (%s)"), oid_to_hex(&object->oid));
452
632
- opt->output(opt, child_output.buf, child_output.len);
633
- strbuf_release(&child_output);
634
- /* invert the return code to make a hit equal to 1 */
635
- return !status;
636
-}
453
+ strbuf_addstr(&base, filename);
454
+ strbuf_addch(&base, '/');
455
638
-/*
639
- * Prep grep structures for a submodule grep
640
- * oid: the oid of the submodule or NULL if using the working tree
641
- * filename: name of the submodule including tree name of parent
642
- * path: location of the submodule
643
- */
644
-static int grep_submodule(struct grep_opt *opt, const struct object_id *oid,
645
- const char *filename, const char *path)
646
-{
647
- if (!is_submodule_active(the_repository, path))
648
- return 0;
649
- if (!is_submodule_populated_gently(path, NULL)) {
650
- /*
651
- * If searching history, check for the presence of the
652
- * submodule's gitdir before skipping the submodule.
653
- */
654
- if (oid) {
655
- const struct submodule *sub =
656
- submodule_from_path(null_sha1, path);
657
- if (sub)
658
- path = git_path("modules/%s", sub->name);
659
-
660
- if (!(is_directory(path) && is_git_directory(path)))
661
- return 0;
662
- } else {
663
- return 0;
664
- }
456
+ init_tree_desc(&tree, data, size);
457
+ hit = grep_tree(opt, pathspec, &tree, &base, base.len,
458
+ object->type == OBJ_COMMIT, &submodule);
459
+ strbuf_release(&base);
460
+ free(data);
461
+ } else {
462
+ hit = grep_cache(opt, &submodule, pathspec, 1);
463
}
464
667
-#ifndef NO_PTHREADS
668
- if (num_threads) {
669
- add_work(opt, GREP_SOURCE_SUBMODULE, filename, path, oid);
670
- return 0;
671
- } else
672
-#endif
673
- {
674
- struct grep_source gs;
675
- int hit;
676
-
677
- grep_source_init(&gs, GREP_SOURCE_SUBMODULE,
678
- filename, path, oid);
679
- hit = grep_submodule_launch(opt, &gs);
680
-
681
- grep_source_clear(&gs);
682
- return hit;
683
- }
465
+ repo_clear(&submodule);
466
+ return hit;
467
}
468
686
-static int grep_cache(struct grep_opt *opt, const struct pathspec *pathspec,
687
- int cached)
469
+static int grep_cache(struct grep_opt *opt, struct repository *repo,
470
+ const struct pathspec *pathspec, int cached)
471
{
472
int hit = 0;
473
int nr;
474
struct strbuf name = STRBUF_INIT;
475
int name_base_len = 0;
693
- if (super_prefix) {
694
- name_base_len = strlen(super_prefix);
695
- strbuf_addstr(&name, super_prefix);
476
+ if (repo->submodule_prefix) {
477
+ name_base_len = strlen(repo->submodule_prefix);
478
+ strbuf_addstr(&name, repo->submodule_prefix);
479
}
480
698
- read_cache();
481
+ repo_read_index(repo);
482
700
- for (nr = 0; nr < active_nr; nr++) {
701
- const struct cache_entry *ce = active_cache[nr];
483
+ for (nr = 0; nr < repo->index->cache_nr; nr++) {
484
+ const struct cache_entry *ce = repo->index->cache[nr];
485
strbuf_setlen(&name, name_base_len);
486
strbuf_addstr(&name, ce->name);
487
@@ -715,14 +498,14 @@ static int grep_cache(struct grep_opt *opt, const struct pathspec *pathspec,
498
ce_skip_worktree(ce)) {
499
if (ce_stage(ce) || ce_intent_to_add(ce))
500
continue;
718
- hit |= grep_oid(opt, &ce->oid, ce->name,
719
- 0, ce->name);
501
+ hit |= grep_oid(opt, &ce->oid, name.buf,
502
+ 0, name.buf);
503
} else {
721
- hit |= grep_file(opt, ce->name);
504
+ hit |= grep_file(opt, name.buf);
505
}
506
} else if (recurse_submodules && S_ISGITLINK(ce->ce_mode) &&
507
submodule_path_match(pathspec, name.buf, NULL)) {
725
- hit |= grep_submodule(opt, NULL, ce->name, ce->name);
508
+ hit |= grep_submodule(opt, repo, pathspec, NULL, ce->name, ce->name);
509
} else {
510
continue;
511
}
@@ -730,8 +513,8 @@ static int grep_cache(struct grep_opt *opt, const struct pathspec *pathspec,
513
if (ce_stage(ce)) {
514
do {
515
nr++;
733
- } while (nr < active_nr &&
734
- !strcmp(ce->name, active_cache[nr]->name));
516
+ } while (nr < repo->index->cache_nr &&
517
+ !strcmp(ce->name, repo->index->cache[nr]->name));
518
nr--; /* compensate for loop control */
519
}
520
if (hit && opt->status_only)
@@ -744,7 +527,7 @@ static int grep_cache(struct grep_opt *opt, const struct pathspec *pathspec,
527
528
static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,
529
struct tree_desc *tree, struct strbuf *base, int tn_len,
747
- int check_attr)
530
+ int check_attr, struct repository *repo)
531
{
532
int hit = 0;
533
enum interesting match = entry_not_interesting;
@@ -752,8 +535,8 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,
535
int old_baselen = base->len;
536
struct strbuf name = STRBUF_INIT;
537
int name_base_len = 0;
755
- if (super_prefix) {
756
- strbuf_addstr(&name, super_prefix);
538
+ if (repo->submodule_prefix) {
539
+ strbuf_addstr(&name, repo->submodule_prefix);
540
name_base_len = name.len;
541
}
542
@@ -791,11 +574,11 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,
574
strbuf_addch(base, '/');
575
init_tree_desc(&sub, data, size);
576
hit |= grep_tree(opt, pathspec, &sub, base, tn_len,
794
- check_attr);
577
+ check_attr, repo);
578
free(data);
579
} else if (recurse_submodules && S_ISGITLINK(entry.mode)) {
797
- hit |= grep_submodule(opt, entry.oid, base->buf,
798
- base->buf + tn_len);
580
+ hit |= grep_submodule(opt, repo, pathspec, entry.oid,
581
+ base->buf, base->buf + tn_len);
582
}
583
584
strbuf_setlen(base, old_baselen);
@@ -809,7 +592,8 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,
592
}
593
594
static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec,
812
- struct object *obj, const char *name, const char *path)
595
+ struct object *obj, const char *name, const char *path,
596
+ struct repository *repo)
597
{
598
if (obj->type == OBJ_BLOB)
599
return grep_oid(opt, &obj->oid, name, 0, path);
@@ -828,10 +612,6 @@ static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec,
612
if (!data)
613
die(_("unable to read tree (%s)"), oid_to_hex(&obj->oid));
614
831
- /* Use parent's name as base when recursing submodules */
832
- if (recurse_submodules && parent_basename)
833
- name = parent_basename;
834
-
615
len = name ? strlen(name) : 0;
616
strbuf_init(&base, PATH_MAX + len + 1);
617
if (len) {
@@ -840,7 +620,7 @@ static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec,
620
}
621
init_tree_desc(&tree, data, size);
622
hit = grep_tree(opt, pathspec, &tree, &base, base.len,
843
- obj->type == OBJ_COMMIT);
623
+ obj->type == OBJ_COMMIT, repo);
624
strbuf_release(&base);
625
free(data);
626
return hit;
@@ -849,6 +629,7 @@ static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec,
629
}
630
631
static int grep_objects(struct grep_opt *opt, const struct pathspec *pathspec,
632
+ struct repository *repo,
633
const struct object_array *list)
634
{
635
unsigned int i;
@@ -864,7 +645,8 @@ static int grep_objects(struct grep_opt *opt, const struct pathspec *pathspec,
645
submodule_free();
646
gitmodules_config_sha1(real_obj->oid.hash);
647
}
867
- if (grep_object(opt, pathspec, real_obj, list->objects[i].name, list->objects[i].path)) {
648
+ if (grep_object(opt, pathspec, real_obj, list->objects[i].name, list->objects[i].path,
649
+ repo)) {
650
hit = 1;
651
if (opt->status_only)
652
break;
@@ -1005,9 +787,6 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
787
N_("ignore files specified via '.gitignore'"), 1),
788
OPT_BOOL(0, "recurse-submodules", &recurse_submodules,
789
N_("recursively search in each submodule")),
1008
- OPT_STRING(0, "parent-basename", &parent_basename,
1009
- N_("basename"),
1010
- N_("prepend parent project's basename to output")),
790
OPT_GROUP(""),
791
OPT_BOOL('v', "invert-match", &opt.invert,
792
N_("show non-matching lines")),
@@ -1112,7 +891,6 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
891
init_grep_defaults();
892
git_config(grep_cmd_config, NULL);
893
grep_init(&opt, prefix);
1115
- super_prefix = get_super_prefix();
894
895
/*
896
* If there is no -- then the paths must exist in the working
@@ -1272,9 +1050,6 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
1050
1051
if (recurse_submodules) {
1052
gitmodules_config();
1275
- compile_submodule_options(&opt, argv + i, cached, untracked,
1276
- opt_exclude, use_index,
1277
- pattern_type_arg);
1053
}
1054
1055
if (show_in_pager && (cached || list.nr))
@@ -1318,11 +1093,12 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
1093
if (!cached)
1094
setup_work_tree();
1095
1321
- hit = grep_cache(&opt, &pathspec, cached);
1096
+ hit = grep_cache(&opt, the_repository, &pathspec, cached);
1097
} else {
1098
if (cached)
1099
die(_("both --cached and trees are given."));
1325
- hit = grep_objects(&opt, &pathspec, &list);
1100
+
1101
+ hit = grep_objects(&opt, &pathspec, the_repository, &list);
1102
}
1103
1104
if (num_threads)
cache.h
-1
@@ -417,7 +417,6 @@ static inline enum object_type object_type(unsigned int mode)
417
#define GIT_WORK_TREE_ENVIRONMENT "GIT_WORK_TREE"
418
#define GIT_PREFIX_ENVIRONMENT "GIT_PREFIX"
419
#define GIT_SUPER_PREFIX_ENVIRONMENT "GIT_INTERNAL_SUPER_PREFIX"
420
-#define GIT_TOPLEVEL_PREFIX_ENVIRONMENT "GIT_INTERNAL_TOPLEVEL_PREFIX"
420
#define DEFAULT_GIT_DIR_ENVIRONMENT ".git"
421
#define DB_ENVIRONMENT "GIT_OBJECT_DIRECTORY"
422
#define INDEX_ENVIRONMENT "GIT_INDEX_FILE"
git.c
+1
-1
@@ -392,7 +392,7 @@ static struct cmd_struct commands[] = {
392
{ "fsck-objects", cmd_fsck, RUN_SETUP },
393
{ "gc", cmd_gc, RUN_SETUP },
394
{ "get-tar-commit-id", cmd_get_tar_commit_id },
395
- { "grep", cmd_grep, RUN_SETUP_GENTLY | SUPPORT_SUPER_PREFIX },
395
+ { "grep", cmd_grep, RUN_SETUP_GENTLY },
396
{ "hash-object", cmd_hash_object },
397
{ "help", cmd_help },
398
{ "index-pack", cmd_index_pack, RUN_SETUP_GENTLY },
grep.c
-13
@@ -1927,16 +1927,6 @@ void grep_source_init(struct grep_source *gs, enum grep_source_type type,
1927
case GREP_SOURCE_FILE:
1928
gs->identifier = xstrdup(identifier);
1929
break;
1930
- case GREP_SOURCE_SUBMODULE:
1931
- if (!identifier) {
1932
- gs->identifier = NULL;
1933
- break;
1934
- }
1935
- /*
1936
- * FALL THROUGH
1937
- * If the identifier is non-NULL (in the submodule case) it
1938
- * will be a SHA1 that needs to be copied.
1939
- */
1930
case GREP_SOURCE_OID:
1931
gs->identifier = oiddup(identifier);
1932
break;
@@ -1959,7 +1949,6 @@ void grep_source_clear_data(struct grep_source *gs)
1949
switch (gs->type) {
1950
case GREP_SOURCE_FILE:
1951
case GREP_SOURCE_OID:
1962
- case GREP_SOURCE_SUBMODULE:
1952
FREE_AND_NULL(gs->buf);
1953
gs->size = 0;
1954
break;
@@ -2030,8 +2019,6 @@ static int grep_source_load(struct grep_source *gs)
2019
return grep_source_load_oid(gs);
2020
case GREP_SOURCE_BUF:
2021
return gs->buf ? 0 : -1;
2033
- case GREP_SOURCE_SUBMODULE:
2034
- break;
2022
}
2023
die("BUG: invalid grep_source type to load");
2024
}
grep.h
-1
@@ -193,7 +193,6 @@ struct grep_source {
193
GREP_SOURCE_OID,
194
GREP_SOURCE_FILE,
195
GREP_SOURCE_BUF,
196
- GREP_SOURCE_SUBMODULE,
196
} type;
197
void *identifier;
198
setup.c
+1
-11
@@ -1027,7 +1027,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
1027
{
1028
static struct strbuf cwd = STRBUF_INIT;
1029
struct strbuf dir = STRBUF_INIT, gitdir = STRBUF_INIT;
1030
- const char *prefix, *env_prefix;
1030
+ const char *prefix;
1031
1032
/*
1033
* We may have read an incomplete configuration before
@@ -1085,16 +1085,6 @@ const char *setup_git_directory_gently(int *nongit_ok)
1085
die("BUG: unhandled setup_git_directory_1() result");
1086
}
1087
1088
- /*
1089
- * NEEDSWORK: This was a hack in order to get ls-files and grep to have
1090
- * properly formated output when recursing submodules. Once ls-files
1091
- * and grep have been changed to perform this recursing in-process this
1092
- * needs to be removed.
1093
- */
1094
- env_prefix = getenv(GIT_TOPLEVEL_PREFIX_ENVIRONMENT);
1095
- if (env_prefix)
1096
- prefix = env_prefix;
1097
-
1088
if (prefix)
1089
setenv(GIT_PREFIX_ENVIRONMENT, prefix, 1);
1090
else