Skip to content

Commit d79b145

Browse files
periperidipgitster
authored andcommitted
t7421: eliminate 'grep' check in t7421.4 for mingw compatibility
The 'grep' check in test 4 of t7421 resulted in the failure of t7421 on Windows due to a different error message error: cannot spawn git: No such file or directory instead of fatal: exec 'rev-parse': cd to 'my-subm' failed: No such file or directory Tighten up the check to compute 'src_abbrev' by guarding the 'verify_submodule_committish()' call using `p->status !='D'`, so that the former isn't called in case of non-existent submodule directory, consequently, there is no such error message on any execution environment. The same need not be implemented for 'dst_abbrev' and is rather redundant since the conditional 'if (S_ISGITLINK(p->mod_dst))' already guards the 'verify_submodule_committish()' when we have a status of 'D'. Therefore, eliminate the 'grep' check in t7421. Instead, verify the absence of an error message by doing a 'test_must_be_empty' on the file containing the error. Reported-by: Johannes Schindelin <[email protected]> Helped-by: Kaartic Sivaraam <[email protected]> Mentored-by: Christian Couder <[email protected]> Mentored-by: Kaartic Sivaraam <[email protected]> Signed-off-by: Shourya Shukla <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f0c6b64 commit d79b145

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

builtin/submodule--helper.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,7 @@ static void print_submodule_summary(struct summary_cb *info, char *errmsg,
10351035
static void generate_submodule_summary(struct summary_cb *info,
10361036
struct module_cb *p)
10371037
{
1038-
char *displaypath, *src_abbrev, *dst_abbrev;
1038+
char *displaypath, *src_abbrev = NULL, *dst_abbrev;
10391039
int missing_src = 0, missing_dst = 0;
10401040
char *errmsg = NULL;
10411041
int total_commits = -1;
@@ -1061,8 +1061,9 @@ static void generate_submodule_summary(struct summary_cb *info,
10611061
}
10621062

10631063
if (S_ISGITLINK(p->mod_src)) {
1064-
src_abbrev = verify_submodule_committish(p->sm_path,
1065-
oid_to_hex(&p->oid_src));
1064+
if (p->status != 'D')
1065+
src_abbrev = verify_submodule_committish(p->sm_path,
1066+
oid_to_hex(&p->oid_src));
10661067
if (!src_abbrev) {
10671068
missing_src = 1;
10681069
/*

t/t7421-submodule-summary-add.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ test_expect_success 'submodule summary output for submodules with changed paths'
5858
git commit -m "change submodule path" &&
5959
rev=$(git -C sm rev-parse --short HEAD^) &&
6060
git submodule summary HEAD^^ -- my-subm >actual 2>err &&
61-
grep "fatal:.*my-subm" err &&
61+
test_must_be_empty err &&
6262
cat >expected <<-EOF &&
6363
* my-subm ${rev}...0000000:
6464

0 commit comments

Comments
 (0)