@@ -93,18 +93,25 @@ func UnsetUserName(global bool) error {
9393 return errors .New ("not a git repository" )
9494 }
9595
96- _ , err := GetUserName ()
97- if err != nil {
98- return errors .New ("no local username to unset" )
99- }
96+ var args []string
97+ if ! global {
98+ _ , err := GetUserName ()
99+ if err != nil {
100+ return errors .New ("no local username to unset" )
101+ }
102+
103+ args = []string {"config" , "--unset" , "user.name" }
104+ } else {
105+ _ , err := GetGlobalUserName ()
106+ if err != nil {
107+ return errors .New ("no global username to unset" )
108+ }
100109
101- args := []string {"config" , "--unset" , "user.name" }
102- if global {
103110 args = []string {"config" , "--global" , "--unset" , "user.name" }
104111 }
105112
106113 cmd := exec .Command ("git" , args ... )
107- _ , err = cmd .Output ()
114+ _ , err : = cmd .Output ()
108115 if err != nil {
109116 return err
110117 }
@@ -224,18 +231,26 @@ func UnsetUserEmail(global bool) error {
224231 return errors .New ("not a git repository" )
225232 }
226233
227- _ , err := GetUserEmail ()
228- if err != nil {
229- return errors .New ("no local email to unset" )
230- }
234+ var args []string
235+
236+ if ! global {
237+ _ , err := GetUserEmail ()
238+ if err != nil {
239+ return errors .New ("no local email to unset" )
240+ }
241+
242+ args = []string {"config" , "--unset" , "user.email" }
243+ } else {
244+ _ , err := GetGlobalUserEmail ()
245+ if err != nil {
246+ return errors .New ("no global email to unset" )
247+ }
231248
232- args := []string {"config" , "--unset" , "user.email" }
233- if global {
234249 args = []string {"config" , "--global" , "--unset" , "user.email" }
235250 }
236251
237252 cmd := exec .Command ("git" , args ... )
238- _ , err = cmd .Output ()
253+ _ , err : = cmd .Output ()
239254 if err != nil {
240255 return err
241256 }
0 commit comments