commit - 0cb83759ff5e9ca28c397bb04edb8e0629eba4bd
commit + fdfa9bf28f9d53053ad4687f6cd06c86cfe31b33
blob - 9963b821c1f57a0322e8913d88df883c8de53679
blob + c985f53d8a15c95d1676fac487eee6262a70e492
--- include/got_worktree.h
+++ include/got_worktree.h
const struct got_error *got_worktree_get_histedit_script_path(char **,
struct got_worktree *);
-/* Stage the specified paths for commit. */
+/*
+ * Stage the specified paths for commit.
+ * If the 'data' pointer of a pathlist element on the path list is NULL then
+ * stage the content of the entire file at this path. Otherwise, the 'data'
+ * pointer is expected to point at a const char * path of a file which
+ * contains alternative content to be staged instead.
+*/
const struct got_error *got_worktree_stage_paths(struct got_worktree *,
struct got_pathlist_head *, struct got_repository *,
got_worktree_status_cb, void *,
blob - e2d15ef7a6c7d7222b3bcc4ffe515453b008c1f9
blob + a88831b22abee7e7511276c0faba475a036c7c69
--- lib/worktree.c
+++ lib/worktree.c
}
static const struct got_error *
-stage_path(const char *path, size_t path_len, struct got_worktree *worktree,
- struct got_fileindex *fileindex, struct got_repository *repo,
+stage_path(const char *path, size_t path_len, const char *path_content,
+ struct got_worktree *worktree, struct got_fileindex *fileindex,
+ struct got_repository *repo,
got_worktree_status_cb status_cb, void *status_arg)
{
const struct got_error *err = NULL;
switch (status) {
case GOT_STATUS_ADD:
case GOT_STATUS_MODIFY:
- err = got_object_blob_create(&blob_id, ondisk_path,
- repo);
+ err = got_object_blob_create(&blob_id,
+ path_content ? path_content : ondisk_path, repo);
if (err)
goto done;
memcpy(ie->staged_blob_sha1, blob_id->sha1,
if (err)
break;
}
- err = stage_path(pe->path, pe->path_len, worktree, fileindex,
- repo, status_cb, status_arg);
+ err = stage_path(pe->path, pe->path_len, (const char *)pe->data,
+ worktree, fileindex, repo, status_cb, status_arg);
if (err)
break;
}