13
13
* Error messages expected by scripts out of plumbing commands such as
14
14
* read-tree. Non-scripted Porcelain is not required to use these messages
15
15
* and in fact are encouraged to reword them to better suit their particular
16
- * situation better. See how "git checkout" replaces not_uptodate_file to
16
+ * situation better. See how "git checkout" replaces ERROR_NOT_UPTODATE_FILE to
17
17
* explain why it does not allow switching between branches when you have
18
18
* local changes, for example.
19
19
*/
20
- static struct unpack_trees_error_msgs unpack_plumbing_errors = {
21
- /* would_overwrite */
20
+ const char * unpack_plumbing_errors [ NB_UNPACK_TREES_ERROR_TYPES ] = {
21
+ /* ERROR_WOULD_OVERWRITE */
22
22
"Entry '%s' would be overwritten by merge. Cannot merge." ,
23
23
24
- /* not_uptodate_file */
24
+ /* ERROR_NOT_UPTODATE_FILE */
25
25
"Entry '%s' not uptodate. Cannot merge." ,
26
26
27
- /* not_uptodate_dir */
27
+ /* ERROR_NOT_UPTODATE_DIR */
28
28
"Updating '%s' would lose untracked files in it" ,
29
29
30
- /* would_lose_untracked */
30
+ /* ERROR_WOULD_LOSE_UNTRACKED */
31
31
"Untracked working tree file '%s' would be %s by merge." ,
32
32
33
- /* bind_overlap */
33
+ /* ERROR_BIND_OVERLAP */
34
34
"Entry '%s' overlaps with '%s'. Cannot bind." ,
35
35
36
- /* sparse_not_uptodate_file */
36
+ /* ERROR_SPARSE_NOT_UPTODATE_FILE */
37
37
"Entry '%s' not uptodate. Cannot update sparse checkout." ,
38
38
39
- /* would_lose_orphaned */
39
+ /* ERROR_WOULD_LOSE_ORPHANED */
40
40
"Working tree file '%s' would be %s by sparse checkout update." ,
41
41
};
42
42
43
- #define ERRORMSG (o ,fld ) \
44
- ( ((o) && (o)->msgs.fld ) \
45
- ? ((o)->msgs.fld) \
46
- : (unpack_plumbing_errors.fld ) )
43
+ #define ERRORMSG (o ,type ) \
44
+ ( ((o) && (o)->msgs[(type)] ) \
45
+ ? ((o)->msgs[(type)]) \
46
+ : (unpack_plumbing_errors[(type)] ) )
47
47
48
48
static void add_entry (struct unpack_trees_options * o , struct cache_entry * ce ,
49
49
unsigned int set , unsigned int clear )
@@ -838,7 +838,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
838
838
839
839
static int reject_merge (struct cache_entry * ce , struct unpack_trees_options * o )
840
840
{
841
- return error (ERRORMSG (o , would_overwrite ), ce -> name );
841
+ return error (ERRORMSG (o , ERROR_WOULD_OVERWRITE ), ce -> name );
842
842
}
843
843
844
844
static int same (struct cache_entry * a , struct cache_entry * b )
@@ -893,13 +893,13 @@ static int verify_uptodate(struct cache_entry *ce,
893
893
{
894
894
if (!o -> skip_sparse_checkout && will_have_skip_worktree (ce , o ))
895
895
return 0 ;
896
- return verify_uptodate_1 (ce , o , ERRORMSG (o , not_uptodate_file ));
896
+ return verify_uptodate_1 (ce , o , ERRORMSG (o , ERROR_NOT_UPTODATE_FILE ));
897
897
}
898
898
899
899
static int verify_uptodate_sparse (struct cache_entry * ce ,
900
900
struct unpack_trees_options * o )
901
901
{
902
- return verify_uptodate_1 (ce , o , ERRORMSG (o , sparse_not_uptodate_file ));
902
+ return verify_uptodate_1 (ce , o , ERRORMSG (o , ERROR_SPARSE_NOT_UPTODATE_FILE ));
903
903
}
904
904
905
905
static void invalidate_ce_path (struct cache_entry * ce , struct unpack_trees_options * o )
@@ -986,7 +986,7 @@ static int verify_clean_subdirectory(struct cache_entry *ce, const char *action,
986
986
i = read_directory (& d , pathbuf , namelen + 1 , NULL );
987
987
if (i )
988
988
return o -> gently ? -1 :
989
- error (ERRORMSG (o , not_uptodate_dir ), ce -> name );
989
+ error (ERRORMSG (o , ERROR_NOT_UPTODATE_DIR ), ce -> name );
990
990
free (pathbuf );
991
991
return cnt ;
992
992
}
@@ -1068,7 +1068,7 @@ static int verify_absent_1(struct cache_entry *ce, const char *action,
1068
1068
}
1069
1069
1070
1070
return o -> gently ? -1 :
1071
- error (ERRORMSG (o , would_lose_untracked ), ce -> name , action );
1071
+ error (ERRORMSG (o , ERROR_WOULD_LOSE_UNTRACKED ), ce -> name , action );
1072
1072
}
1073
1073
return 0 ;
1074
1074
}
@@ -1077,13 +1077,13 @@ static int verify_absent(struct cache_entry *ce, const char *action,
1077
1077
{
1078
1078
if (!o -> skip_sparse_checkout && will_have_skip_worktree (ce , o ))
1079
1079
return 0 ;
1080
- return verify_absent_1 (ce , action , o , ERRORMSG (o , would_lose_untracked ));
1080
+ return verify_absent_1 (ce , action , o , ERRORMSG (o , ERROR_WOULD_LOSE_UNTRACKED ));
1081
1081
}
1082
1082
1083
1083
static int verify_absent_sparse (struct cache_entry * ce , const char * action ,
1084
1084
struct unpack_trees_options * o )
1085
1085
{
1086
- return verify_absent_1 (ce , action , o , ERRORMSG (o , would_lose_orphaned ));
1086
+ return verify_absent_1 (ce , action , o , ERRORMSG (o , ERROR_WOULD_LOSE_ORPHANED ));
1087
1087
}
1088
1088
1089
1089
static int merged_entry (struct cache_entry * merge , struct cache_entry * old ,
@@ -1412,7 +1412,7 @@ int bind_merge(struct cache_entry **src,
1412
1412
o -> merge_size );
1413
1413
if (a && old )
1414
1414
return o -> gently ? -1 :
1415
- error (ERRORMSG (o , bind_overlap ), a -> name , old -> name );
1415
+ error (ERRORMSG (o , ERROR_BIND_OVERLAP ), a -> name , old -> name );
1416
1416
if (!a )
1417
1417
return keep_entry (old , o );
1418
1418
else
0 commit comments