Skip to contentSkip to conversation

git-show-branch cant show --more

BUG Jon Loeliger 2 participants 2 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

Guys,

I realize I probably dumbly expected more history out of a partial git repository than is actually present, but a segmentation fault wasn't a nice way to tell me. :-)

Start with just Paul's repo over here:

rsync://rsync.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc-merge.git

And do a "git show-branch --more=10" on it.

Yeah, msg == 0. Bad msg. No dereferencing for you.

Thanks,
jdl

jdl.com 487 % gdb /usr/bin/git-show-branch
Using host libthread_db library "/lib/tls/libthread_db.so.1". (gdb) run --more=10
Starting program: /usr/bin/git-show-branch --more=10
error: Could not read 628f87f3d585bd0c2b0e39df039585d7a5831cc9
* [master] ppc32: Allow user to individual select CHRP/PMAC/PREP config ! [origin] ppc32: Allow user to individual select CHRP/PMAC/PREP config
--
++ [master] ppc32: Allow user to individual select CHRP/PMAC/PREP config ++ [master~1] powerpc: Merge simplified sections.h into asm-powerpc ++ [master~2] powerpc: Remove section free() and linker script bits ++ [master~3] powerpc: Remove sections use from ppc64 and drivers ++ [master~4] powerpc: Remove sections use from ppc
++ [master~5] ppc32: Removed non-inlined versions of local_irq* functions ++ [master~6] powerpc: Merged ppc_asm.h
++ [master~7] powerpc: Merge kmap_types.h

Program received signal SIGSEGV, Segmentation fault. get_one_line (msg=0x0, len=4294967294) at commit.c:347
347 char c = *msg++;
(gdb) where
#0 get_one_line (msg=0x0, len=4294967294) at commit.c:347 #1 0x0804dfc5 in pretty_print_commit (fmt=CMIT_FMT_ONELINE, msg=0x0,

    len=4294967295, buf=0xbfc86e40 "[PATCH] powerpc: Merge kmap_types.h",
    space=128) at commit.c:416

#2 0x08049a22 in show_one_commit (commit=0x0) at show-branch.c:199 #3 0x0804a304 in main (ac=0, av=0xbfc871bc) at show-branch.c:483

#1 lore raw
Quoted 7 lines · Jon Loeliger

I realize I probably dumbly expected more history out of a partial git repository than is actually present, but a segmentation fault wasn't a nice way to tell me. :-)

Start with just Paul's repo over here:

rsync://rsync.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc-merge.git

Hmph. That repository does not look partial to me, although it seems to use alternates to borrow heavily from Linus.

  $ git clone rsync://rsync.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc-merge.git ppc-merge
  $ git show-branch --more=10
  [master] ppc32: Allow user to individual select CHRP/PMAC/PREP config
  [master~1] powerpc: Merge simplified sections.h into asm-powerpc
  [master~2] powerpc: Remove section free() and linker script bits
  [master~3] powerpc: Remove sections use from ppc64 and drivers
  [master~4] powerpc: Remove sections use from ppc
  [master~5] ppc32: Removed non-inlined versions of local_irq* functions
  [master~6] powerpc: Merged ppc_asm.h
  [master~7] powerpc: Merge kmap_types.h
  [master~8] [NETFILTER]: Solve Kconfig dependency problem
  [master~9] [IPV6]: Check connect(2) status for IPv6 UDP socket (Re: xfrm_lookup)
  [master~10] [BOND]: Fix bond_init() error path handling.
  $ git --version
  git version 0.99.7

But in any case you are right. We should barf a bit nicely when we encounter an corrupt repository. How about something like this (not fully tested)?

------------
[PATCH] Be nice when running in a corrupt repository.

We may end up trying to print a commit we do not have but only whose existence is known to us because another commit we have refer to it.

---

show-branch.c +5 -2
@@ -196,8 +196,11 @@ static void show_one_commit(struct commi
 {
 	char pretty[128], *cp;
 	struct commit_name *name = commit->object.util;
-	pretty_print_commit(CMIT_FMT_ONELINE, commit->buffer, ~0,
-			    pretty, sizeof(pretty));
+	if (commit->object.parsed)
+		pretty_print_commit(CMIT_FMT_ONELINE, commit->buffer, ~0,
+				    pretty, sizeof(pretty));
+	else
+		strcpy(pretty, "(unavailable)");
 	if (!strncmp(pretty, "[PATCH] ", 8))
 		cp = pretty + 8;
 	else