Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filenames with spaces cause fatal errors #19

Closed
Zetten opened this issue Feb 27, 2013 · 3 comments
Closed

Filenames with spaces cause fatal errors #19

Zetten opened this issue Feb 27, 2013 · 3 comments
Milestone

Comments

@Zetten
Copy link

Zetten commented Feb 27, 2013

After adding a Mercurial remote to an existing Git repo, and git --fetching to synchronise, a git push --tags fails in two separate locations due to the existence of filenames with spaces in the changesets.

The errors occur in the parse_commit(parser) function, where the diff stat lines are split on whitespace. The existence of a filename with a space character causes the error (and a similar error later on line 624):

Traceback (most recent call last):
  File "/usr/local/bin/git-remote-hg", line 805, in 
    sys.exit(main(sys.argv))
  File "/usr/local/bin/git-remote-hg", line 795, in main
    do_export(parser)
  File "/usr/local/bin/git-remote-hg", line 689, in do_export
    parse_commit(parser)
  File "/usr/local/bin/git-remote-hg", line 577, in parse_commit
    t, path = line.split(' ')
ValueError: too many values to unpack
error: fast-export died of signal 13
fatal: Error while running fast-export

Setting the maxsplit value for these splits is my quick fix, but there may be a better way for a more experienced python dev. I'll add a pull request just in case.

@fingolfin
Copy link

Good catch. Unfortunately, felipe has not shown any signs of activity in the past months. You may be better off trying to get this patch integrated right into the copy of felipe's git-remote-hg now shipped as part of git.git (in the contrib dir).

Or you could try out our "fork" of this tool, which adds many improvements and fixes over this code here (but it also drops the hg-git compatibility mode, so if you need that, this won't be for you). In particular, I just pushed a commit there which fixes the issue you are reporting here in gitifyhg.

@Zetten
Copy link
Author

Zetten commented Mar 21, 2013

Unfortunately the hg-git mode is kind of essential for a current use case. I might be able to work around that sometime in the future.

In any event I'll see about submitting the patch to git directly since it's definitely a failure case in git-remote-hg.

@felipec
Copy link
Owner

felipec commented Apr 1, 2013

Thanks. I've merged the patch, makes sense to me.

@felipec felipec closed this as completed Apr 1, 2013
felipec pushed a commit that referenced this issue Jun 12, 2013
This resolves issue #19 by setting the compiled default to html in msys
builds following the changes introduced by commit
1cc8af0 "help: use HTML as the default help format on Windows"

Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
felipec pushed a commit that referenced this issue Jul 5, 2021
The primary goal of this change is to stop leaking init_db_template_dir.
This leak can happen because:
 1. git_init_db_config() allocates new memory into init_db_template_dir
    without first freeing the existing value.
 2. init_db_template_dir might already contain data, either because:
  2.1 git_config() can be invoked twice with this callback in a single
      process - at least 2 allocations are likely.
  2.2 A single git_config() allocation can invoke the callback multiple
      times for a given key (see further explanation in the function
      docs) - each of those calls will trigger another leak.

The simplest fix for the leak would be to free(init_db_template_dir)
before overwriting it. Instead we choose to convert to fetching
init.templatedir via git_config_get_value() as that is more explicit,
more efficient, and avoids allocations (the returned result is owned by
the config cache, so we aren't responsible for freeing it).

If we remove init_db_template_dir, git_init_db_config() ends up being
responsible only for forwarding core.* config values to
platform_core_config(). However platform_core_config() already ignores
non-core.* config values, so we can safely remove git_init_db_config()
and invoke git_config() directly with platform_core_config() as the
callback.

The platform_core_config forwarding was originally added in:
  2878533 (mingw: respect core.hidedotfiles = false in git-init again, 2019-03-11
And I suspect the potential for a leak existed since the original
implementation of git_init_db_config in:
  90b4518 (Add `init.templatedir` configuration variable., 2010-02-17)

LSAN output from t0001:

Direct leak of 73 byte(s) in 1 object(s) allocated from:
    #0 0x49a859 in realloc /home/abuild/rpmbuild/BUILD/llvm-11.0.0.src/build/../projects/compiler-rt/lib/asan/asan_malloc_linux.cpp:164:3
    #1 0x9a7276 in xrealloc /home/ahunt/oss-fuzz/git/wrapper.c:126:8
    #2 0x9362ad in strbuf_grow /home/ahunt/oss-fuzz/git/strbuf.c:98:2
    #3 0x936eaa in strbuf_add /home/ahunt/oss-fuzz/git/strbuf.c:295:2
    #4 0x868112 in strbuf_addstr /home/ahunt/oss-fuzz/git/./strbuf.h:304:2
    #5 0x86a8ad in expand_user_path /home/ahunt/oss-fuzz/git/path.c:758:2
    #6 0x720bb1 in git_config_pathname /home/ahunt/oss-fuzz/git/config.c:1287:10
    #7 0x5960e2 in git_init_db_config /home/ahunt/oss-fuzz/git/builtin/init-db.c:161:11
    #8 0x7255b8 in configset_iter /home/ahunt/oss-fuzz/git/config.c:1982:7
    #9 0x7253fc in repo_config /home/ahunt/oss-fuzz/git/config.c:2311:2
    #10 0x725ca7 in git_config /home/ahunt/oss-fuzz/git/config.c:2399:2
    #11 0x593e8d in create_default_files /home/ahunt/oss-fuzz/git/builtin/init-db.c:225:2
    #12 0x5935c6 in init_db /home/ahunt/oss-fuzz/git/builtin/init-db.c:449:11
    #13 0x59588e in cmd_init_db /home/ahunt/oss-fuzz/git/builtin/init-db.c:714:9
    #14 0x4cd60d in run_builtin /home/ahunt/oss-fuzz/git/git.c:453:11
    #15 0x4cb2da in handle_builtin /home/ahunt/oss-fuzz/git/git.c:704:3
    #16 0x4ccc37 in run_argv /home/ahunt/oss-fuzz/git/git.c:771:4
    #17 0x4cac29 in cmd_main /home/ahunt/oss-fuzz/git/git.c:902:19
    #18 0x69c4de in main /home/ahunt/oss-fuzz/git/common-main.c:52:11
    #19 0x7f23552d6349 in __libc_start_main (/lib64/libc.so.6+0x24349)

Signed-off-by: Andrzej Hunt <ajrhunt@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants