3
3
*
4
4
* Copyright (C) 2006 Linus Torvalds
5
5
*/
6
- #define USE_THE_INDEX_VARIABLE
6
+
7
7
#include "builtin.h"
8
8
#include "advice.h"
9
9
#include "config.h"
@@ -40,20 +40,20 @@ static int chmod_pathspec(struct pathspec *pathspec, char flip, int show_only)
40
40
{
41
41
int i , ret = 0 ;
42
42
43
- for (i = 0 ; i < the_index . cache_nr ; i ++ ) {
44
- struct cache_entry * ce = the_index . cache [i ];
43
+ for (i = 0 ; i < the_repository -> index -> cache_nr ; i ++ ) {
44
+ struct cache_entry * ce = the_repository -> index -> cache [i ];
45
45
int err ;
46
46
47
47
if (!include_sparse &&
48
48
(ce_skip_worktree (ce ) ||
49
- !path_in_sparse_checkout (ce -> name , & the_index )))
49
+ !path_in_sparse_checkout (ce -> name , the_repository -> index )))
50
50
continue ;
51
51
52
- if (pathspec && !ce_path_match (& the_index , ce , pathspec , NULL ))
52
+ if (pathspec && !ce_path_match (the_repository -> index , ce , pathspec , NULL ))
53
53
continue ;
54
54
55
55
if (!show_only )
56
- err = chmod_index_entry (& the_index , ce , flip );
56
+ err = chmod_index_entry (the_repository -> index , ce , flip );
57
57
else
58
58
err = S_ISREG (ce -> ce_mode ) ? 0 : -1 ;
59
59
@@ -68,20 +68,20 @@ static int renormalize_tracked_files(const struct pathspec *pathspec, int flags)
68
68
{
69
69
int i , retval = 0 ;
70
70
71
- for (i = 0 ; i < the_index . cache_nr ; i ++ ) {
72
- struct cache_entry * ce = the_index . cache [i ];
71
+ for (i = 0 ; i < the_repository -> index -> cache_nr ; i ++ ) {
72
+ struct cache_entry * ce = the_repository -> index -> cache [i ];
73
73
74
74
if (!include_sparse &&
75
75
(ce_skip_worktree (ce ) ||
76
- !path_in_sparse_checkout (ce -> name , & the_index )))
76
+ !path_in_sparse_checkout (ce -> name , the_repository -> index )))
77
77
continue ;
78
78
if (ce_stage (ce ))
79
79
continue ; /* do not touch unmerged paths */
80
80
if (!S_ISREG (ce -> ce_mode ) && !S_ISLNK (ce -> ce_mode ))
81
81
continue ; /* do not touch non blobs */
82
- if (pathspec && !ce_path_match (& the_index , ce , pathspec , NULL ))
82
+ if (pathspec && !ce_path_match (the_repository -> index , ce , pathspec , NULL ))
83
83
continue ;
84
- retval |= add_file_to_index (& the_index , ce -> name ,
84
+ retval |= add_file_to_index (the_repository -> index , ce -> name ,
85
85
flags | ADD_CACHE_RENORMALIZE );
86
86
}
87
87
@@ -100,11 +100,11 @@ static char *prune_directory(struct dir_struct *dir, struct pathspec *pathspec,
100
100
i = dir -> nr ;
101
101
while (-- i >= 0 ) {
102
102
struct dir_entry * entry = * src ++ ;
103
- if (dir_path_match (& the_index , entry , pathspec , prefix , seen ))
103
+ if (dir_path_match (the_repository -> index , entry , pathspec , prefix , seen ))
104
104
* dst ++ = entry ;
105
105
}
106
106
dir -> nr = dst - dir -> entries ;
107
- add_pathspec_matches_against_index (pathspec , & the_index , seen ,
107
+ add_pathspec_matches_against_index (pathspec , the_repository -> index , seen ,
108
108
PS_IGNORE_SKIP_WORKTREE );
109
109
return seen ;
110
110
}
@@ -119,14 +119,14 @@ static int refresh(int verbose, const struct pathspec *pathspec)
119
119
(verbose ? REFRESH_IN_PORCELAIN : REFRESH_QUIET );
120
120
121
121
seen = xcalloc (pathspec -> nr , 1 );
122
- refresh_index (& the_index , flags , pathspec , seen ,
122
+ refresh_index (the_repository -> index , flags , pathspec , seen ,
123
123
_ ("Unstaged changes after refreshing the index:" ));
124
124
for (i = 0 ; i < pathspec -> nr ; i ++ ) {
125
125
if (!seen [i ]) {
126
126
const char * path = pathspec -> items [i ].original ;
127
127
128
128
if (matches_skip_worktree (pathspec , i , & skip_worktree_seen ) ||
129
- !path_in_sparse_checkout (path , & the_index )) {
129
+ !path_in_sparse_checkout (path , the_repository -> index )) {
130
130
string_list_append (& only_match_skip_worktree ,
131
131
pathspec -> items [i ].original );
132
132
} else {
@@ -338,12 +338,12 @@ static int add_files(struct dir_struct *dir, int flags)
338
338
339
339
for (i = 0 ; i < dir -> nr ; i ++ ) {
340
340
if (!include_sparse &&
341
- !path_in_sparse_checkout (dir -> entries [i ]-> name , & the_index )) {
341
+ !path_in_sparse_checkout (dir -> entries [i ]-> name , the_repository -> index )) {
342
342
string_list_append (& matched_sparse_paths ,
343
343
dir -> entries [i ]-> name );
344
344
continue ;
345
345
}
346
- if (add_file_to_index (& the_index , dir -> entries [i ]-> name , flags )) {
346
+ if (add_file_to_index (the_repository -> index , dir -> entries [i ]-> name , flags )) {
347
347
if (!ignore_add_errors )
348
348
die (_ ("adding files failed" ));
349
349
exit_status = 1 ;
@@ -461,8 +461,8 @@ int cmd_add(int argc, const char **argv, const char *prefix)
461
461
if (repo_read_index_preload (the_repository , & pathspec , 0 ) < 0 )
462
462
die (_ ("index file corrupt" ));
463
463
464
- die_in_unpopulated_submodule (& the_index , prefix );
465
- die_path_inside_submodule (& the_index , & pathspec );
464
+ die_in_unpopulated_submodule (the_repository -> index , prefix );
465
+ die_path_inside_submodule (the_repository -> index , & pathspec );
466
466
467
467
if (add_new_files ) {
468
468
int baselen ;
@@ -474,7 +474,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
474
474
}
475
475
476
476
/* This picks up the paths that are not tracked */
477
- baselen = fill_directory (& dir , & the_index , & pathspec );
477
+ baselen = fill_directory (& dir , the_repository -> index , & pathspec );
478
478
if (pathspec .nr )
479
479
seen = prune_directory (& dir , & pathspec , baselen );
480
480
}
@@ -491,7 +491,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
491
491
492
492
if (!seen )
493
493
seen = find_pathspecs_matching_against_index (& pathspec ,
494
- & the_index , PS_IGNORE_SKIP_WORKTREE );
494
+ the_repository -> index , PS_IGNORE_SKIP_WORKTREE );
495
495
496
496
/*
497
497
* file_exists() assumes exact match
@@ -527,8 +527,8 @@ int cmd_add(int argc, const char **argv, const char *prefix)
527
527
!file_exists (path )) {
528
528
if (ignore_missing ) {
529
529
int dtype = DT_UNKNOWN ;
530
- if (is_excluded (& dir , & the_index , path , & dtype ))
531
- dir_add_ignored (& dir , & the_index ,
530
+ if (is_excluded (& dir , the_repository -> index , path , & dtype ))
531
+ dir_add_ignored (& dir , the_repository -> index ,
532
532
path , pathspec .items [i ].len );
533
533
} else
534
534
die (_ ("pathspec '%s' did not match any files" ),
@@ -569,7 +569,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
569
569
end_odb_transaction ();
570
570
571
571
finish :
572
- if (write_locked_index (& the_index , & lock_file ,
572
+ if (write_locked_index (the_repository -> index , & lock_file ,
573
573
COMMIT_LOCK | SKIP_IF_UNCHANGED ))
574
574
die (_ ("unable to write new index file" ));
575
575
0 commit comments