Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-12-05 23:52:43 +0300
committerJunio C Hamano <gitster@pobox.com>2019-12-05 23:52:43 +0300
commitf7998d979322c439578a4334524ae2c924042705 (patch)
treedee4df2a225eebc8e83bb5b54fa93835cdf3b498 /diff.c
parent917d0d6234be4c6ce4ab0feea15911bfa5e65253 (diff)
parent8c159044625e46de67cd8467f07424f38eb8301e (diff)
Merge branch 'js/builtin-add-i'
The beginning of rewriting "git add -i" in C. * js/builtin-add-i: built-in add -i: implement the `help` command built-in add -i: use color in the main loop built-in add -i: support `?` (prompt help) built-in add -i: show unique prefixes of the commands built-in add -i: implement the main loop built-in add -i: color the header in the `status` command built-in add -i: implement the `status` command diff: export diffstat interface Start to implement a built-in version of `git add --interactive`
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c39
1 files changed, 16 insertions, 23 deletions
diff --git a/diff.c b/diff.c
index 087213466e..8e2914c031 100644
--- a/diff.c
+++ b/diff.c
@@ -2495,22 +2495,6 @@ static void pprint_rename(struct strbuf *name, const char *a, const char *b)
}
}
-struct diffstat_t {
- int nr;
- int alloc;
- struct diffstat_file {
- char *from_name;
- char *name;
- char *print_name;
- const char *comments;
- unsigned is_unmerged:1;
- unsigned is_binary:1;
- unsigned is_renamed:1;
- unsigned is_interesting:1;
- uintmax_t added, deleted;
- } **files;
-};
-
static struct diffstat_file *diffstat_add(struct diffstat_t *diffstat,
const char *name_a,
const char *name_b)
@@ -3157,7 +3141,7 @@ static void show_dirstat_by_line(struct diffstat_t *data, struct diff_options *o
gather_dirstat(options, &dir, changed, "", 0);
}
-static void free_diffstat_info(struct diffstat_t *diffstat)
+void free_diffstat_info(struct diffstat_t *diffstat)
{
int i;
for (i = 0; i < diffstat->nr; i++) {
@@ -6283,12 +6267,7 @@ void diff_flush(struct diff_options *options)
dirstat_by_line) {
struct diffstat_t diffstat;
- memset(&diffstat, 0, sizeof(struct diffstat_t));
- for (i = 0; i < q->nr; i++) {
- struct diff_filepair *p = q->queue[i];
- if (check_pair_status(p))
- diff_flush_stat(p, options, &diffstat);
- }
+ compute_diffstat(options, &diffstat, q);
if (output_format & DIFF_FORMAT_NUMSTAT)
show_numstat(&diffstat, options);
if (output_format & DIFF_FORMAT_DIFFSTAT)
@@ -6621,6 +6600,20 @@ static int is_submodule_ignored(const char *path, struct diff_options *options)
return ignored;
}
+void compute_diffstat(struct diff_options *options,
+ struct diffstat_t *diffstat,
+ struct diff_queue_struct *q)
+{
+ int i;
+
+ memset(diffstat, 0, sizeof(struct diffstat_t));
+ for (i = 0; i < q->nr; i++) {
+ struct diff_filepair *p = q->queue[i];
+ if (check_pair_status(p))
+ diff_flush_stat(p, options, diffstat);
+ }
+}
+
void diff_addremove(struct diff_options *options,
int addremove, unsigned mode,
const struct object_id *oid,