Subject: assert failed in pathspec.c

From: Dingyuan Wang <[email-masked]>
Date: Thu, 11 Feb 2016 11:59:16 +0800

Hi all,

I've got an assertion error when `git add .`

git: pathspec.c:317: prefix_pathspec: Assertion `item->nowildcard_len <=
item->len && item->prefix <= item->len' failed.
Aborted (core dumped)

I think the repo doesn't have anything interesting.
No submodules or subrepos. It's like:

repo/
 .gitignore
 .git/
 scripts/
  .gitignore
  foo.py
  bar.json
 something/
 someanother/
 other/         (gitignored)
  scripts.git/  (original .git for scripts/)
  foo.txt

With

modified:   ../something/a.txt
modified:   ../someanother/b.txt
...

Working directory is repo/scripts.

I think the bug is related to this post: [assert failed in submodule
edge case](https://marc.info/?l=git&m=142894416621088&w=2).

(gdb) r
Starting program: /home/gumble/software/git-master/git-add .
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
git-add: pathspec.c:317: prefix_pathspec: Assertion
`item->nowildcard_len <= item->len && item->prefix <= item->len' failed.

Program received signal SIGABRT, Aborted.
0x00007ffff6fc8507 in __GI_raise (sig=sig@entry=6) at
../sysdeps/unix/sysv/linux/raise.c:55
55	../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  0x00007ffff6fc8507 in __GI_raise (sig=sig@entry=6) at
../sysdeps/unix/sysv/linux/raise.c:55
#1  0x00007ffff6fc98da in __GI_abort () at abort.c:89
#2  0x00007ffff6fc159d in __assert_fail_base (fmt=0x7ffff70fe6b8
"%s%s%s:%u: %s%sAssertion `%s' failed.\n%n",
    assertion=assertion@entry=0x56ffe0 "item->nowildcard_len <=
item->len && item->prefix <= item->len", file=file@entry=0x5701a6
"pathspec.c", line=line@entry=317,
    function=function@entry=0x5701d0 <__PRETTY_FUNCTION__.22386>
"prefix_pathspec") at assert.c:92
#3  0x00007ffff6fc1652 in __GI___assert_fail
(assertion=assertion@entry=0x56ffe0 "item->nowildcard_len <= item->len
&& item->prefix <= item->len", file=file@entry=0x5701a6 "pathspec.c",
    line=line@entry=317, function=function@entry=0x5701d0
<__PRETTY_FUNCTION__.22386> "prefix_pathspec") at assert.c:101
#4  0x00000000004deb3e in prefix_pathspec (elt=0x7fffffffe3f5 ".",
prefixlen=8, prefix=0x7e71f3 "scripts/", flags=50, raw=0x7fffffffe0a0,
p_short_magic=<synthetic pointer>, item=<optimized out>)
    at pathspec.c:316
#5  parse_pathspec (pathspec=pathspec@entry=0x7fffffffd530,
magic_mask=magic_mask@entry=0, flags=flags@entry=50,
prefix=prefix@entry=0x7e71f3 "scripts/", argv=argv@entry=0x7fffffffe0a0)
at pathspec.c:417
#6  0x0000000000406423 in cmd_add (argc=<optimized out>,
argv=0x7fffffffe0a0, prefix=0x7e71f3 "scripts/") at builtin/add.c:364
#7  0x0000000000405cc8 in run_builtin (argv=0x7fffffffe098, argc=2,
p=0x7b2520 <commands>) at git.c:352
#8  handle_builtin (argc=2, argv=0x7fffffffe098) at git.c:542
#9  0x0000000000404e7a in main (argc=2, av=<optimized out>) at git.c:665

--
Dingyuan Wang