Commit graph

36829 commits

Author SHA1 Message Date
Jeff King f33206992d walker_fetch: fix minor memory leak
We sometimes allocate "msg" on the heap, but will fail to
free it if we hit the failure code path. We can instead keep
a separate variable that is safe to be freed no matter how
we get to the failure code path.

While we're here, we can also do two readability
improvements:

  1. Use xstrfmt instead of a manual malloc/sprintf

  2. Due to the "maybe we allocate msg, maybe we don't"
     strategy, the logic for deciding which message to show
     was split into two parts. Since the deallocation is now
     pushed onto a separate variable, this is no longer a
     concern, and we can keep all of the logic in the same
     place.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-06-19 15:20:56 -07:00
Jeff King 5c1753b198 merge: use argv_array when spawning merge strategy
This is shorter, and avoids a rather complicated set of
allocation and free steps.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-06-19 15:20:55 -07:00
Jeff King 3bdd55228b sequencer: use argv_array_pushf
This avoids a manual allocation calculation, and is shorter
to boot.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-06-19 15:20:55 -07:00
Jeff King a0279e1865 setup_git_env: use git_pathdup instead of xmalloc + sprintf
This is shorter, harder to get wrong, and more clearly
captures the intent.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-06-19 15:20:55 -07:00
Jeff King b2724c8787 use xstrfmt to replace xmalloc + strcpy/strcat
It's easy to get manual allocation calculations wrong, and
the use of strcpy/strcat raise red flags for people looking
for buffer overflows (though in this case each site was
fine).

It's also shorter to use xstrfmt, and the printf-format
tends to be easier for a reader to see what the final string
will look like.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-06-19 15:20:54 -07:00
Jeff King 283101869b use xstrfmt to replace xmalloc + sprintf
This is one line shorter, and makes sure the length in the
malloc and sprintf steps match.

These conversions are very straightforward; we can drop the
malloc entirely, and replace the sprintf with xstrfmt.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-06-19 15:20:54 -07:00
Jeff King 95244ae3dd use xstrdup instead of xmalloc + strcpy
This is one line shorter, and makes sure the length in the
malloc and copy steps match.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-06-19 15:20:53 -07:00
Jeff King fa3f60b783 use xstrfmt in favor of manual size calculations
In many parts of the code, we do an ugly and error-prone
malloc like:

  const char *fmt = "something %s";
  buf = xmalloc(strlen(foo) + 10 + 1);
  sprintf(buf, fmt, foo);

This makes the code brittle, and if we ever get the
allocation wrong, is a potential heap overflow. Let's
instead favor xstrfmt, which handles the allocation
automatically, and makes the code shorter and more readable.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-06-19 12:25:17 -07:00
Jeff King 30a0ddb705 strbuf: add xstrfmt helper
You can use a strbuf to build up a string from parts, and
then detach it. In the general case, you might use multiple
strbuf_add* functions to do the building. However, in many
cases, a single strbuf_addf is sufficient, and we end up
with:

  struct strbuf buf = STRBUF_INIT;
  ...
  strbuf_addf(&buf, fmt, some, args);
  str = strbuf_detach(&buf, NULL);

We can make this much more readable (and avoid introducing
an extra variable, which can clutter the code) by
introducing a convenience function:

  str = xstrfmt(fmt, some, args);

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-06-19 12:25:17 -07:00
Junio C Hamano cb682f8cfe Third batch for 2.1
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-06-16 12:39:35 -07:00
Junio C Hamano 7e1a5381b0 Merge branch 'ib/test-selectively-run'
Allow specifying only certain individual test pieces to be run
using a range notation (e.g. "t1234-test.sh --run='1-4 6 8 9-'").

* ib/test-selectively-run:
  t0000-*.sh: fix the GIT_SKIP_TESTS sub-tests
  test-lib: '--run' to run only specific tests
  test-lib: tests skipped by GIT_SKIP_TESTS say so
  test-lib: document short options in t/README
2014-06-16 12:18:56 -07:00
Junio C Hamano c6d3abbf99 Merge branch 'ta/string-list-init'
* ta/string-list-init:
  string-list: spell all values out that are given to a string_list initializer
2014-06-16 12:18:55 -07:00
Junio C Hamano bbfa0cc7f8 Merge branch 'jm/dedup-test-config'
* jm/dedup-test-config:
  t/t7810-grep.sh: remove duplicate test_config()
