6
#include "git-compat-util.h"
7
8
#include "builtin.h"
9
-#include "cache-tree.h"
10
-#include "commit.h"
9
#include "environment.h"
12
-#include "gettext.h"
13
-#include "hash.h"
10
#include "hex.h"
11
#include "lockfile.h"
12
#include "merge-ort.h"
14
#include "parse-options.h"
15
#include "refs.h"
16
#include "revision.h"
21
-#include "sequencer.h"
22
-#include "setup.h"
17
#include "strvec.h"
18
#include <oidset.h>
19
#include <tree.h>
96
pickme_tree = repo_get_commit_tree(the_repository, pickme);
97
base_tree = repo_get_commit_tree(the_repository, base);
98
99
+ merge_opt->branch1 = short_commit_name(last_commit);
100
merge_opt->branch2 = short_commit_name(pickme);
101
merge_opt->ancestor = xstrfmt("parent of %s", merge_opt->branch2);
102
117
{
118
struct commit *onto;
119
const char *onto_name = NULL;
125
- struct commit *last_commit = NULL, *last_picked_commit = NULL;
126
- struct lock_file lock = LOCK_INIT;
120
+ struct commit *last_commit = NULL;
121
struct strvec rev_walk_args = STRVEC_INIT;
122
struct rev_info revs;
123
struct commit *commit;
124
struct merge_options merge_opt;
131
- struct tree *head_tree;
125
struct merge_result result;
133
- struct strbuf reflog_msg = STRBUF_INIT;
126
struct strbuf branch_name = STRBUF_INIT;
127
int ret = 0;
128
153
onto = peel_committish(onto_name);
154
strbuf_addf(&branch_name, "refs/heads/%s", argv[2]);
155
164
- repo_hold_locked_index(the_repository, &lock, LOCK_DIE_ON_ERROR);
165
- if (repo_read_index(the_repository) < 0)
166
- BUG("Could not read index");
167
-
156
repo_init_revisions(the_repository, &revs, prefix);
157
158
strvec_pushl(&rev_walk_args, "", argv[2], "--not", argv[1], NULL);
215
init_merge_options(&merge_opt, the_repository);
216
memset(&result, 0, sizeof(result));
217
merge_opt.show_rename_progress = 0;
230
- merge_opt.branch1 = "HEAD";
231
- head_tree = repo_get_commit_tree(the_repository, onto);
232
- result.tree = head_tree;
218
+ result.tree = repo_get_commit_tree(the_repository, onto);
219
last_commit = onto;
220
while ((commit = get_revision(&revs))) {
235
- struct commit *pick;
221
+ const struct name_decoration *decoration;
222
223
if (!commit->parents)
224
die(_("replaying down to root commit is not supported yet!"));
225
if (commit->parents->next)
226
die(_("replaying merge commits is not supported yet!"));
227
242
- pick = pick_regular_commit(commit, last_commit, &merge_opt, &result);
243
- if (!pick)
228
+ last_commit = pick_regular_commit(commit, last_commit, &merge_opt, &result);
229
+ if (!last_commit)
230
break;
245
- last_commit = pick;
246
- last_picked_commit = commit;
231
+
232
+ decoration = get_name_decoration(&commit->object);
233
+ if (!decoration)
234
+ continue;
235
+
236
+ while (decoration) {
237
+ if (decoration->type == DECORATION_REF_LOCAL) {
238
+ printf("update %s %s %s\n",
239
+ decoration->name,
240
+ oid_to_hex(&last_commit->object.oid),
241
+ oid_to_hex(&commit->object.oid));
242
+ }
243
+ decoration = decoration->next;
244
+ }
245
}
246
247
merge_finalize(&merge_opt, &result);
248
+ ret = result.clean;
249
251
- if (result.clean < 0)
252
- exit(128);
253
-
254
- if (result.clean) {
255
- strbuf_addf(&reflog_msg, "finish rebase %s onto %s",
256
- oid_to_hex(&last_picked_commit->object.oid),
257
- oid_to_hex(&last_commit->object.oid));
258
- if (update_ref(reflog_msg.buf, branch_name.buf,
259
- &last_commit->object.oid,
260
- &last_picked_commit->object.oid,
261
- REF_NO_DEREF, UPDATE_REFS_MSG_ON_ERR)) {
262
- error(_("could not update %s"), argv[2]);
263
- die("Failed to update %s", argv[2]);
264
- }
265
- if (create_symref("HEAD", branch_name.buf, reflog_msg.buf) < 0)
266
- die(_("unable to update HEAD"));
267
- } else {
268
- strbuf_addf(&reflog_msg, "rebase progress up to %s",
269
- oid_to_hex(&last_picked_commit->object.oid));
270
- if (update_ref(reflog_msg.buf, "HEAD",
271
- &last_commit->object.oid,
272
- &onto->object.oid,
273
- REF_NO_DEREF, UPDATE_REFS_MSG_ON_ERR)) {
274
- error(_("could not update %s"), argv[2]);
275
- die("Failed to update %s", argv[2]);
276
- }
277
- }
278
- ret = (result.clean == 0);
250
cleanup:
280
- strbuf_release(&reflog_msg);
251
strbuf_release(&branch_name);
252
release_revisions(&revs);
283
- return ret;
253
+
254
+ /* Return */
255
+ if (ret < 0)
256
+ exit(128);
257
+ return ret ? 0 : 1;
258
}