Skip to content

Commit 88cf809

Browse files
committed
Merge branch 'mg/submodule-status-from-a-subdirectory'
"git submodule status" that is run from a subdirectory of the superproject did not work well, which has been corrected. * mg/submodule-status-from-a-subdirectory: submodule: fix 'submodule status' when called from a subdirectory
2 parents 8feb47e + 1f3aea2 commit 88cf809

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

builtin/submodule--helper.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,8 @@ static void status_submodule(const char *path, const struct object_id *ce_oid,
802802
path, NULL);
803803

804804
git_config(git_diff_basic_config, NULL);
805-
repo_init_revisions(the_repository, &rev, prefix);
805+
806+
repo_init_revisions(the_repository, &rev, NULL);
806807
rev.abbrev = 0;
807808
diff_files_args.argc = setup_revisions(diff_files_args.argc,
808809
diff_files_args.argv,

t/t7400-submodule-basic.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,28 @@ test_expect_success 'status should only print one line' '
356356
test_line_count = 1 lines
357357
'
358358

359+
test_expect_success 'status from subdirectory should have the same SHA1' '
360+
test_when_finished "rmdir addtest/subdir" &&
361+
(
362+
cd addtest &&
363+
mkdir subdir &&
364+
git submodule status >output &&
365+
awk "{print \$1}" <output >expect &&
366+
cd subdir &&
367+
git submodule status >../output &&
368+
awk "{print \$1}" <../output >../actual &&
369+
test_cmp ../expect ../actual &&
370+
git -C ../submod checkout HEAD^ &&
371+
git submodule status >../output &&
372+
awk "{print \$1}" <../output >../actual2 &&
373+
cd .. &&
374+
git submodule status >output &&
375+
awk "{print \$1}" <output >expect2 &&
376+
test_cmp expect2 actual2 &&
377+
! test_cmp actual actual2
378+
)
379+
'
380+
359381
test_expect_success 'setup - fetch commit name from submodule' '
360382
rev1=$(cd .subrepo && git rev-parse HEAD) &&
361383
printf "rev1: %s\n" "$rev1" &&

0 commit comments

Comments
 (0)