diff_unique_abbrev: rename to diff_aligned_abbrev

The word "align" describes how the function actually differs from find_unique_abbrev, and will make it less confusing when we add more diff-specific abbrevation functions that do not do this alignment. Since this is a globally available function, let's also move its descriptive comment to the header file, where we typically document function interfaces. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Oct 20, 2016 at 02:19 UTC d5e3b01e5bd6b06c06dbd5d1e2257d57e6b1deb7
3 files changed +11 -11
combine-diff.c
+3 -3
@@ -1203,9 +1203,9 @@ static void show_raw_diff(struct combine_diff_path *p, int num_parent, struct re
1203
1204 /* Show sha1's */
1205 for (i = 0; i < num_parent; i++)
1206 - printf(" %s", diff_unique_abbrev(p->parent[i].oid.hash,
1207 - opt->abbrev));
1208 - printf(" %s ", diff_unique_abbrev(p->oid.hash, opt->abbrev));
1206 + printf(" %s", diff_aligned_abbrev(p->parent[i].oid.hash,
1207 + opt->abbrev));
1208 + printf(" %s ", diff_aligned_abbrev(p->oid.hash, opt->abbrev));
1209 }
1210
1211 if (opt->output_format & (DIFF_FORMAT_RAW | DIFF_FORMAT_NAME_STATUS)) {
diff.c
+3 -7
@@ -4157,11 +4157,7 @@ void diff_free_filepair(struct diff_filepair *p)
4157 free(p);
4158 }
4159
4160 -/*
4161 - * This is different from find_unique_abbrev() in that
4162 - * it stuffs the result with dots for alignment.
4163 - */
4164 -const char *diff_unique_abbrev(const unsigned char *sha1, int len)
4160 +const char *diff_aligned_abbrev(const unsigned char *sha1, int len)
4161 {
4162 int abblen;
4163 const char *abbrev;
@@ -4209,9 +4205,9 @@ static void diff_flush_raw(struct diff_filepair *p, struct diff_options *opt)
4205 fprintf(opt->file, "%s", diff_line_prefix(opt));
4206 if (!(opt->output_format & DIFF_FORMAT_NAME_STATUS)) {
4207 fprintf(opt->file, ":%06o %06o %s ", p->one->mode, p->two->mode,
4212 - diff_unique_abbrev(p->one->oid.hash, opt->abbrev));
4208 + diff_aligned_abbrev(p->one->oid.hash, opt->abbrev));
4209 fprintf(opt->file, "%s ",
4214 - diff_unique_abbrev(p->two->oid.hash, opt->abbrev));
4210 + diff_aligned_abbrev(p->two->oid.hash, opt->abbrev));
4211 }
4212 if (p->score) {
4213 fprintf(opt->file, "%c%03d%c", p->status, similarity_index(p),
diff.h
+5 -1
@@ -340,7 +340,11 @@ extern void diff_warn_rename_limit(const char *varname, int needed, int degraded
340 #define DIFF_STATUS_FILTER_AON '*'
341 #define DIFF_STATUS_FILTER_BROKEN 'B'
342
343 -extern const char *diff_unique_abbrev(const unsigned char *, int);
343 +/*
344 + * This is different from find_unique_abbrev() in that
345 + * it stuffs the result with dots for alignment.
346 + */
347 +extern const char *diff_aligned_abbrev(const unsigned char *sha1, int);
348
349 /* do not report anything on removed paths */
350 #define DIFF_SILENT_ON_REMOVED 01