2014-06-16 12:18:54 -07:00
Junio C Hamano ae7dd1a492 Merge branch 'dt/refs-check-refname-component-optim'
* dt/refs-check-refname-component-optim:
  refs.c: optimize check_refname_component()
2014-06-16 12:18:52 -07:00
Junio C Hamano c651ccc91d Merge branch 'sk/test-cmp-bin'
* sk/test-cmp-bin:
  t5000, t5003: do not use test_cmp to compare binary files
2014-06-16 12:18:51 -07:00
Junio C Hamano 96b29bde91 Merge branch 'sh/enable-preloadindex'
* sh/enable-preloadindex:
  environment.c: enable core.preloadindex by default
2014-06-16 12:18:49 -07:00
Junio C Hamano bb0ced7581 Merge branch 'rs/read-ref-at'
* rs/read-ref-at:
  refs.c: change read_ref_at to use the reflog iterators
2014-06-16 12:18:48 -07:00
Junio C Hamano d0d5ba7e6e Merge branch 'jk/error-resolve-conflict-advice'
* jk/error-resolve-conflict-advice:
  error_resolve_conflict: drop quotations around operation
  error_resolve_conflict: rewrap advice message
2014-06-16 12:18:47 -07:00
Junio C Hamano 57a2eee925 Merge branch 'rs/pack-objects-no-unnecessary-realloc'
Avoid unnecessary copy of previous contents when extending the
hashtable used in pack-objects.

* rs/pack-objects-no-unnecessary-realloc:
  pack-objects: use free()+xcalloc() instead of xrealloc()+memset()
2014-06-16 12:18:42 -07:00
Junio C Hamano 3009afd54e Merge branch 'lt/log-auto-decorate'
* lt/log-auto-decorate:
  git log: support "auto" decorations
2014-06-16 12:18:41 -07:00
Junio C Hamano 668668ad50 Merge branch 'jm/doc-wording-tweaks'
* jm/doc-wording-tweaks:
  Documentation: wording fixes in the user manual and glossary
2014-06-16 12:18:39 -07:00
Junio C Hamano f18871dcd4 Merge branch 'jm/format-patch-mail-sig'
* jm/format-patch-mail-sig:
  format-patch: add "--signature-file=<file>" option
  format-patch: make newline after signature conditional
2014-06-16 12:18:38 -07:00
Junio C Hamano 2075a0c27f Merge branch 'jk/http-errors'
Propagate the error messages from the webserver better to the
client coming over the HTTP transport.

* jk/http-errors:
  http: default text charset to iso-8859-1
  remote-curl: reencode http error messages
  strbuf: add strbuf_reencode helper
  http: optionally extract charset parameter from content-type
  http: extract type/subtype portion of content-type
  t5550: test display of remote http error messages
  t/lib-httpd: use write_script to copy CGI scripts
  test-lib: preserve GIT_CURL_VERBOSE from the environment
2014-06-16 12:18:36 -07:00
Junio C Hamano c37d3269d9 Merge branch 'ow/config-mailmap-pathname'
mailmap.file configuration names a pathname, hence should honor
~/path and ~user/path as its value.

* ow/config-mailmap-pathname:
  config: respect '~' and '~user' in mailmap.file
2014-06-16 12:18:24 -07:00
Junio C Hamano c9fc3a6ac5 Merge branch 'fc/remote-helper-refmap'
Allow remote-helper/fast-import based transport to rename the refs
while transferring the history.

* fc/remote-helper-refmap:
  transport-helper: remove unnecessary strbuf resets
  transport-helper: add support to delete branches
  fast-export: add support to delete refs
  fast-import: add support to delete refs
  transport-helper: add support to push symbolic refs
  transport-helper: add support for old:new refspec
  fast-export: add new --refspec option
  fast-export: improve argument parsing
2014-06-16 12:18:15 -07:00
Junio C Hamano 1a81f6ceea Merge branch 'nd/daemonize-gc'
"git gc --auto" was recently changed to run in the background to
give control back early to the end-user sitting in front of the
terminal, but it forgot that housekeeping involving reflogs should
be done without other processes competing for accesses to the refs.

* nd/daemonize-gc:
  gc --auto: do not lock refs in the background
