commit - eaccb85f7218ef3615353170a2a64ec1c48028e2
commit + fc76cabb0c70b61d89701fce09ff96e538615379
blob - 86250c11fe57924c5ca80e01cac4cd1188d8e075
blob + a6bdde165134042c5baf59120676cb60d8c8d153
--- lib/fileindex.c
+++ lib/fileindex.c
const struct got_error *
got_fileindex_entry_alloc(struct got_fileindex_entry **entry,
- const char *ondisk_path, const char *relpath, uint8_t *blob_sha1)
+ const char *ondisk_path, const char *relpath, uint8_t *blob_sha1,
+ uint8_t *commit_sha1)
{
struct stat sb;
size_t len;
(*entry)->mode |= ((sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO)) <<
GOT_INDEX_ENTRY_MODE_PERMS_SHIFT);
memcpy((*entry)->blob_sha1, blob_sha1, SHA1_DIGEST_LENGTH);
+ memcpy((*entry)->commit_sha1, commit_sha1, SHA1_DIGEST_LENGTH);
len = strlen(relpath);
if (len > GOT_INDEX_ENTRY_F_PATH_LEN)
len = GOT_INDEX_ENTRY_F_PATH_LEN;
if (n != SHA1_DIGEST_LENGTH)
return got_ferror(outfile, GOT_ERR_IO);
+ SHA1Update(ctx, entry->commit_sha1, SHA1_DIGEST_LENGTH);
+ n = fwrite(entry->commit_sha1, 1, SHA1_DIGEST_LENGTH, outfile);
+ if (n != SHA1_DIGEST_LENGTH)
+ return got_ferror(outfile, GOT_ERR_IO);
+
err = write_fileindex_val32(ctx, entry->flags, outfile);
if (err)
return err;
}
SHA1Update(ctx, entry->blob_sha1, SHA1_DIGEST_LENGTH);
+ n = fread(entry->commit_sha1, 1, SHA1_DIGEST_LENGTH, infile);
+ if (n != SHA1_DIGEST_LENGTH) {
+ err = got_ferror(infile, GOT_ERR_IO);
+ goto done;
+ }
+ SHA1Update(ctx, entry->commit_sha1, SHA1_DIGEST_LENGTH);
+
err = read_fileindex_val32(&entry->flags, ctx, infile);
if (err)
goto done;
blob - d0855bedd7a7257124e3ec233a0cae2cb93b85ad
blob + e8716e82b5c7226df522570f9907830e40f4274d
--- lib/got_lib_fileindex.h
+++ lib/got_lib_fileindex.h
/* SHA1 of corresponding blob in repository. */
uint8_t blob_sha1[SHA1_DIGEST_LENGTH];
+ /* SHA1 of corresponding base commit in repository. */
+ uint8_t commit_sha1[SHA1_DIGEST_LENGTH];
+
uint32_t flags;
#define GOT_INDEX_ENTRY_F_PATH_LEN 0x00000fff
#define GOT_INDEX_ENTRY_F_STAGE 0x00003000
};
const struct got_error *got_fileindex_entry_alloc(struct got_fileindex_entry **,
- const char *, const char *, uint8_t *);
+ const char *, const char *, uint8_t *, uint8_t *);
void got_fileindex_entry_free(struct got_fileindex_entry *);
struct got_fileindex *got_fileindex_alloc(void);
void got_fileindex_free(struct got_fileindex *);
blob - 4656e2e4a0598b526e576e75b85fc270885e00a5
blob + f8d6e1c9f31ed998a56d9e161ceda32926f2ba60
--- lib/worktree.c
+++ lib/worktree.c
fsync(fd);
err = got_fileindex_entry_alloc(&entry, ondisk_path,
- apply_path_prefix(worktree, path), blob->id.sha1);
+ apply_path_prefix(worktree, path), blob->id.sha1,
+ worktree->base_commit_id->sha1);
if (err)
goto done;