diff: --full-index
A new option, --full-index, is introduced to diff family. This causes the full object name of pre- and post-images to appear on the index line of patch formatted output, to be used in conjunction with --allow-binary-replacement option of git-apply. Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
@ -13,6 +13,11 @@
|
|||||||
--name-status::
|
--name-status::
|
||||||
Show only names and status of changed files.
|
Show only names and status of changed files.
|
||||||
|
|
||||||
|
--full-index::
|
||||||
|
Instead of the first handful characters, show full
|
||||||
|
object name of pre- and post-image blob on the "index"
|
||||||
|
line when generating a patch format output.
|
||||||
|
|
||||||
-B::
|
-B::
|
||||||
Break complete rewrite changes into pairs of delete and create.
|
Break complete rewrite changes into pairs of delete and create.
|
||||||
|
|
||||||
|
14
diff.c
14
diff.c
@ -650,7 +650,7 @@ static void diff_fill_sha1_info(struct diff_filespec *one)
|
|||||||
memset(one->sha1, 0, 20);
|
memset(one->sha1, 0, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void run_diff(struct diff_filepair *p)
|
static void run_diff(struct diff_filepair *p, struct diff_options *o)
|
||||||
{
|
{
|
||||||
const char *pgm = external_diff();
|
const char *pgm = external_diff();
|
||||||
char msg[PATH_MAX*2+300], *xfrm_msg;
|
char msg[PATH_MAX*2+300], *xfrm_msg;
|
||||||
@ -713,11 +713,11 @@ static void run_diff(struct diff_filepair *p)
|
|||||||
|
|
||||||
if (memcmp(one->sha1, two->sha1, 20)) {
|
if (memcmp(one->sha1, two->sha1, 20)) {
|
||||||
char one_sha1[41];
|
char one_sha1[41];
|
||||||
|
const char *index_fmt = o->full_index ? "index %s..%s" : "index %.7s..%.7s";
|
||||||
memcpy(one_sha1, sha1_to_hex(one->sha1), 41);
|
memcpy(one_sha1, sha1_to_hex(one->sha1), 41);
|
||||||
|
|
||||||
len += snprintf(msg + len, sizeof(msg) - len,
|
len += snprintf(msg + len, sizeof(msg) - len,
|
||||||
"index %.7s..%.7s", one_sha1,
|
index_fmt, one_sha1, sha1_to_hex(two->sha1));
|
||||||
sha1_to_hex(two->sha1));
|
|
||||||
if (one->mode == two->mode)
|
if (one->mode == two->mode)
|
||||||
len += snprintf(msg + len, sizeof(msg) - len,
|
len += snprintf(msg + len, sizeof(msg) - len,
|
||||||
" %06o", one->mode);
|
" %06o", one->mode);
|
||||||
@ -794,6 +794,8 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
|
|||||||
options->line_termination = 0;
|
options->line_termination = 0;
|
||||||
else if (!strncmp(arg, "-l", 2))
|
else if (!strncmp(arg, "-l", 2))
|
||||||
options->rename_limit = strtoul(arg+2, NULL, 10);
|
options->rename_limit = strtoul(arg+2, NULL, 10);
|
||||||
|
else if (!strcmp(arg, "--full-index"))
|
||||||
|
options->full_index = 1;
|
||||||
else if (!strcmp(arg, "--name-only"))
|
else if (!strcmp(arg, "--name-only"))
|
||||||
options->output_format = DIFF_FORMAT_NAME;
|
options->output_format = DIFF_FORMAT_NAME;
|
||||||
else if (!strcmp(arg, "--name-status"))
|
else if (!strcmp(arg, "--name-status"))
|
||||||
@ -1022,7 +1024,7 @@ int diff_unmodified_pair(struct diff_filepair *p)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void diff_flush_patch(struct diff_filepair *p)
|
static void diff_flush_patch(struct diff_filepair *p, struct diff_options *o)
|
||||||
{
|
{
|
||||||
if (diff_unmodified_pair(p))
|
if (diff_unmodified_pair(p))
|
||||||
return;
|
return;
|
||||||
@ -1031,7 +1033,7 @@ static void diff_flush_patch(struct diff_filepair *p)
|
|||||||
(DIFF_FILE_VALID(p->two) && S_ISDIR(p->two->mode)))
|
(DIFF_FILE_VALID(p->two) && S_ISDIR(p->two->mode)))
|
||||||
return; /* no tree diffs in patch format */
|
return; /* no tree diffs in patch format */
|
||||||
|
|
||||||
run_diff(p);
|
run_diff(p, o);
|
||||||
}
|
}
|
||||||
|
|
||||||
int diff_queue_is_empty(void)
|
int diff_queue_is_empty(void)
|
||||||
@ -1163,7 +1165,7 @@ void diff_flush(struct diff_options *options)
|
|||||||
die("internal error in diff-resolve-rename-copy");
|
die("internal error in diff-resolve-rename-copy");
|
||||||
switch (diff_output_format) {
|
switch (diff_output_format) {
|
||||||
case DIFF_FORMAT_PATCH:
|
case DIFF_FORMAT_PATCH:
|
||||||
diff_flush_patch(p);
|
diff_flush_patch(p, options);
|
||||||
break;
|
break;
|
||||||
case DIFF_FORMAT_RAW:
|
case DIFF_FORMAT_RAW:
|
||||||
case DIFF_FORMAT_NAME_STATUS:
|
case DIFF_FORMAT_NAME_STATUS:
|
||||||
|
4
diff.h
4
diff.h
@ -32,7 +32,8 @@ struct diff_options {
|
|||||||
const char *orderfile;
|
const char *orderfile;
|
||||||
const char *pickaxe;
|
const char *pickaxe;
|
||||||
unsigned recursive:1,
|
unsigned recursive:1,
|
||||||
tree_in_recursive:1;
|
tree_in_recursive:1,
|
||||||
|
full_index:1;
|
||||||
int break_opt;
|
int break_opt;
|
||||||
int detect_rename;
|
int detect_rename;
|
||||||
int find_copies_harder;
|
int find_copies_harder;
|
||||||
@ -96,6 +97,7 @@ extern void diffcore_std_no_resolve(struct diff_options *);
|
|||||||
" -u synonym for -p.\n" \
|
" -u synonym for -p.\n" \
|
||||||
" --name-only show only names of changed files.\n" \
|
" --name-only show only names of changed files.\n" \
|
||||||
" --name-status show names and status of changed files.\n" \
|
" --name-status show names and status of changed files.\n" \
|
||||||
|
" --full-index show full object name on index ines.\n" \
|
||||||
" -R swap input file pairs.\n" \
|
" -R swap input file pairs.\n" \
|
||||||
" -B detect complete rewrites.\n" \
|
" -B detect complete rewrites.\n" \
|
||||||
" -M detect renames.\n" \
|
" -M detect renames.\n" \
|
||||||
|
Reference in New Issue
Block a user