2014-06-16 12:18:12 -07:00
Junio C Hamano 8dbd313394 Merge branch 'jm/t9138-style-fix'
* jm/t9138-style-fix:
  t9138-git-svn-authors-prog.sh fixups
2014-06-16 12:18:09 -07:00
Junio C Hamano bf2941be5d Merge branch 'jm/instaweb-apache-24'
* jm/instaweb-apache-24:
  git-instaweb: add support for Apache 2.4
2014-06-16 12:18:06 -07:00
Junio C Hamano 474df928b1 Merge branch 'jl/remote-rm-prune'
"git remote rm" and "git remote prune" can involve removing many
refs at once, which is not a very efficient thing to do when very
many refs exist in the packed-refs file.

* jl/remote-rm-prune:
  remote prune: optimize "dangling symref" check/warning
  remote: repack packed-refs once when deleting multiple refs
  remote rm: delete remote configuration as the last
2014-06-16 12:17:58 -07:00
Junio C Hamano 5cf2c571d0 Merge branch 'jk/complete-merge-pull'
The completion code did not know about quite a few options that are
common between "git merge" and "git pull", and a couple of options
unique to "git merge".

* jk/complete-merge-pull:
  completion: add missing options for git-merge
  completion: add a note that merge options are shared
2014-06-16 12:17:53 -07:00
Junio C Hamano a634a6d209 Merge branch 'bg/xcalloc-nmemb-then-size'
Like calloc(3), xcalloc() takes nmemb and then size.

* bg/xcalloc-nmemb-then-size:
  transport-helper.c: rearrange xcalloc arguments
  remote.c: rearrange xcalloc arguments
  reflog-walk.c: rearrange xcalloc arguments
  pack-revindex.c: rearrange xcalloc arguments
  notes.c: rearrange xcalloc arguments
  imap-send.c: rearrange xcalloc arguments
  http-push.c: rearrange xcalloc arguments
  diff.c: rearrange xcalloc arguments
  config.c: rearrange xcalloc arguments
  commit.c: rearrange xcalloc arguments
  builtin/remote.c: rearrange xcalloc arguments
  builtin/ls-remote.c: rearrange xcalloc arguments
2014-06-16 12:17:50 -07:00
Junio C Hamano 6d681f0a3e Merge branch 'jl/status-added-submodule-is-never-ignored'
submodule.*.ignore and diff.ignoresubmodules are used to ignore all
submodule changes in "diff" output, but it can be confusing to
apply these configuration values to status and commit.

This is a backward-incompatible change, but should be so in a good
way (aka bugfix).

* jl/status-added-submodule-is-never-ignored:
  commit -m: commit staged submodules regardless of ignore config
  status/commit: show staged submodules regardless of ignore config
2014-06-16 10:07:19 -07:00
Junio C Hamano 83a4904fad Merge branch 'cb/byte-order'
Compatibility enhancement for Solaris.

* cb/byte-order:
  compat/bswap.h: fix endianness detection
  compat/bswap.h: restore preference __BIG_ENDIAN over BIG_ENDIAN
  compat/bswap.h: detect endianness on more platforms that don't use BYTE_ORDER
2014-06-16 10:07:18 -07:00
Junio C Hamano b4bba8de11 Merge branch 'jk/strbuf-tolower'
* jk/strbuf-tolower:
  strbuf: add strbuf_tolower function
2014-06-16 10:07:17 -07:00
Junio C Hamano b4516df9b8 Merge branch 'jk/daemon-tolower'
* jk/daemon-tolower:
  daemon/config: factor out duplicate xstrdup_tolower
2014-06-16 10:07:15 -07:00
Junio C Hamano 09e13ad5b0 Merge branch 'as/pretty-truncate'
* as/pretty-truncate:
  pretty.c: format string with truncate respects logOutputEncoding
  t4205, t6006: add tests that fail with i18n.logOutputEncoding set
  t4205 (log-pretty-format): use `tformat` rather than `format`
  t4041, t4205, t6006, t7102: don't hardcode tested encoding value
  t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs
2014-06-16 10:07:12 -07:00
Junio C Hamano b0e2c999af Merge branch 'jk/diff-follow-must-take-one-pathspec'
* jk/diff-follow-must-take-one-pathspec:
  move "--follow needs one pathspec" rule to diff_setup_done
