From fff0d0abdde6729606824688c2acac72db643e65 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Thu, 15 Apr 2010 02:25:38 -0500 Subject: Document new "already-merged" rule for branch -d MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit v1.7.0-rc0~18^2 (branch -d: base the "already-merged" safety on the branch it merges with, 2009-12-29) taught ‘git branch’ a new heuristic for when it is safe to delete a branch without forcing the issue. It is safe to delete a branch "topic" without second thought if: - the branch "topic" is set up to pull from a (remote-tracking, usually) branch and is fully merged in that "upstream" branch, or - there is no branch.topic.merge configuration and branch "topic" is fully merged in the current HEAD. Update the man page to acknowledge the new rules. Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- Documentation/git-branch.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt index b3605c0ec5..60fa684b1d 100644 --- a/Documentation/git-branch.txt +++ b/Documentation/git-branch.txt @@ -63,7 +63,9 @@ way to clean up all obsolete remote-tracking branches. OPTIONS ------- -d:: - Delete a branch. The branch must be fully merged in HEAD. + Delete a branch. The branch must be fully merged in its + upstream branch, or in `HEAD` if no upstream was set with + `--track` or `--set-upstream`. -D:: Delete a branch irrespective of its merged status. -- cgit v1.2.3 From 21798708031ed808cb77232e771e20d3146cf9c8 Mon Sep 17 00:00:00 2001 From: Thomas Rast Date: Thu, 15 Apr 2010 14:59:37 +0200 Subject: combined diff: correctly handle truncated file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Consider an evil merge of two commits A and B, both of which have a file 'foo', but the merge result does not have that file. The combined-diff code learned in 4462731 (combine-diff: do not punt on removed or added files., 2006-02-06) to concisely show only the removal, since that is the evil part and the previous contents are presumably uninteresting. However, to diagnose an empty merge result, it overloaded the variable that holds the file's length. This means that the check also triggers for truncated files. Consequently, such files were not shown in the diff at all despite the merge being clearly evil. Fix this by adding a new variable that distinguishes whether the file was deleted (which is the case 4462731 handled) or truncated. In the truncated case, we show the full combined diff again, which is rather spammy but at least does not hide the evilness. Reported-by: David Martínez Martí Signed-off-by: Thomas Rast Signed-off-by: Junio C Hamano --- combine-diff.c | 14 ++++++++------ t/t4038-diff-combined.sh | 8 ++++++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/combine-diff.c b/combine-diff.c index 61626912e3..3480dae824 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -204,7 +204,7 @@ static void consume_line(void *state_, char *line, unsigned long len) static void combine_diff(const unsigned char *parent, unsigned int mode, mmfile_t *result_file, struct sline *sline, unsigned int cnt, int n, - int num_parent) + int num_parent, int result_deleted) { unsigned int p_lno, lno; unsigned long nmask = (1UL << n); @@ -215,7 +215,7 @@ static void combine_diff(const unsigned char *parent, unsigned int mode, struct combine_diff_state state; unsigned long sz; - if (!cnt) + if (result_deleted) return; /* result deleted */ parent_file.ptr = grab_blob(parent, mode, &sz); @@ -517,7 +517,7 @@ static void show_line_to_eol(const char *line, int len, const char *reset) } static void dump_sline(struct sline *sline, unsigned long cnt, int num_parent, - int use_color) + int use_color, int result_deleted) { unsigned long mark = (1UL<diffopt; unsigned long result_size, cnt, lno; + int result_deleted = 0; char *result, *cp; struct sline *sline; /* survived lines */ int mode_differs = 0; @@ -767,6 +768,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent, } else { deleted_file: + result_deleted = 1; result_size = 0; elem->mode = 0; result = xcalloc(1, 1); @@ -823,7 +825,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent, combine_diff(elem->parent[i].sha1, elem->parent[i].mode, &result_file, sline, - cnt, i, num_parent); + cnt, i, num_parent, result_deleted); if (elem->parent[i].mode != elem->mode) mode_differs = 1; } @@ -889,7 +891,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent, dump_quoted_path("+++ ", b_prefix, elem->path, c_meta, c_reset); dump_sline(sline, cnt, num_parent, - DIFF_OPT_TST(opt, COLOR_DIFF)); + DIFF_OPT_TST(opt, COLOR_DIFF), result_deleted); } free(result); diff --git a/t/t4038-diff-combined.sh b/t/t4038-diff-combined.sh index 7584efa36b..40277c77aa 100755 --- a/t/t4038-diff-combined.sh +++ b/t/t4038-diff-combined.sh @@ -81,4 +81,12 @@ test_expect_success 'check combined output (2)' ' verify_helper sidesansone ' +test_expect_success 'diagnose truncated file' ' + >file && + git add file && + git commit --amend -C HEAD && + git show >out && + grep "diff --cc file" out +' + test_done -- cgit v1.2.3 From 53b3c47d64b4294ae586d1daa04f9140dadd9ae6 Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Thu, 15 Apr 2010 11:34:07 +0200 Subject: t1010-mktree: Adjust expected result to code and documentation The last two tests here were always supposed to fail in the sense that, according to code and documentation, mktree should read non-recursive ls-tree output, but not recursive one, and therefore explicitely refuses to deal with slashes. Adjust the test (must_fail) so that it succeeds when mktree dies on slashes. Signed-off-by: Michael J Gruber Signed-off-by: Junio C Hamano --- t/t1010-mktree.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/t/t1010-mktree.sh b/t/t1010-mktree.sh index 9956e3ad62..b946f87686 100755 --- a/t/t1010-mktree.sh +++ b/t/t1010-mktree.sh @@ -58,14 +58,12 @@ test_expect_success 'allow missing object with --missing' ' test_cmp tree.missing actual ' -test_expect_failure 'mktree reads ls-tree -r output (1)' ' - git mktree actual && - test_cmp tree actual +test_expect_success 'mktree refuses to read ls-tree -r output (1)' ' + test_must_fail git mktree actual ' -test_expect_failure 'mktree reads ls-tree -r output (2)' ' - git mktree actual && - test_cmp tree.withsub actual +test_expect_success 'mktree refuses to read ls-tree -r output (2)' ' + test_must_fail git mktree actual ' test_done -- cgit v1.2.3