@@ -82,67 +82,80 @@ static struct cache_file cache_file;
8282
8383int main (int argc , char * * argv )
8484{
85- int i , force_filename = 0 ;
85+ int i ;
8686 int newfd = -1 ;
87+ int all = 0 ;
8788
8889 if (read_cache () < 0 ) {
8990 die ("invalid cache" );
9091 }
9192
9293 for (i = 1 ; i < argc ; i ++ ) {
9394 const char * arg = argv [i ];
94- if (!force_filename ) {
95- if (!strcmp (arg , "-a" )) {
96- checkout_all ();
97- continue ;
98- }
99- if (!strcmp (arg , "--" )) {
100- force_filename = 1 ;
101- continue ;
102- }
103- if (!strcmp (arg , "-f" )) {
104- state .force = 1 ;
105- continue ;
106- }
107- if (!strcmp (arg , "-q" )) {
108- state .quiet = 1 ;
109- continue ;
110- }
111- if (!strcmp (arg , "-n" )) {
112- state .not_new = 1 ;
113- continue ;
114- }
115- if (!strcmp (arg , "-u" )) {
116- state .refresh_cache = 1 ;
117- if (newfd < 0 )
118- newfd = hold_index_file_for_update
119- (& cache_file ,
120- get_index_file ());
121- if (newfd < 0 )
122- die ("cannot open index.lock file." );
123- continue ;
124- }
125- if (!memcmp (arg , "--prefix=" , 9 )) {
126- state .base_dir = arg + 9 ;
127- state .base_dir_len = strlen (state .base_dir );
128- continue ;
129- }
130- if (arg [0 ] == '-' )
131- usage (checkout_cache_usage );
95+
96+ if (!strcmp (arg , "--" )) {
97+ i ++ ;
98+ break ;
99+ }
100+ if (!strcmp (arg , "-a" ) || !strcmp (arg , "--all" )) {
101+ all = 1 ;
102+ continue ;
103+ }
104+ if (!strcmp (arg , "-f" ) || !strcmp (arg , "--force" )) {
105+ state .force = 1 ;
106+ continue ;
132107 }
133- if (state .base_dir_len ) {
134- /* when --prefix is specified we do not
135- * want to update cache.
136- */
137- if (state .refresh_cache ) {
138- close (newfd ); newfd = -1 ;
139- rollback_index_file (& cache_file );
140- }
141- state .refresh_cache = 0 ;
108+ if (!strcmp (arg , "-q" ) || !strcmp (arg , "--quiet" )) {
109+ state .quiet = 1 ;
110+ continue ;
111+ }
112+ if (!strcmp (arg , "-n" ) || !strcmp (arg , "--no-create" )) {
113+ state .not_new = 1 ;
114+ continue ;
115+ }
116+ if (!strcmp (arg , "-u" ) || !strcmp (arg , "--index" )) {
117+ state .refresh_cache = 1 ;
118+ if (newfd < 0 )
119+ newfd = hold_index_file_for_update
120+ (& cache_file ,
121+ get_index_file ());
122+ if (newfd < 0 )
123+ die ("cannot open index.lock file." );
124+ continue ;
142125 }
126+ if (!memcmp (arg , "--prefix=" , 9 )) {
127+ state .base_dir = arg + 9 ;
128+ state .base_dir_len = strlen (state .base_dir );
129+ continue ;
130+ }
131+ if (arg [0 ] == '-' )
132+ usage (checkout_cache_usage );
133+ break ;
134+ }
135+
136+ if (state .base_dir_len ) {
137+ /* when --prefix is specified we do not
138+ * want to update cache.
139+ */
140+ if (state .refresh_cache ) {
141+ close (newfd ); newfd = -1 ;
142+ rollback_index_file (& cache_file );
143+ }
144+ state .refresh_cache = 0 ;
145+ }
146+
147+ /* Check out named files first */
148+ for ( ; i < argc ; i ++ ) {
149+ const char * arg = argv [i ];
150+
151+ if (all )
152+ die ("git-checkout-index: don't mix '--all' and explicit filenames" );
143153 checkout_file (arg );
144154 }
145155
156+ if (all )
157+ checkout_all ();
158+
146159 if (0 <= newfd &&
147160 (write_cache (newfd , active_cache , active_nr ) ||
148161 commit_index_file (& cache_file )))
0 commit comments