Hello Samuel Hym,
I just tried to reproduce the segfault.
(gdb) bt
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1 0x00007fc3d443e2f1 in __GI_abort () at abort.c:79
#2 0x000055b095852436 in BUG_vfl (file=<optimized out>, line=<optimized out>, fmt=0x55b0958a9250 "attempting to get main_ref_store outside of repository", params=params@entry=0x7ffc469b4980) at usage.c:230
#3 0x000055b095852bbf in BUG_fl (file=file@entry=0x55b0958a9536 "refs.c", line=line@entry=1687, fmt=fmt@entry=0x55b0958a9250 "attempting to get main_ref_store outside of repository") at usage.c:238
#4 0x000055b0957f0a14 in get_main_ref_store (r=0x55b095b39fc0 <the_repo>) at refs.c:1687
#5 0x000055b09580e329 in handle_revision_pseudo_opt (argc=1, flags=<synthetic pointer>, argv=0x7ffc469b4b98, revs=0x7ffc469b4bb0, submodule=0x0) at revision.c:2191
#6 setup_revisions (argc=<optimized out>, argc@entry=2, argv=argv@entry=0x7ffc469b4b90, revs=revs@entry=0x7ffc469b4bb0, opt=opt@entry=0x0) at revision.c:2341
#7 0x000055b09576b5ac in verify_bundle (header=header@entry=0x7ffc469b54b0, verbose=verbose@entry=1) at bundle.c:157
#8 0x000055b0956d6335 in cmd_bundle (argc=1, argv=0x7ffc469b58a0, prefix=<optimized out>) at builtin/bundle.c:43
#9 0x000055b0956c7825 in run_builtin (argv=<optimized out>, argc=<optimized out>, p=<optimized out>) at git.c:417
#10 handle_builtin (argc=<optimized out>, argv=<optimized out>) at git.c:632
#11 0x000055b0956c87c5 in run_argv (argv=0x7ffc469b5630, argcp=0x7ffc469b563c) at git.c:684
#12 cmd_main (argc=<optimized out>, argv=<optimized out>) at git.c:761
#13 0x000055b0956c74ef in main (argc=4, argv=0x7ffc469b5888) at common-main.c:45
(gdb) list get_main_ref_store
1680
1681 struct ref_store *get_main_ref_store(struct repository *r)
1682 {
1683 if (r->refs)
1684 return r->refs;
1685
1686 if (!r->gitdir)
1687 BUG("attempting to get main_ref_store outside of repository");
1688
1689 r->refs = ref_store_init(r->gitdir, REF_STORE_ALL_CAPS);
1690 return r->refs;
1691 }
I think a call to "BUG" is probably too much.
Probably a call to "die" could be more appropriate.
E.g. like "git diff" printing "Not a git repository".
Attached patch does just replace the "BUG" by "die".
Kind regards,
Bernhard