@matheusbsbs / matheus-bagliano / commits / cb280e1075
Fork 0

Allow non-developer to clone, checkout and fetch more easily.

The code that uses committer_info() in reflog can barf and die whenever it is asked to update a ref. And I do not think calling ignore_missing_committer_name() upfront like recent receive-pack did in the aplication is a reasonable workaround. What the patch does. - git_committer_info() takes one parameter. It used to be "if this is true, then die() if the name is not available due to bad GECOS, otherwise issue a warning once but leave the name empty". The reason was because we wanted to prevent bad commits from being made by git-commit-tree (and its callers). The value 0 is only used by "git var -l". Now it takes -1, 0 or 1. When set to -1, it does not complain but uses the pw->pw_name when name is not available. Existing 0 and 1 values mean the same thing as they used to mean before. 0 means issue warnings and leave it empty, 1 means barf and die. - ignore_missing_committer_name() and its existing caller (receive-pack, to set the reflog) have been removed. - git-format-patch, to come up with the phoney message ID when asked to thread, now passes -1 to git_committer_info(). This codepath uses only the e-mail part, ignoring the name. It used to barf and die. The other call in the same program when asked to add signed-off-by line based on committer identity still passes 1 to make sure it barfs instead of adding a bogus s-o-b line. - log_ref_write in refs.c, to come up with the name to record who initiated the ref update in the reflog, passes -1. It used to barf and die. The last change means that git-update-ref, git-branch, and commit walker backends can now be used in a repository with reflog by somebody who does not have the user identity required to make a commit. They all used to barf and die. I've run tests and all of them seem to pass, and also tried "git clone" as a user whose GECOS is empty -- git clone works again now (it was broken when reflog was enabled by default). But this definitely needs extra sets of eyeballs. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Jan 25, 2007 at 19:05 UTC cb280e107523e5263f390db715234700355a63b9
5 files changed +13 -22
builtin-log.c
+1 -1
@@ -352,7 +352,7 @@ static void get_patch_ids(struct rev_info *rev, struct diff_options *options, co
352
353 static void gen_message_id(char *dest, unsigned int length, char *base)
354 {
355 - const char *committer = git_committer_info(1);
355 + const char *committer = git_committer_info(-1);
356 const char *email_start = strrchr(committer, '<');
357 const char *email_end = strrchr(committer, '>');
358 if(!email_start || !email_end || email_start > email_end - 1)
cache.h
-1
@@ -320,7 +320,6 @@ void datestamp(char *buf, int bufsize);
320 unsigned long approxidate(const char *);
321
322 extern int setup_ident(void);
323 -extern void ignore_missing_committer_name(void);
323 extern const char *git_author_info(int);
324 extern const char *git_committer_info(int);
325
ident.c
+11 -17
@@ -180,12 +180,21 @@ static const char *get_ident(const char *name, const char *email,
180 email = git_default_email;
181
182 if (!*name) {
183 - if (name == git_default_name && env_hint) {
183 + struct passwd *pw;
184 +
185 + if (0 <= error_on_no_name &&
186 + name == git_default_name && env_hint) {
187 fprintf(stderr, env_hint, au_env, co_env);
188 env_hint = NULL; /* warn only once, for "git-var -l" */
189 }
187 - if (error_on_no_name)
190 + if (0 < error_on_no_name)
191 die("empty ident %s <%s> not allowed", name, email);
192 + pw = getpwuid(getuid());
193 + if (!pw)
194 + die("You don't exist. Go away!");
195 + strlcpy(git_default_name, pw->pw_name,
196 + sizeof(git_default_name));
197 + name = git_default_name;
198 }
199
200 strcpy(date, git_default_date);
@@ -218,18 +227,3 @@ const char *git_committer_info(int error_on_no_name)
227 getenv("GIT_COMMITTER_DATE"),
228 error_on_no_name);
229 }
221 -
222 -void ignore_missing_committer_name()
223 -{
224 - /* If we did not get a name from the user's gecos entry then
225 - * git_default_name is empty; so instead load the username
226 - * into it as a 'good enough for now' approximation of who
227 - * this user is.
228 - */
229 - if (!*git_default_name) {
230 - struct passwd *pw = getpwuid(getuid());
231 - if (!pw)
232 - die("You don't exist. Go away!");
233 - strlcpy(git_default_name, pw->pw_name, sizeof(git_default_name));
234 - }
235 -}
receive-pack.c
-2
@@ -430,8 +430,6 @@ int main(int argc, char **argv)
430 die("attempt to push into a shallow repository");
431
432 setup_ident();
433 - /* don't die if gecos is empty */
434 - ignore_missing_committer_name();
433 git_config(receive_pack_config);
434
435 if (0 <= transfer_unpack_limit)
refs.c
+1 -1
@@ -958,7 +958,7 @@ static int log_ref_write(struct ref_lock *lock,
958 lock->log_file, strerror(errno));
959 }
960
961 - committer = git_committer_info(1);
961 + committer = git_committer_info(-1);
962 if (msg) {
963 maxlen = strlen(committer) + strlen(msg) + 2*40 + 5;
964 logrec = xmalloc(maxlen);