#include "packfile.h"
#include "parse-options.h"
#include "help.h"
-#include "fetch-object.h"
+#include "promisor-remote.h"
#ifdef NO_FAST_WORKING_DIRECTORY
#define FAST_WORKING_DIRECTORY 0
if (ecbdata->opt->flags.dual_color_diffed_diffs)
strbuf_addstr(&msgbuf, reverse);
strbuf_addstr(&msgbuf, frag);
- strbuf_add(&msgbuf, line, ep - line);
+ if (ecbdata->opt->flags.suppress_hunk_header_line_count)
+ strbuf_add(&msgbuf, atat, sizeof(atat));
+ else
+ strbuf_add(&msgbuf, line, ep - line);
strbuf_addstr(&msgbuf, reset);
/*
argv_array_pushf(&env, "GIT_DIFF_PATH_COUNTER=%d", ++o->diff_path_counter);
argv_array_pushf(&env, "GIT_DIFF_PATH_TOTAL=%d", q->nr);
+ diff_free_filespec_data(one);
+ diff_free_filespec_data(two);
if (run_command_v_opt_cd_env(argv.argv, RUN_USING_SHELL, NULL, env.argv))
die(_("external diff died, stopping at %s"), name);
return dst - line;
}
+void flush_one_hunk(struct object_id *result, git_SHA_CTX *ctx)
+{
+ unsigned char hash[GIT_MAX_RAWSZ];
+ unsigned short carry = 0;
+ int i;
+
+ git_SHA1_Final(hash, ctx);
+ git_SHA1_Init(ctx);
+ /* 20-byte sum, with carry */
+ for (i = 0; i < GIT_SHA1_RAWSZ; ++i) {
+ carry += result->hash[i] + hash[i];
+ result->hash[i] = carry;
+ carry >>= 8;
+ }
+}
+
static void patch_id_consume(void *priv, char *line, unsigned long len)
{
struct patch_id_t *data = priv;
git_SHA1_Update(ctx, buf, len);
}
-/* returns 0 upon success, and writes result into sha1 */
-static int diff_get_patch_id(struct diff_options *options, struct object_id *oid, int diff_header_only)
+/* returns 0 upon success, and writes result into oid */
+static int diff_get_patch_id(struct diff_options *options, struct object_id *oid, int diff_header_only, int stable)
{
struct diff_queue_struct *q = &diff_queued_diff;
int i;
git_SHA1_Init(&ctx);
memset(&data, 0, sizeof(struct patch_id_t));
data.ctx = &ctx;
+ oidclr(oid);
for (i = 0; i < q->nr; i++) {
xpparam_t xpp;
patch_id_consume, &data, &xpp, &xecfg))
return error("unable to generate patch-id diff for %s",
p->one->path);
+
+ if (stable)
+ flush_one_hunk(oid, &ctx);
}
- git_SHA1_Final(oid->hash, &ctx);
+ if (!stable)
+ git_SHA1_Final(oid->hash, &ctx);
+
return 0;
}
-int diff_flush_patch_id(struct diff_options *options, struct object_id *oid, int diff_header_only)
+int diff_flush_patch_id(struct diff_options *options, struct object_id *oid, int diff_header_only, int stable)
{
struct diff_queue_struct *q = &diff_queued_diff;
int i;
- int result = diff_get_patch_id(options, oid, diff_header_only);
+ int result = diff_get_patch_id(options, oid, diff_header_only, stable);
for (i = 0; i < q->nr; i++)
diff_free_filepair(q->queue[i]);
const struct diff_filespec *filespec)
{
if (filespec && filespec->oid_valid &&
+ !S_ISGITLINK(filespec->mode) &&
oid_object_info_extended(r, &filespec->oid, NULL,
OBJECT_INFO_FOR_PREFETCH))
oid_array_append(to_fetch, &filespec->oid);
void diffcore_std(struct diff_options *options)
{
- if (options->repo == the_repository &&
- repository_format_partial_clone) {
+ if (options->repo == the_repository && has_promisor_remote()) {
/*
* Prefetch the diff pairs that are about to be flushed.
*/
/*
* NEEDSWORK: Consider deduplicating the OIDs sent.
*/
- fetch_objects(repository_format_partial_clone,
- to_fetch.oid, to_fetch.nr);
+ promisor_remote_get_direct(options->repo,
+ to_fetch.oid, to_fetch.nr);
oid_array_clear(&to_fetch);
}