commit - c363b2c176847929422503bc59dede412e83f0ae
commit + 537ac44b6c471f75e8dd4abf6e16d0a775d9dded
blob - 37d1d68664b112530292c1107beaf2d6d59b2340
blob + dae6672247158b8fbc4f7a5261aa087743531d3a
--- got/got.c
+++ got/got.c
static const struct got_error *
print_diff(void *arg, unsigned char status, unsigned char staged_status,
const char *path, struct got_object_id *blob_id,
- struct got_object_id *commit_id)
+ struct got_object_id *staged_blob_id, struct got_object_id *commit_id)
{
struct print_diff_arg *a = arg;
const struct got_error *err = NULL;
static const struct got_error *
print_status(void *arg, unsigned char status, unsigned char staged_status,
const char *path, struct got_object_id *blob_id,
- struct got_object_id *commit_id)
+ struct got_object_id *staged_blob_id, struct got_object_id *commit_id)
{
if (status == staged_status &&
(status == GOT_STATUS_ADD || status == GOT_STATUS_DELETE))
blob - 52674a343e3a62182995e05f88e313dadc8bc688
blob + 371f24f3fab3bd6ac857e1702676f26aa16095f8
--- include/got_worktree.h
+++ include/got_worktree.h
/* A callback function which is invoked to report a path's status. */
typedef const struct got_error *(*got_worktree_status_cb)(void *,
unsigned char, unsigned char, const char *, struct got_object_id *,
- struct got_object_id *);
+ struct got_object_id *, struct got_object_id *);
/*
* Report the status of paths in the work tree.
blob - eaffa11cd7493c261c0313a98f515371d10ebe42
blob + 4b2e43983065a80504a44a2a3afdcc6d5c13462d
--- lib/worktree.c
+++ lib/worktree.c
unsigned char status = GOT_STATUS_NO_CHANGE;
unsigned char staged_status = get_staged_status(ie);
struct stat sb;
- struct got_object_id blob_id, commit_id;
+ struct got_object_id blob_id, commit_id, staged_blob_id;
err = get_file_status(&status, &sb, ie, abspath, repo);
if (err == NULL && (status != GOT_STATUS_NO_CHANGE ||
staged_status != GOT_STATUS_NO_CHANGE)) {
memcpy(blob_id.sha1, ie->blob_sha1, SHA1_DIGEST_LENGTH);
memcpy(commit_id.sha1, ie->commit_sha1, SHA1_DIGEST_LENGTH);
- err = (*status_cb)(status_arg, status, staged_status,
- ie->path, &blob_id, &commit_id);
+ if (staged_status == GOT_STATUS_ADD ||
+ staged_status == GOT_STATUS_MODIFY) {
+ memcpy(staged_blob_id.sha1, ie->staged_blob_sha1,
+ SHA1_DIGEST_LENGTH);
+ err = (*status_cb)(status_arg, status, staged_status,
+ ie->path, &blob_id, &staged_blob_id, &commit_id);
+ } else
+ err = (*status_cb)(status_arg, status, staged_status,
+ ie->path, &blob_id, NULL, &commit_id);
}
return err;
}
else
status = GOT_STATUS_DELETE;
return (*a->status_cb)(a->status_arg, status, get_staged_status(ie),
- ie->path, &blob_id, &commit_id);
+ ie->path, &blob_id, NULL, &commit_id);
}
static const struct got_error *
if (got_path_is_child(path, a->status_path, a->status_path_len))
err = (*a->status_cb)(a->status_arg, GOT_STATUS_UNVERSIONED,
- GOT_STATUS_NO_CHANGE, path, NULL, NULL);
+ GOT_STATUS_NO_CHANGE, path, NULL, NULL, NULL);
if (parent_path[0])
free(path);
return err;
if (S_ISREG(sb.st_mode))
return (*status_cb)(status_arg, GOT_STATUS_UNVERSIONED,
- GOT_STATUS_NO_CHANGE, path, NULL, NULL);
+ GOT_STATUS_NO_CHANGE, path, NULL, NULL, NULL);
return NULL;
}
static const struct got_error *
collect_commitables(void *arg, unsigned char status,
unsigned char staged_status, const char *relpath,
- struct got_object_id *blob_id, struct got_object_id *commit_id)
+ struct got_object_id *blob_id, struct got_object_id *staged_blob_id,
+ struct got_object_id *commit_id)
{
struct collect_commitables_arg *a = arg;
const struct got_error *err = NULL;
while (ct_path[0] == '/')
ct_path++;
return (*status_cb)(status_arg, ct->status, GOT_STATUS_NO_CHANGE,
- ct_path, ct->blob_id, NULL);
+ ct_path, ct->blob_id, NULL, NULL);
}
static const struct got_error *
static const struct got_error *
rebase_status(void *arg, unsigned char status, unsigned char staged_status,
const char *path, struct got_object_id *blob_id,
- struct got_object_id *commit_id)
+ struct got_object_id *staged_blob_id, struct got_object_id *commit_id)
{
return NULL;
}
static const struct got_error *
collect_revertible_paths(void *arg, unsigned char status,
unsigned char staged_status, const char *relpath,
- struct got_object_id *blob_id, struct got_object_id *commit_id)
+ struct got_object_id *blob_id, struct got_object_id *staged_blob_id,
+ struct got_object_id *commit_id)
{
struct collect_revertible_paths_arg *a = arg;
const struct got_error *err = NULL;
struct got_fileindex_entry *ie;
unsigned char status;
struct stat sb;
- struct got_object_id *blob_id = NULL;
+ struct got_object_id blob_id, *staged_blob_id = NULL;
uint32_t stage;
ie = got_fileindex_entry_get(fileindex, relpath, strlen(relpath));
switch (status) {
case GOT_STATUS_ADD:
case GOT_STATUS_MODIFY:
- err = got_object_blob_create(&blob_id,
+ err = got_object_blob_create(&staged_blob_id,
path_content ? path_content : ondisk_path, repo);
if (err)
goto done;
- memcpy(ie->staged_blob_sha1, blob_id->sha1,
+ memcpy(&blob_id.sha1, ie->blob_sha1, SHA1_DIGEST_LENGTH);
+ memcpy(ie->staged_blob_sha1, staged_blob_id->sha1,
SHA1_DIGEST_LENGTH);
if (status == GOT_STATUS_ADD)
stage = GOT_FILEIDX_STAGE_ADD;
else
stage = GOT_FILEIDX_STAGE_MODIFY;
+ got_fileindex_entry_stage_set(ie, stage);
+ err = (*status_cb)(status_arg, GOT_STATUS_NO_CHANGE,
+ get_staged_status(ie), relpath, &blob_id,
+ staged_blob_id, NULL);
break;
case GOT_STATUS_DELETE:
stage = GOT_FILEIDX_STAGE_DELETE;
+ got_fileindex_entry_stage_set(ie, stage);
+ err = (*status_cb)(status_arg, GOT_STATUS_NO_CHANGE,
+ get_staged_status(ie), relpath, NULL, NULL, NULL);
break;
default:
err = got_error_path(relpath, GOT_ERR_FILE_STATUS);
- goto done;
+ break;
}
-
- got_fileindex_entry_stage_set(ie, stage);
- err = (*status_cb)(status_arg, GOT_STATUS_NO_CHANGE,
- get_staged_status(ie), relpath, blob_id, NULL);
done:
- free(blob_id);
+ free(staged_blob_id);
return err;
}