Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'jn/do-not-drop-username-when-reading-from-etc-mailname'…

… into maint

We used to stuff "user@" and then append what we read from
/etc/mailname to come up with a default e-mail ident, but a bug lost
the "user@" part.

* jn/do-not-drop-username-when-reading-from-etc-mailname:
  ident: do not drop username when reading from /etc/mailname
  • Loading branch information...
commit 7f3d409cd18e74c1d3adf892dce70a2d02d0797a 2 parents 3d00a5c + dc342a2
Junio C Hamano authored February 04, 2013

Showing 1 changed file with 5 additions and 1 deletion. Show diff stats Hide diff stats

  1. 6  ident.c
6  ident.c
@@ -46,6 +46,7 @@ static void copy_gecos(const struct passwd *w, struct strbuf *name)
46 46
 static int add_mailname_host(struct strbuf *buf)
47 47
 {
48 48
 	FILE *mailname;
  49
+	struct strbuf mailnamebuf = STRBUF_INIT;
49 50
 
50 51
 	mailname = fopen("/etc/mailname", "r");
51 52
 	if (!mailname) {
@@ -54,14 +55,17 @@ static int add_mailname_host(struct strbuf *buf)
54 55
 				strerror(errno));
55 56
 		return -1;
56 57
 	}
57  
-	if (strbuf_getline(buf, mailname, '\n') == EOF) {
  58
+	if (strbuf_getline(&mailnamebuf, mailname, '\n') == EOF) {
58 59
 		if (ferror(mailname))
59 60
 			warning("cannot read /etc/mailname: %s",
60 61
 				strerror(errno));
  62
+		strbuf_release(&mailnamebuf);
61 63
 		fclose(mailname);
62 64
 		return -1;
63 65
 	}
64 66
 	/* success! */
  67
+	strbuf_addbuf(buf, &mailnamebuf);
  68
+	strbuf_release(&mailnamebuf);
65 69
 	fclose(mailname);
66 70
 	return 0;
67 71
 }

0 notes on commit 7f3d409

Please sign in to comment.
Something went wrong with that request. Please try again.