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 {
@@ -335,12 +335,12 @@ static int add_files(struct dir_struct *dir, int flags)
335
335
336
336
for (i = 0 ; i < dir -> nr ; i ++ ) {
337
337
if (!include_sparse &&
338
- !path_in_sparse_checkout (dir -> entries [i ]-> name , & the_index )) {
338
+ !path_in_sparse_checkout (dir -> entries [i ]-> name , the_repository -> index )) {
339
339
string_list_append (& matched_sparse_paths ,
340
340
dir -> entries [i ]-> name );
341
341
continue ;
342
342
}
343
- if (add_file_to_index (& the_index , dir -> entries [i ]-> name , flags )) {
343
+ if (add_file_to_index (the_repository -> index , dir -> entries [i ]-> name , flags )) {
344
344
if (!ignore_add_errors )
345
345
die (_ ("adding files failed" ));
346
346
exit_status = 1 ;
@@ -458,8 +458,8 @@ int cmd_add(int argc, const char **argv, const char *prefix)
458
458
if (repo_read_index_preload (the_repository , & pathspec , 0 ) < 0 )
459
459
die (_ ("index file corrupt" ));
460
460
461
- die_in_unpopulated_submodule (& the_index , prefix );
462
- die_path_inside_submodule (& the_index , & pathspec );
461
+ die_in_unpopulated_submodule (the_repository -> index , prefix );
462
+ die_path_inside_submodule (the_repository -> index , & pathspec );
463
463
464
464
if (add_new_files ) {
465
465
int baselen ;
@@ -471,7 +471,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
471
471
}
472
472
473
473
/* This picks up the paths that are not tracked */
474
- baselen = fill_directory (& dir , & the_index , & pathspec );
474
+ baselen = fill_directory (& dir , the_repository -> index , & pathspec );
475
475
if (pathspec .nr )
476
476
seen = prune_directory (& dir , & pathspec , baselen );
477
477
}
@@ -488,7 +488,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
488
488
489
489
if (!seen )
490
490
seen = find_pathspecs_matching_against_index (& pathspec ,
491
- & the_index , PS_IGNORE_SKIP_WORKTREE );
491
+ the_repository -> index , PS_IGNORE_SKIP_WORKTREE );
492
492
493
493
/*
494
494
* file_exists() assumes exact match
@@ -524,8 +524,8 @@ int cmd_add(int argc, const char **argv, const char *prefix)
524
524
!file_exists (path )) {
525
525
if (ignore_missing ) {
526
526
int dtype = DT_UNKNOWN ;
527
- if (is_excluded (& dir , & the_index , path , & dtype ))
528
- dir_add_ignored (& dir , & the_index ,
527
+ if (is_excluded (& dir , the_repository -> index , path , & dtype ))
528
+ dir_add_ignored (& dir , the_repository -> index ,
529
529
path , pathspec .items [i ].len );
530
530
} else
531
531
die (_ ("pathspec '%s' did not match any files" ),
@@ -566,7 +566,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
566
566
end_odb_transaction ();
567
567
568
568
finish :
569
- if (write_locked_index (& the_index , & lock_file ,
569
+ if (write_locked_index (the_repository -> index , & lock_file ,
570
570
COMMIT_LOCK | SKIP_IF_UNCHANGED ))
571
571
die (_ ("unable to write new index file" ));
572
572
0 commit comments