Merge branch 'ss/submodule-summary-in-c-fixes'

Fixups to a topic in 'next'.

* ss/submodule-summary-in-c-fixes:
  t7421: eliminate 'grep' check in t7421.4 for mingw compatibility
  submodule: fix style in function definition
  submodule: eliminate unused parameters from print_submodule_summary()
maint
Junio C Hamano 2020-09-09 13:53:07 -07:00
commit 9f7833fd55
2 changed files with 9 additions and 10 deletions

View File

@ -959,7 +959,7 @@ enum diff_cmd {
DIFF_FILES DIFF_FILES
}; };


static char* verify_submodule_committish(const char *sm_path, static char *verify_submodule_committish(const char *sm_path,
const char *committish) const char *committish)
{ {
struct child_process cp_rev_parse = CHILD_PROCESS_INIT; struct child_process cp_rev_parse = CHILD_PROCESS_INIT;
@ -979,10 +979,9 @@ static char* verify_submodule_committish(const char *sm_path,
return strbuf_detach(&result, NULL); return strbuf_detach(&result, NULL);
} }


static void print_submodule_summary(struct summary_cb *info, char* errmsg, static void print_submodule_summary(struct summary_cb *info, char *errmsg,
int total_commits, const char *displaypath, int total_commits, const char *displaypath,
const char *src_abbrev, const char *dst_abbrev, const char *src_abbrev, const char *dst_abbrev,
int missing_src, int missing_dst,
struct module_cb *p) struct module_cb *p)
{ {
if (p->status == 'T') { if (p->status == 'T') {
@ -1036,7 +1035,7 @@ static void print_submodule_summary(struct summary_cb *info, char* errmsg,
static void generate_submodule_summary(struct summary_cb *info, static void generate_submodule_summary(struct summary_cb *info,
struct module_cb *p) struct module_cb *p)
{ {
char *displaypath, *src_abbrev, *dst_abbrev; char *displaypath, *src_abbrev = NULL, *dst_abbrev;
int missing_src = 0, missing_dst = 0; int missing_src = 0, missing_dst = 0;
char *errmsg = NULL; char *errmsg = NULL;
int total_commits = -1; int total_commits = -1;
@ -1057,13 +1056,14 @@ static void generate_submodule_summary(struct summary_cb *info,
} else { } else {
/* for a submodule removal (mode:0000000), don't warn */ /* for a submodule removal (mode:0000000), don't warn */
if (p->mod_dst) if (p->mod_dst)
warning(_("unexpected mode %d\n"), p->mod_dst); warning(_("unexpected mode %o\n"), p->mod_dst);
} }
} }


if (S_ISGITLINK(p->mod_src)) { if (S_ISGITLINK(p->mod_src)) {
src_abbrev = verify_submodule_committish(p->sm_path, if (p->status != 'D')
oid_to_hex(&p->oid_src)); src_abbrev = verify_submodule_committish(p->sm_path,
oid_to_hex(&p->oid_src));
if (!src_abbrev) { if (!src_abbrev) {
missing_src = 1; missing_src = 1;
/* /*
@ -1154,8 +1154,7 @@ static void generate_submodule_summary(struct summary_cb *info,


print_submodule_summary(info, errmsg, total_commits, print_submodule_summary(info, errmsg, total_commits,
displaypath, src_abbrev, displaypath, src_abbrev,
dst_abbrev, missing_src, dst_abbrev, p);
missing_dst, p);


free(displaypath); free(displaypath);
free(src_abbrev); free(src_abbrev);

View File

@ -58,7 +58,7 @@ test_expect_success 'submodule summary output for submodules with changed paths'
git commit -m "change submodule path" && git commit -m "change submodule path" &&
rev=$(git -C sm rev-parse --short HEAD^) && rev=$(git -C sm rev-parse --short HEAD^) &&
git submodule summary HEAD^^ -- my-subm >actual 2>err && git submodule summary HEAD^^ -- my-subm >actual 2>err &&
grep "fatal:.*my-subm" err && test_must_be_empty err &&
cat >expected <<-EOF && cat >expected <<-EOF &&
* my-subm ${rev}...0000000: * my-subm ${rev}...0000000: