commit - 0d5bb27670e5cdef181f8073984fd02be5a42d53
commit + a615e0e7796ea1103a6e0d4b5dbb613459788666
blob - 91a87ba60ac2ebc61140d6778df16fc1e2f39016
blob + 38c6dc6f1c93d31c2b51ea0514de0fbd09d5dfc3
--- lib/worktree.c
+++ lib/worktree.c
}
memcpy(ie->commit_sha1, a->base_commit_id->sha1, SHA1_DIGEST_LENGTH);
return NULL;
+}
+
+static const struct got_error *
+bump_base_commit_id_everywhere(struct got_worktree *worktree,
+ struct got_fileindex *fileindex,
+ got_worktree_checkout_cb progress_cb, void *progress_arg)
+{
+ struct bump_base_commit_id_arg bbc_arg;
+
+ bbc_arg.base_commit_id = worktree->base_commit_id;
+ bbc_arg.entry_name = NULL;
+ bbc_arg.path = "";
+ bbc_arg.path_len = 0;
+ bbc_arg.progress_cb = progress_cb;
+ bbc_arg.progress_arg = progress_arg;
+
+ return got_fileindex_for_each_entry_safe(fileindex,
+ bump_base_commit_id, &bbc_arg);
}
static const struct got_error *
struct got_reference *tmp_branch, struct got_reference *rebased_branch,
struct got_repository *repo)
{
- const struct got_error *err, *unlockerr;
+ const struct got_error *err, *unlockerr, *sync_err;
struct got_object_id *new_head_commit_id = NULL;
+ char *fileindex_path = NULL;
err = got_ref_resolve(&new_head_commit_id, repo, tmp_branch);
if (err)
goto done;
err = delete_rebase_refs(worktree, repo);
+ if (err)
+ goto done;
+
+ err = get_fileindex_path(&fileindex_path, worktree);
+ if (err)
+ goto done;
+ err = bump_base_commit_id_everywhere(worktree, fileindex, NULL, NULL);
+ sync_err = sync_fileindex(fileindex, fileindex_path);
+ if (sync_err && err == NULL)
+ err = sync_err;
done:
- if (fileindex)
- got_fileindex_free(fileindex);
+ got_fileindex_free(fileindex);
+ free(fileindex_path);
free(new_head_commit_id);
unlockerr = lock_worktree(worktree, LOCK_SH);
if (unlockerr && err == NULL)
struct got_fileindex *fileindex, struct got_reference *tmp_branch,
struct got_reference *edited_branch, struct got_repository *repo)
{
- const struct got_error *err, *unlockerr;
+ const struct got_error *err, *unlockerr, *sync_err;
struct got_object_id *new_head_commit_id = NULL;
struct got_reference *resolved = NULL;
+ char *fileindex_path = NULL;
err = got_ref_resolve(&new_head_commit_id, repo, tmp_branch);
if (err)
goto done;
err = delete_histedit_refs(worktree, repo);
+ if (err)
+ goto done;
+
+ err = get_fileindex_path(&fileindex_path, worktree);
+ if (err)
+ goto done;
+ err = bump_base_commit_id_everywhere(worktree, fileindex, NULL, NULL);
+ sync_err = sync_fileindex(fileindex, fileindex_path);
+ if (sync_err && err == NULL)
+ err = sync_err;
done:
- if (fileindex)
- got_fileindex_free(fileindex);
+ got_fileindex_free(fileindex);
+ free(fileindex_path);
free(new_head_commit_id);
unlockerr = lock_worktree(worktree, LOCK_SH);
if (unlockerr && err == NULL)
blob - 3ba776626d052edc2f5f9848a2ce3491cf2c5109
blob + daf60185826466233528db4e050e56876c18cf37
--- regress/cmdline/histedit.sh
+++ regress/cmdline/histedit.sh
ret="$?"
if [ "$ret" != "0" ]; then
diff -u $testroot/diff.expected $testroot/diff
+ test_done "$testroot" "$ret"
+ return 1
fi
+
+ (cd $testroot/wt && got update > $testroot/stdout)
+
+ echo 'Already up-to-date' > $testroot/stdout.expected
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ fi
test_done "$testroot" "$ret"
}
blob - 6d48e72761668deed003b1cc1aaa9aa08f37a772
blob + 2f6c1977edb23682bb4234fb7a1ed7765df8e7a5
--- regress/cmdline/rebase.sh
+++ regress/cmdline/rebase.sh
ret="$?"
if [ "$ret" != "0" ]; then
diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$ret"
+ return 1
fi
+
+ (cd $testroot/wt && got update > $testroot/stdout)
+
+ echo 'Already up-to-date' > $testroot/stdout.expected
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ fi
test_done "$testroot" "$ret"
}