Commit Diff


commit - 768aea60a17834a020b4c7ddd4cb6c3c3496debc
commit + 35bd8fed48e5c647869cdc1b3144be70101c9e0b
blob - 77eeffbd54d16cdfc877092f4812ada8a39dd5f4
blob + e4684d961ad765586db56578e828c55d6b2d0100
--- got/got.c
+++ got/got.c
@@ -2088,6 +2088,7 @@ cmd_commit(int argc, char *argv[])
 	char *cwd = NULL, *path = NULL, *id_str = NULL;
 	struct got_object_id *id = NULL;
 	const char *logmsg = "<no log message was specified>";
+	const char *got_author = getenv("GOT_AUTHOR");
 	int ch;
 
 	while ((ch = getopt(argc, argv, "m:")) != -1) {
@@ -2113,6 +2114,11 @@ cmd_commit(int argc, char *argv[])
 	} else if (argc != 0)
 		usage_commit();
 
+	if (got_author == NULL) {
+		/* TODO: Look current user up in password database */
+		error = got_error(GOT_ERR_COMMIT_NO_AUTHOR);
+		goto done;
+	}
 
 	cwd = getcwd(NULL, 0);
 	if (cwd == NULL) {
@@ -2132,9 +2138,8 @@ cmd_commit(int argc, char *argv[])
 	if (error)
 		goto done;
 
-	error = got_worktree_commit(&id, worktree, path,
-	    "Stefan Sperling <stsp@stsp.name>", NULL, logmsg,
-	    print_status, NULL, repo);
+	error = got_worktree_commit(&id, worktree, path, got_author, NULL,
+	    logmsg, print_status, NULL, repo);
 	if (error)
 		goto done;
 
blob - c3c1b5abc876c276781220cad85eb5f5081d47b4
blob + 52d7a09962ece61d245acc31d840a4b52ab3d012
--- include/got_error.h
+++ include/got_error.h
@@ -84,6 +84,7 @@
 #define GOT_ERR_FILE_STATUS	68
 #define GOT_ERR_COMMIT_CONFLICT	69
 #define GOT_ERR_BAD_REF_TYPE	70
+#define GOT_ERR_COMMIT_NO_AUTHOR 71
 
 static const struct got_error {
 	int code;
@@ -159,6 +160,7 @@ static const struct got_error {
 	{ GOT_ERR_FILE_STATUS,	"file has unexpected status" },
 	{ GOT_ERR_COMMIT_CONFLICT,"cannot commit file in conflicted status" },
 	{ GOT_ERR_BAD_REF_TYPE,	"bad reference type" },
+	{ GOT_ERR_COMMIT_NO_AUTHOR,"GOT_AUTHOR environment variable is not set" },
 };
 
 /*
blob - 3b59e835e6ecc623df880e4728b88bbe7900a8ab
blob + e3788886fd140f9ecfccc941118174c1abf7fc12
--- regress/cmdline/commit.sh
+++ regress/cmdline/commit.sh
@@ -16,6 +16,9 @@
 
 . ./common.sh
 
+name=$(getent passwd $USER | cut -d: -f5)
+export GOT_AUTHOR="$name <$(whoami)@$(hostname)>"
+
 function test_commit_basic {
 	local testroot=`test_init commit_basic`