@@ -1004,21 +1004,30 @@ public void abortCherryPick() throws RepoException {
1004
1004
public class AddCmd {
1005
1005
1006
1006
private final boolean force ;
1007
+ private final boolean renormalize ;
1007
1008
private final boolean all ;
1008
1009
private final Iterable <String > files ;
1009
1010
@ Nullable private final String pathSpecFromFile ;
1010
1011
1011
- private AddCmd (boolean force , boolean all , Iterable <String > files , String pathSpecFromFile ) {
1012
+
1013
+ private AddCmd (boolean force , boolean all , Iterable <String > files , String pathSpecFromFile , boolean renormalize ) {
1012
1014
this .force = force ;
1013
1015
this .all = all ;
1016
+ this .renormalize = renormalize ;
1014
1017
this .files = checkNotNull (files );
1015
1018
this .pathSpecFromFile = pathSpecFromFile ;
1016
1019
}
1017
1020
1018
1021
/** Force the add */
1019
1022
@ CheckReturnValue
1020
1023
public AddCmd force () {
1021
- return new AddCmd (/*force=*/ true , all , files , pathSpecFromFile );
1024
+ return new AddCmd (/*force=*/ true , all , files , pathSpecFromFile , renormalize );
1025
+ }
1026
+
1027
+ /** Renormalize the add */
1028
+ @ CheckReturnValue
1029
+ public AddCmd renormalize () {
1030
+ return new AddCmd (/*force=*/ true , all , files , pathSpecFromFile , true );
1022
1031
}
1023
1032
1024
1033
/** Add all the unstagged files to the index */
@@ -1027,7 +1036,7 @@ public AddCmd all() {
1027
1036
Preconditions .checkState (Iterables .isEmpty (files ), "'all' and passing files is incompatible" );
1028
1037
Preconditions .checkState (
1029
1038
pathSpecFromFile == null , "'all' and pathSpecFromFile is incompatible" );
1030
- return new AddCmd (force , /*all=*/ true , files , pathSpecFromFile );
1039
+ return new AddCmd (force , /*all=*/ true , files , pathSpecFromFile , renormalize );
1031
1040
}
1032
1041
1033
1042
/** Configure the files to add to the index */
@@ -1036,7 +1045,7 @@ public AddCmd files(Iterable<String> files) {
1036
1045
Preconditions .checkState (!all , "'all' and passing files is incompatible" );
1037
1046
Preconditions .checkState (
1038
1047
pathSpecFromFile == null , "'pathSpecFromFile' and passing files is incompatible" );
1039
- return new AddCmd (force , /*all=*/ false , files , pathSpecFromFile );
1048
+ return new AddCmd (force , /*all=*/ false , files , pathSpecFromFile , renormalize );
1040
1049
}
1041
1050
1042
1051
/** Configure the files to add to the index */
@@ -1045,7 +1054,7 @@ public AddCmd pathSpecFromFile(String pathSpecFromFile) {
1045
1054
Preconditions .checkState (!all , "'pathSpecFromFile' and passing files is incompatible" );
1046
1055
Preconditions .checkState (
1047
1056
Iterables .isEmpty (files ), "'pathSpecFromFile' and passing files is incompatible" );
1048
- return new AddCmd (force , /*all=*/ false , files , pathSpecFromFile );
1057
+ return new AddCmd (force , /*all=*/ false , files , pathSpecFromFile , renormalize );
1049
1058
}
1050
1059
1051
1060
/** Configure the files to add to the index */
@@ -1063,7 +1072,9 @@ public void run() throws RepoException {
1063
1072
if (all ) {
1064
1073
params .add ("--all" );
1065
1074
}
1066
-
1075
+ if (renormalize ) {
1076
+ params .add ("--renormalize" );
1077
+ }
1067
1078
if (pathSpecFromFile != null ) {
1068
1079
params .add ("--pathspec-from-file=" + pathSpecFromFile );
1069
1080
}
@@ -1078,7 +1089,7 @@ public void run() throws RepoException {
1078
1089
*/
1079
1090
@ CheckReturnValue
1080
1091
public AddCmd add () {
1081
- return new AddCmd (/*force*/ false , /*all*/ false , /*files*/ ImmutableSet .of (), null );
1092
+ return new AddCmd (/*force*/ false , /*all*/ false , /*files*/ ImmutableSet .of (), null , false );
1082
1093
}
1083
1094
1084
1095
/**
0 commit comments