summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn O. Pearce <sop@google.com>2009-07-02 10:53:04 -0700
committerShawn O. Pearce <sop@google.com>2009-07-02 10:53:04 -0700
commit37dbf2bf0fa799530052ffd010dadbd4c01b7746 (patch)
tree9e9be8619020ba6b6de2bc28ba5da94fa69e6188
parent438c54713a7ca56fba2a7985b6563aa076b17169 (diff)
downloadgit-repo-37dbf2bf0fa799530052ffd010dadbd4c01b7746.tar.gz
Try to prevent 'repo sync' as a user namev1.6.8.6
When someone copies and pastes a setup line from a web page, they might actually copy 'repo sync' onto the clipboard and wind up pasting it into the "Your Name" prompt. This means they will initialize their client with the user name of "repo sync", creating some rather funny looking commits later on. For example: To setup your source tree: mkdir ~/code cd ~/code repo init -u git://.... repo sync If this entire block was just blindly copy and pasted into the terminal, the shell won't read "repo sync" but "repo init" will. By showing the user their full identity string, and asking them to confirm it before we continue, we can give the hapless user a chance to recover from this mistake, without unfairly harming those who were actually named 'repo' by their parents. Signed-off-by: Shawn O. Pearce <sop@google.com>
-rw-r--r--subcmds/init.py25
1 files changed, 19 insertions, 6 deletions
diff --git a/subcmds/init.py b/subcmds/init.py
index fbc406e2..75a58f11 100644
--- a/subcmds/init.py
+++ b/subcmds/init.py
@@ -148,20 +148,33 @@ to update the working directory files.
148 print >>sys.stderr, 'fatal: %s' % str(e) 148 print >>sys.stderr, 'fatal: %s' % str(e)
149 sys.exit(1) 149 sys.exit(1)
150 150
151 def _PromptKey(self, prompt, key, value): 151 def _Prompt(self, prompt, value):
152 mp = self.manifest.manifestProject 152 mp = self.manifest.manifestProject
153 153
154 sys.stdout.write('%-10s [%s]: ' % (prompt, value)) 154 sys.stdout.write('%-10s [%s]: ' % (prompt, value))
155 a = sys.stdin.readline().strip() 155 a = sys.stdin.readline().strip()
156 if a != '' and a != value: 156 if a == '':
157 mp.config.SetString(key, a) 157 return value
158 return a
158 159
159 def _ConfigureUser(self): 160 def _ConfigureUser(self):
160 mp = self.manifest.manifestProject 161 mp = self.manifest.manifestProject
161 162
162 print '' 163 while True:
163 self._PromptKey('Your Name', 'user.name', mp.UserName) 164 print ''
164 self._PromptKey('Your Email', 'user.email', mp.UserEmail) 165 name = self._Prompt('Your Name', mp.UserName)
166 email = self._Prompt('Your Email', mp.UserEmail)
167
168 print ''
169 print 'Your identity is: %s <%s>' % (name, email)
170 sys.stdout.write('is this correct [yes/no]? ')
171 if 'yes' == sys.stdin.readline().strip():
172 break
173
174 if name != mp.UserName:
175 mp.config.SetString('user.name', name)
176 if email != mp.UserEmail:
177 mp.config.SetString('user.email', email)
165 178
166 def _HasColorSet(self, gc): 179 def _HasColorSet(self, gc):
167 for n in ['ui', 'diff', 'status']: 180 for n in ['ui', 'diff', 'status']: