author | Junio C Hamano <gitster@pobox.com> | |
Sun, 16 Nov 2008 08:48:59 +0000 (00:48 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 16 Nov 2008 08:48:59 +0000 (00:48 -0800) |
* 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
status: show "-v" diff even for initial commit
wt-status: refactor initial commit printing
define empty tree sha1 as a macro
cache.h | patch | blob | history | |
sha1_file.c | patch | blob | history | |
t/t7507-commit-verbose.sh | patch | blob | history | |
wt-status.c | patch | blob | history |
index 3b5f0c4c003a611b45e2ca9455681dc8a8347516..7efba7756d3658996f2cda4f79f1c5d2072ed51c 100644 (file)
--- a/cache.h
+++ b/cache.h
}
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);
/*
diff --git a/sha1_file.c b/sha1_file.c
index 0fa65baa59de4db058ca6a41bba29ac78eab2643..75a748a644f8f11c7bcb372fe74fbfb00faf1796 100644 (file)
--- a/sha1_file.c
+++ b/sha1_file.c
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
index 519adba80b4e5bc23a68c4bdcae607cf2d403c23..da5bd3b5a585667dad97481df27049f0aa7415eb 100755 (executable)
git commit -F message
'
-test_expect_failure 'initial commit shows verbose diff' '
+test_expect_success 'initial commit shows verbose diff' '
git commit --amend -v
'
diff --git a/wt-status.c b/wt-status.c
index 6a7645ed86fd5879e959460011a8add015d392d9..3edae43ce9d99b27ed69166d90db71bc3c219404 100644 (file)
--- a/wt-status.c
+++ b/wt-status.c
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;
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);
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);
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)