From: Jens Lehmann Date: Mon, 05 Oct 2009 17:32:43 GMT Subject: Re: [PATCH] Add the --submodule-summary option to the diff option family Message-ID: <4ACA2DBB.5030908@web.de> In-Reply-To: <4AC9D6EB.8090002@web.de> A bug showed up in the tests, deleted submodules were labelled "(not checked out)" instead of "(submodule deleted)". This patch fixes that. --------------------------8<-------------------- [PATCH] fix output for deleted submodules in git diff --submodule-summary When a submodule has been deleted, add_submodule_odb() returns false because the directory of the submodule is gone. So we have to test the second sha for null before we call add_submodule_odb() to get the correct output. Signed-off-by: Jens Lehmann --- submodule.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/submodule.c b/submodule.c index 11fce7d..54c8de8 100644 --- a/submodule.c +++ b/submodule.c @@ -45,12 +45,12 @@ void show_submodule_summary(FILE *f, const char *path, static const char *format = " %m %s"; int fast_forward = 0, fast_backward = 0; - if (add_submodule_odb(path)) + if (is_null_sha1(two)) + message = "(submodule deleted)"; + else if (add_submodule_odb(path)) message = "(not checked out)"; else if (is_null_sha1(one)) message = "(new submodule)"; - else if (is_null_sha1(two)) - message = "(submodule deleted)"; else if (!(left = lookup_commit_reference(one)) || !(right = lookup_commit_reference(two))) message = "(commits not present)"; -- 1.6.5.rc2.210.gac56a4.dirty