@@ -58,33 +58,31 @@ init(args: list of string)
58
58
REPOPATH = hd args;
59
59
args = tl args;
60
60
61
- arg->init(args);
62
61
utils->init(REPOPATH);
63
62
deflate->init();
64
63
65
64
parents: list of string = nil;
66
- sha := arg->arg();
67
65
68
- while((c := arg->opt()) != 0)
69
- {
70
- case c
71
- {
66
+ sha := hd args;
67
+ arg->init(args);
68
+
69
+ while((c := arg->opt()) != 0){
70
+ case c{
72
71
73
72
'p' => parents = arg->arg() :: parents;
74
73
* => usage(); return;
75
74
}
76
75
}
77
76
78
- commit(sha, parents);
77
+ commit(sha, parents, arg->argv() );
79
78
}
80
79
81
- commit(treesha: string, parents: list of string): string
80
+ commit(treesha: string, parents: list of string, args: list of string ): string
82
81
{
83
82
if(!utils->exists(treesha)){
84
83
sys->fprint(stderr, "no such tree file\n");
85
84
return "";
86
85
}
87
-
88
86
for(l := parents; l != nil; l = tl l){
89
87
if(!utils->exists(hd l)){
90
88
sys->fprint(stderr, "no such sha file: %s\n", hd l);
@@ -100,15 +98,34 @@ commit(treesha: string, parents: list of string): string
100
98
}
101
99
config: ref Strhash[ref Config];
102
100
config = utils->getuserinfo();
103
- authorname := env->getenv("AUTHOR_NAME");
104
- authoremail := env->getenv("AUTHOR_EMAIL");
105
- authordate := env->getenv("AUTHOR_DATE");
101
+
102
+ authorname := hd args;
103
+ args = tl args;
104
+
105
+ authoremail := hd args;
106
+ args = tl args;
106
107
107
- if(authorname == "" || authoremail == ""){
108
- (authorname, authoremail) = getpersoninfo("author");
109
- }
108
+ authordate := hd args;
109
+ args = tl args;
110
110
111
- (comname, comemail) := getpersoninfo("committer");
111
+ comname := hd args;
112
+ args = tl args;
113
+
114
+ comemail := hd args;
115
+ args = tl args;
116
+
117
+ # authorname := env->getenv("AUTHOR_NAME");
118
+ # authoremail := env->getenv("AUTHOR_EMAIL");
119
+ # authordate := env->getenv("AUTHOR_DATE");
120
+ #
121
+ # if(authorname == "" || authoremail == ""){
122
+ # (authorname, authoremail) = getpersoninfo("author");
123
+ # }
124
+ #
125
+ # (comname, comemail) := (config.find("user"), config.find("email")););
126
+ # if(comname == "" || comemail == ""){
127
+ # (comname, comemail) = getpersoninfo("committer");
128
+ # }
112
129
date := daytime->time();
113
130
114
131
if(authordate == "")
@@ -117,7 +134,12 @@ commit(treesha: string, parents: list of string): string
117
134
commitmsg += "author " + authorname + " <" + authoremail + "> " + authordate + "\n";
118
135
commitmsg += "committer " + comname + " <" + comemail + "> " + date + "\n\n";
119
136
120
- commitmsg += getcomment();
137
+ while(args != nil){
138
+ commitmsg += hd args;
139
+ args = tl args;
140
+ }
141
+ # commitmsg += getcomment();
142
+
121
143
122
144
commitlen := int2string(len commitmsg);
123
145
#6 - "commit", 1 - " ", 1 - '\0'
@@ -137,9 +159,13 @@ commit(treesha: string, parents: list of string): string
137
159
ch <-= (0, buf);
138
160
(sz, sha) = <-ch;
139
161
140
- fd := sys->open(REPOPATH + "head", Sys->OWRITE);
141
- sys->fprint(fd, "%s", treesha);
142
- return sha2string(sha);
162
+ fd := sys->create(REPOPATH + "head", Sys->OWRITE, 8r644);
163
+
164
+ ret := sha2string(sha);
165
+
166
+ sys->fprint(fd, "%s", ret);
167
+
168
+ return ret;
143
169
}
144
170
145
171
@@ -149,6 +175,7 @@ getpersoninfo(pos: string): (string, string)
149
175
ibuf := bufio->fopen(sys->fildes(0), bufio->OREAD);
150
176
151
177
sys->print("Enter %s's name: ", pos);
178
+ buf := array[128] of byte;
152
179
name := readline(ibuf);
153
180
154
181
sys->print("Enter %s's email: ", pos);
0 commit comments