2014-06-16 10:07:09 -07:00
Junio C Hamano b83163643b Merge branch 'sk/windows-unc-path'
* sk/windows-unc-path:
  Windows: allow using UNC path for git repository
2014-06-16 10:07:03 -07:00
Junio C Hamano 4a43d4f98a Merge branch 'rr/rebase-autostash-fix'
* rr/rebase-autostash-fix:
  rebase -i: test "Nothing to do" case with autostash
  rebase -i: handle "Nothing to do" case with autostash
2014-06-16 10:06:57 -07:00
Junio C Hamano 9d1d882e9c Merge branch 'jk/report-fail-to-read-objects-better'
* jk/report-fail-to-read-objects-better:
  open_sha1_file: report "most interesting" errno
2014-06-16 10:06:15 -07:00
Junio C Hamano 414405969e Merge branch 'jk/diff-files-assume-unchanged'
* jk/diff-files-assume-unchanged:
  run_diff_files: do not look at uninitialized stat data
2014-06-16 10:06:12 -07:00
Junio C Hamano 5b3a58d459 Merge branch 'jk/argv-array-for-child-process'
* jk/argv-array-for-child-process:
  argv-array: drop "detach" code
  get_importer: use run-command's internal argv_array
  get_exporter: use argv_array
  get_helper: use run-command's internal argv_array
  git_connect: use argv_array
  run_column_filter: use argv_array
  run-command: store an optional argv_array
2014-06-16 10:06:10 -07:00
Junio C Hamano 45dc292716 Merge branch 'sk/wincred'
* sk/wincred:
  wincred: avoid overwriting configured variables
  wincred: add install target
2014-06-16 10:06:08 -07:00
Junio C Hamano fd80021438 Merge branch 'jk/do-not-run-httpd-tests-as-root'
* jk/do-not-run-httpd-tests-as-root:
  t/lib-httpd: require SANITY prereq
2014-06-16 10:06:05 -07:00
Junio C Hamano 499168af3b Merge branch 'cc/replace-edit'
"git replace" learns a new "--edit" option.

* cc/replace-edit:
  Documentation: replace: describe new --edit option
  replace: add --edit to usage string
  replace: add tests for --edit
  replace: die early if replace ref already exists
  replace: refactor checking ref validity
  replace: make sure --edit results in a different object
  replace: add --edit option
  replace: factor object resolution out of replace_object
  replace: use OPT_CMDMODE to handle modes
  replace: refactor command-mode determination
2014-06-16 10:06:01 -07:00
Junio C Hamano 79e539404c Merge branch 'mt/patch-id-stable' (early part)
* 'mt/patch-id-stable' (early part):
  patch-id-test: test stable and unstable behaviour
  patch-id: make it stable against hunk reordering
  test doc: test_write_lines does not split its arguments
  test: add test_write_lines helper
2014-06-16 10:05:38 -07:00
Junio C Hamano 75cc6c67e2 Sync with maint
* maint:
  pull: do not abuse 'break' inside a shell 'case'
2014-06-12 12:22:38 -07:00
Junio C Hamano 9a597edc83 Merge branch 'jc/rev-parse-argh-dashed-multi-words' into maint
* jc/rev-parse-argh-dashed-multi-words:
  update-index: fix segfault with missing --cacheinfo argument
2014-06-12 12:17:57 -07:00
Jacek Konieczny 8f92c7755e pull: do not abuse 'break' inside a shell 'case'
It is not C. The code would break under mksh when 'pull.ff' is set:

  $ git pull
  /usr/lib/git-core/git-pull[67]: break: can't break
  Already up-to-date.

Signed-off-by: Jacek Konieczny <jajcus@jajcus.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-06-12 12:15:49 -07:00
Cezary Zawadka c2369bdf7f Windows: allow using UNC path for git repository
[efl: moved MinGW-specific part to compat/]
[jes: fixed compilation on non-Windows]

Eric Sunshine fixed mingw_offset_1st_component() to return
consistently "foo" for UNC "//machine/share/foo", cf

http://groups.google.com/group/msysgit/browse_thread/thread/c0af578549b5dda0

Author: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Cezary Zawadka <czawadka@gmail.com>
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Stepan Kasal <kasal@ucw.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-06-10 13:30:04 -07:00