Merge branch 'jk/commit-v-strip'
* jk/commit-v-strip: status: show "-v" diff even for initial commit wt-status: refactor initial commit printing define empty tree sha1 as a macro
This commit is contained in:
commit
47a792539a
6
cache.h
6
cache.h
@ -530,6 +530,12 @@ static inline void hashclr(unsigned char *hash)
|
||||
}
|
||||
extern int is_empty_blob_sha1(const unsigned char *sha1);
|
||||
|
||||
#define EMPTY_TREE_SHA1_HEX \
|
||||
"4b825dc642cb6eb9a060e54bf8d69288fbee4904"
|
||||
#define EMPTY_TREE_SHA1_BIN \
|
||||
"\x4b\x82\x5d\xc6\x42\xcb\x6e\xb9\xa0\x60" \
|
||||
"\xe5\x4b\xf8\xd6\x92\x88\xfb\xee\x49\x04"
|
||||
|
||||
int git_mkstemp(char *path, size_t n, const char *template);
|
||||
|
||||
/*
|
||||
|
@ -2055,9 +2055,7 @@ static struct cached_object {
|
||||
static int cached_object_nr, cached_object_alloc;
|
||||
|
||||
static struct cached_object empty_tree = {
|
||||
/* empty tree sha1: 4b825dc642cb6eb9a060e54bf8d69288fbee4904 */
|
||||
"\x4b\x82\x5d\xc6\x42\xcb\x6e\xb9\xa0\x60"
|
||||
"\xe5\x4b\xf8\xd6\x92\x88\xfb\xee\x49\x04",
|
||||
EMPTY_TREE_SHA1_BIN,
|
||||
OBJ_TREE,
|
||||
"",
|
||||
0
|
||||
|
@ -22,7 +22,7 @@ test_expect_success 'setup' '
|
||||
git commit -F message
|
||||
'
|
||||
|
||||
test_expect_failure 'initial commit shows verbose diff' '
|
||||
test_expect_success 'initial commit shows verbose diff' '
|
||||
git commit --amend -v
|
||||
'
|
||||
|
||||
|
33
wt-status.c
33
wt-status.c
@ -185,31 +185,12 @@ static void wt_status_print_changed_cb(struct diff_queue_struct *q,
|
||||
wt_status_print_trailer(s);
|
||||
}
|
||||
|
||||
static void wt_status_print_initial(struct wt_status *s)
|
||||
{
|
||||
int i;
|
||||
struct strbuf buf = STRBUF_INIT;
|
||||
|
||||
if (active_nr) {
|
||||
s->commitable = 1;
|
||||
wt_status_print_cached_header(s);
|
||||
}
|
||||
for (i = 0; i < active_nr; i++) {
|
||||
color_fprintf(s->fp, color(WT_STATUS_HEADER), "#\t");
|
||||
color_fprintf_ln(s->fp, color(WT_STATUS_UPDATED), "new file: %s",
|
||||
quote_path(active_cache[i]->name, -1,
|
||||
&buf, s->prefix));
|
||||
}
|
||||
if (active_nr)
|
||||
wt_status_print_trailer(s);
|
||||
strbuf_release(&buf);
|
||||
}
|
||||
|
||||
static void wt_status_print_updated(struct wt_status *s)
|
||||
{
|
||||
struct rev_info rev;
|
||||
init_revisions(&rev, NULL);
|
||||
setup_revisions(0, NULL, &rev, s->reference);
|
||||
setup_revisions(0, NULL, &rev,
|
||||
s->is_initial ? EMPTY_TREE_SHA1_HEX : s->reference);
|
||||
rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;
|
||||
rev.diffopt.format_callback = wt_status_print_updated_cb;
|
||||
rev.diffopt.format_callback_data = s;
|
||||
@ -298,7 +279,8 @@ static void wt_status_print_verbose(struct wt_status *s)
|
||||
struct rev_info rev;
|
||||
|
||||
init_revisions(&rev, NULL);
|
||||
setup_revisions(0, NULL, &rev, s->reference);
|
||||
setup_revisions(0, NULL, &rev,
|
||||
s->is_initial ? EMPTY_TREE_SHA1_HEX : s->reference);
|
||||
rev.diffopt.output_format |= DIFF_FORMAT_PATCH;
|
||||
rev.diffopt.detect_rename = 1;
|
||||
DIFF_OPT_SET(&rev.diffopt, ALLOW_TEXTCONV);
|
||||
@ -360,12 +342,9 @@ void wt_status_print(struct wt_status *s)
|
||||
color_fprintf_ln(s->fp, color(WT_STATUS_HEADER), "#");
|
||||
color_fprintf_ln(s->fp, color(WT_STATUS_HEADER), "# Initial commit");
|
||||
color_fprintf_ln(s->fp, color(WT_STATUS_HEADER), "#");
|
||||
wt_status_print_initial(s);
|
||||
}
|
||||
else {
|
||||
wt_status_print_updated(s);
|
||||
}
|
||||
|
||||
wt_status_print_updated(s);
|
||||
wt_status_print_changed(s);
|
||||
if (wt_status_submodule_summary)
|
||||
wt_status_print_submodule_summary(s);
|
||||
@ -374,7 +353,7 @@ void wt_status_print(struct wt_status *s)
|
||||
else if (s->commitable)
|
||||
fprintf(s->fp, "# Untracked files not listed (use -u option to show untracked files)\n");
|
||||
|
||||
if (s->verbose && !s->is_initial)
|
||||
if (s->verbose)
|
||||
wt_status_print_verbose(s);
|
||||
if (!s->commitable) {
|
||||
if (s->amend)
|
||||
|
Loading…
Reference in New Issue
Block a user