]> Kevux Git Server - rit/log
rit
9 years agoMakefile: detect errors in running spatch
Jeff King [Fri, 10 Mar 2017 08:31:18 +0000 (03:31 -0500)]
Makefile: detect errors in running spatch

The "make coccicheck" target runs spatch against each source
file. But it does so in a for loop, so "make" never sees the
exit code of spatch. Worse, it redirects stderr to a log
file, so the user has no indication of any failure. And then
to top it all off, because we touched the patch file's
mtime, make will refuse to repeat the command because it
think the target is up-to-date.

So for example:

  $ make coccicheck SPATCH=does-not-exist
      SPATCH contrib/coccinelle/free.cocci
      SPATCH contrib/coccinelle/qsort.cocci
      SPATCH contrib/coccinelle/xstrdup_or_null.cocci
      SPATCH contrib/coccinelle/swap.cocci
      SPATCH contrib/coccinelle/strbuf.cocci
      SPATCH contrib/coccinelle/object_id.cocci
      SPATCH contrib/coccinelle/array.cocci
  $ make coccicheck SPATCH=does-not-exist
  make: Nothing to be done for 'coccicheck'.

With this patch, you get:

  $ make coccicheck SPATCH=does-not-exist
       SPATCH contrib/coccinelle/free.cocci
  /bin/sh: 4: does-not-exist: not found
  Makefile:2338: recipe for target 'contrib/coccinelle/free.cocci.patch' failed
  make: *** [contrib/coccinelle/free.cocci.patch] Error 1

It also dumps the log on failure, so any errors from spatch
itself (like syntax errors in our .cocci files) will be seen
by the user.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoodb_mkstemp: use git_path_buf
Jeff King [Tue, 28 Mar 2017 19:45:52 +0000 (15:45 -0400)]
odb_mkstemp: use git_path_buf

Since git_path_buf() is smart enough to replace "objects/"
with the correct object path, we can use it instead of
manually assembling the path. That's slightly shorter, and
will clean up any non-canonical bits in the path.

Signed-off-by: Jeff King <peff@peff.net>
9 years agoodb_mkstemp: write filename into strbuf
Jeff King [Tue, 28 Mar 2017 19:45:43 +0000 (15:45 -0400)]
odb_mkstemp: write filename into strbuf

The odb_mkstemp() function expects the caller to provide a
fixed buffer to write the resulting tempfile name into. But
it creates the template using snprintf without checking the
return value. This means we could silently truncate the
filename.

In practice, it's unlikely that the truncation would end in
the template-pattern that mkstemp needs to open the file. So
we'd probably end up failing either way, unless the path was
specially crafted.

The simplest fix would be to notice the truncation and die.
However, we can observe that most callers immediately
xstrdup() the result anyway. So instead, let's switch to
using a strbuf, which is easier for them (and isn't a big
deal for the other 2 callers, who can just strbuf_release
when they're done with it).

Note that many of the callers used static buffers, but this
was purely to avoid putting a large buffer on the stack. We
never passed the static buffers out of the function, so
there's no complicated memory handling we need to change.

Signed-off-by: Jeff King <peff@peff.net>
9 years agodo not check odb_mkstemp return value for errors
Jeff King [Tue, 28 Mar 2017 19:45:25 +0000 (15:45 -0400)]
do not check odb_mkstemp return value for errors

The odb_mkstemp function does not return an error; it dies
on failure instead. But many of its callers compare the
resulting descriptor against -1 and die themselves.

Mostly this is just pointless, but it does raise a question
when looking at the callers: if they show the results of the
"template" buffer after a failure, what's in it? The answer
is: it doesn't matter, because it cannot happen.

So let's make that clear by removing the bogus error checks.
In bitmap_writer_finish(), we can drop the error-handling
code entirely. In the other two cases, it's shared with the
open() in another code path; we can just move the
error-check next to that open() call.

And while we're at it, let's flesh out the function's
docstring a bit to make the error behavior clear.

Signed-off-by: Jeff King <peff@peff.net>
9 years agoNinth batch for 2.13
Junio C Hamano [Tue, 28 Mar 2017 21:14:56 +0000 (14:14 -0700)]
Ninth batch for 2.13

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoSync with 'maint'
Junio C Hamano [Tue, 28 Mar 2017 21:14:24 +0000 (14:14 -0700)]
Sync with 'maint'

9 years agoMerge branch 'jk/sha1dc'
Junio C Hamano [Tue, 28 Mar 2017 21:06:00 +0000 (14:06 -0700)]
Merge branch 'jk/sha1dc'

sha1dc/sha1.c wanted to check the endianness of the target platform
at compilation time and used a CPP macro with a rather overly
generic name, "BIGENDIAN", to pass the result of the check around
in the file.  It wasn't prepared for the same macro set to 0
(false) by the platform to signal that the target is _not_ a big
endian box, and assumed that the endianness detection logic it has
alone would be the one that is setting the macro, resulting in a
breakage on Windows.  This has been fixed by using a bit less
generic name for the same purpose.

* jk/sha1dc:
  sha1dc: avoid CPP macro collisions

9 years agoMerge branch 'jh/memihash-opt'
Junio C Hamano [Tue, 28 Mar 2017 21:06:00 +0000 (14:06 -0700)]
Merge branch 'jh/memihash-opt'

The name-hash used for detecting paths that are different only in
cases (which matter on case insensitive filesystems) has been
optimized to take advantage of multi-threading when it makes sense.

* jh/memihash-opt:
  name-hash: add test-lazy-init-name-hash to .gitignore
  name-hash: add perf test for lazy_init_name_hash
  name-hash: add test-lazy-init-name-hash
  name-hash: perf improvement for lazy_init_name_hash
  hashmap: document memihash_cont, hashmap_disallow_rehash api
  hashmap: add disallow_rehash setting
  hashmap: allow memihash computation to be continued
  name-hash: specify initial size for istate.dir_hash table

9 years agoMerge branch 'jk/fast-import-cleanup'
Junio C Hamano [Tue, 28 Mar 2017 21:05:59 +0000 (14:05 -0700)]
Merge branch 'jk/fast-import-cleanup'

Code clean-up.

* jk/fast-import-cleanup:
  pack.h: define largest possible encoded object size
  encode_in_pack_object_header: respect output buffer length
  fast-import: use xsnprintf for formatting headers
  fast-import: use xsnprintf for writing sha1s

9 years agoMerge branch 'sg/skip-prefix-in-prettify-refname'
Junio C Hamano [Tue, 28 Mar 2017 21:05:59 +0000 (14:05 -0700)]
Merge branch 'sg/skip-prefix-in-prettify-refname'

Code cleanup.

* sg/skip-prefix-in-prettify-refname:
  refs.c: use skip_prefix() in prettify_refname()

9 years agoMerge branch 'ab/branch-list-doc'
Junio C Hamano [Tue, 28 Mar 2017 21:05:59 +0000 (14:05 -0700)]
Merge branch 'ab/branch-list-doc'

Doc update.

* ab/branch-list-doc:
  branch doc: update description for `--list`
  branch doc: change `git branch <pattern>` to use `<branchname>`

9 years agoMerge branch 'jk/pager-in-use'
Junio C Hamano [Tue, 28 Mar 2017 21:05:58 +0000 (14:05 -0700)]
Merge branch 'jk/pager-in-use'

Code clean-up.

* jk/pager-in-use:
  pager_in_use: use git_env_bool()

9 years agoMerge branch 'tg/stash-push-fixup'
Junio C Hamano [Tue, 28 Mar 2017 21:05:58 +0000 (14:05 -0700)]
Merge branch 'tg/stash-push-fixup'

Recent enhancement to "git stash push" command to support pathspec
to allow only a subset of working tree changes to be stashed away
was found to be too chatty and exposed the internal implementation
detail (e.g. when it uses reset to match the index to HEAD before
doing other things, output from reset seeped out).  These, and
other chattyness has been fixed.

* tg/stash-push-fixup:
  stash: keep untracked files intact in stash -k
  stash: pass the pathspec argument to git reset
  stash: don't show internal implementation details

9 years agoMerge branch 'sb/checkout-recurse-submodules'
Junio C Hamano [Tue, 28 Mar 2017 21:05:58 +0000 (14:05 -0700)]
Merge branch 'sb/checkout-recurse-submodules'

"git checkout" is taught the "--recurse-submodules" option.

* sb/checkout-recurse-submodules:
  builtin/read-tree: add --recurse-submodules switch
  builtin/checkout: add --recurse-submodules switch
  entry.c: create submodules when interesting
  unpack-trees: check if we can perform the operation for submodules
  unpack-trees: pass old oid to verify_clean_submodule
  update submodules: add submodule_move_head
  submodule.c: get_super_prefix_or_empty
  update submodules: move up prepare_submodule_repo_env
  submodules: introduce check to see whether to touch a submodule
  update submodules: add a config option to determine if submodules are updated
  update submodules: add submodule config parsing
  make is_submodule_populated gently
  lib-submodule-update.sh: define tests for recursing into submodules
  lib-submodule-update.sh: replace sha1 by hash
  lib-submodule-update: teach test_submodule_content the -C <dir> flag
  lib-submodule-update.sh: do not use ./. as submodule remote
  lib-submodule-update.sh: reorder create_lib_submodule_repo
  submodule--helper.c: remove duplicate code
  connect_work_tree_and_git_dir: safely create leading directories

9 years agoMerge branch 'bw/grep-recurse-submodules'
Junio C Hamano [Tue, 28 Mar 2017 21:05:57 +0000 (14:05 -0700)]
Merge branch 'bw/grep-recurse-submodules'

Build fix for NO_PTHREADS build.

* bw/grep-recurse-submodules:
  grep: fix builds with with no thread support
  grep: set default output method

9 years agoPrepare for 2.12.3
Junio C Hamano [Tue, 28 Mar 2017 20:54:14 +0000 (13:54 -0700)]
Prepare for 2.12.3

9 years agoMerge branch 'km/config-grammofix' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:29 +0000 (13:52 -0700)]
Merge branch 'km/config-grammofix' into maint

Doc update.

* km/config-grammofix:
  doc/config: grammar fixes for core.{editor,commentChar}

9 years agoMerge branch 'sb/t3600-rephrase' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:29 +0000 (13:52 -0700)]
Merge branch 'sb/t3600-rephrase' into maint

A test retitling.

* sb/t3600-rephrase:
  t3600: rename test to describe its functionality

9 years agoMerge branch 'sb/submodule-update-initial-runs-custom-script' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:29 +0000 (13:52 -0700)]
Merge branch 'sb/submodule-update-initial-runs-custom-script' into maint

A test fix.

* sb/submodule-update-initial-runs-custom-script:
  t7406: correct test case for submodule-update initial population

9 years agoMerge branch 'jk/quote-env-path-list-component' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:28 +0000 (13:52 -0700)]
Merge branch 'jk/quote-env-path-list-component' into maint

A test fix.

* jk/quote-env-path-list-component:
  t5615: fix a here-doc syntax error

9 years agoMerge branch 'rs/update-hook-optim' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:28 +0000 (13:52 -0700)]
Merge branch 'rs/update-hook-optim' into maint

Code clean-up.

* rs/update-hook-optim:
  receive-pack: simplify run_update_post_hook()

9 years agoMerge branch 'rs/shortlog-cleanup' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:27 +0000 (13:52 -0700)]
Merge branch 'rs/shortlog-cleanup' into maint

Code clean-up.

* rs/shortlog-cleanup:
  shortlog: don't set after_subject to an empty string

9 years agoMerge branch 'rs/path-name-safety-cleanup' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:27 +0000 (13:52 -0700)]
Merge branch 'rs/path-name-safety-cleanup' into maint

Code clean-up.

* rs/path-name-safety-cleanup:
  revision: remove declaration of path_name()

9 years agoMerge branch 'rs/http-push-cleanup' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:26 +0000 (13:52 -0700)]
Merge branch 'rs/http-push-cleanup' into maint

Code clean-up.

* rs/http-push-cleanup:
  http-push: don't check return value of lookup_unknown_object()

9 years agoMerge branch 'sb/wt-status-cleanup' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:26 +0000 (13:52 -0700)]
Merge branch 'sb/wt-status-cleanup' into maint

Code clean-up.

* sb/wt-status-cleanup:
  wt-status: simplify by using for_each_string_list_item

9 years agoMerge branch 'jk/pack-name-cleanups' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:25 +0000 (13:52 -0700)]
Merge branch 'jk/pack-name-cleanups' into maint

Code clean-up.

* jk/pack-name-cleanups:
  index-pack: make pointer-alias fallbacks safer
  replace snprintf with odb_pack_name()
  odb_pack_keep(): stop generating keepfile name
  sha1_file.c: make pack-name helper globally accessible
  move odb_* declarations out of git-compat-util.h

9 years agoMerge branch 'jk/rev-parse-cleanup' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:25 +0000 (13:52 -0700)]
Merge branch 'jk/rev-parse-cleanup' into maint

Code clean-up.

* jk/rev-parse-cleanup:
  rev-parse: simplify parsing of ref options
  rev-parse: add helper for parsing "--foo/--foo="
  rev-parse: use skip_prefix when parsing options

9 years agoMerge branch 'rs/blame-code-cleanup' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:25 +0000 (13:52 -0700)]
Merge branch 'rs/blame-code-cleanup' into maint

Code clean-up.

* rs/blame-code-cleanup:
  blame: move blame_entry duplication to add_blame_entry()

9 years agoMerge branch 'st/verify-tag' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:24 +0000 (13:52 -0700)]
Merge branch 'st/verify-tag' into maint

A few unterminated here documents in tests were fixed, which in
turn revealed incorrect expectations the tests make. These tests
have been updated.

* st/verify-tag:
  t7004, t7030: fix here-doc syntax errors

9 years agoMerge branch 'js/regexec-buf' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:24 +0000 (13:52 -0700)]
Merge branch 'js/regexec-buf' into maint

Fix for potential segv introduced in v2.11.0 and later (also
v2.10.2).

* js/regexec-buf:
  pickaxe: fix segfault with '-S<...> --pickaxe-regex'

9 years agoMerge branch 'jk/execv-dashed-external' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:23 +0000 (13:52 -0700)]
Merge branch 'jk/execv-dashed-external' into maint

Fix for NO_PTHREADS build.

* jk/execv-dashed-external:
  run-command: fix segfault when cleaning forked async process

9 years agoMerge branch 'ew/http-alternates-as-redirects-warning' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:23 +0000 (13:52 -0700)]
Merge branch 'ew/http-alternates-as-redirects-warning' into maint

Recent versions of Git treats http alternates (used in dumb http
transport) just like HTTP redirects and requires the client to
enable following it, due to security concerns.  But we forgot to
give a warning when we decide not to honor the alternates.

* ew/http-alternates-as-redirects-warning:
  http: release strbuf on disabled alternates
  http: inform about alternates-as-redirects behavior

9 years agoMerge branch 'dp/filter-branch-prune-empty' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:22 +0000 (13:52 -0700)]
Merge branch 'dp/filter-branch-prune-empty' into maint

"git filter-branch --prune-empty" drops a single-parent commit that
becomes a no-op, but did not drop a root commit whose tree is empty.

* dp/filter-branch-prune-empty:
  p7000: add test for filter-branch with --prune-empty
  filter-branch: fix --prune-empty on parentless commits
  t7003: ensure --prune-empty removes entire branch when applicable
  t7003: ensure --prune-empty can prune root commit

9 years agoMerge branch 'mm/fetch-show-error-message-on-unadvertised-object' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:22 +0000 (13:52 -0700)]
Merge branch 'mm/fetch-show-error-message-on-unadvertised-object' into maint

"git fetch" that requests a commit by object name, when the other
side does not allow such an request, failed without much
explanation.

* mm/fetch-show-error-message-on-unadvertised-object:
  fetch-pack: add specific error for fetching an unadvertised object
  fetch_refs_via_pack: call report_unmatched_refs
  fetch-pack: move code to report unmatched refs to a function

9 years agoMerge branch 'jk/interpret-branch-name' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:22 +0000 (13:52 -0700)]
Merge branch 'jk/interpret-branch-name' into maint

"git branch @" created refs/heads/@ as a branch, and in general the
code that handled @{-1} and @{upstream} was a bit too loose in
disambiguating.

* jk/interpret-branch-name:
  checkout: restrict @-expansions when finding branch
  strbuf_check_ref_format(): expand only local branches
  branch: restrict @-expansions when deleting
  t3204: test git-branch @-expansion corner cases
  interpret_branch_name: allow callers to restrict expansions
  strbuf_branchname: add docstring
  strbuf_branchname: drop return value
  interpret_branch_name: move docstring to header file
  interpret_branch_name(): handle auto-namelen for @{-1}

9 years agoMerge branch 'ab/cond-skip-tests' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:21 +0000 (13:52 -0700)]
Merge branch 'ab/cond-skip-tests' into maint

A few tests were run conditionally under (rare) conditions where
they cannot be run (like running cvs tests under 'root' account).

* ab/cond-skip-tests:
  gitweb tests: skip tests when we don't have Time::HiRes
  gitweb tests: change confusing "skip_all" phrasing
  cvs tests: skip tests that call "cvs commit" when running as root

9 years agoMerge branch 'jk/ident-empty' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:21 +0000 (13:52 -0700)]
Merge branch 'jk/ident-empty' into maint

user.email that consists of only cruft chars should consistently
error out, but didn't.

* jk/ident-empty:
  ident: do not ignore empty config name/email
  ident: reject all-crud ident name
  ident: handle NULL email when complaining of empty name
  ident: mark error messages for translation

9 years agoMerge branch 'jk/delta-chain-limit' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:20 +0000 (13:52 -0700)]
Merge branch 'jk/delta-chain-limit' into maint

"git repack --depth=<n>" for a long time busted the specified depth
when reusing delta from existing packs.  This has been corrected.

* jk/delta-chain-limit:
  pack-objects: convert recursion to iteration in break_delta_chain()
  pack-objects: enforce --depth limit in reused deltas

9 years agoMerge branch 'sg/test-with-stdin' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:20 +0000 (13:52 -0700)]
Merge branch 'sg/test-with-stdin' into maint

Teach the "debug" helper used in the test framework that allows a
command to run under "gdb" to make the session interactive.

* sg/test-with-stdin:
  tests: make the 'test_pause' helper work in non-verbose mode
  tests: create an interactive gdb session with the 'debug' helper

9 years agoMerge branch 'jk/interop-test' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:20 +0000 (13:52 -0700)]
Merge branch 'jk/interop-test' into maint

Picking two versions of Git and running tests to make sure the
older one and the newer one interoperate happily has now become
possible.

* jk/interop-test:
  t/interop: add test of old clients against modern git-daemon
  t: add an interoperability test harness

9 years agoMerge branch 'jt/perf-updates' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:19 +0000 (13:52 -0700)]
Merge branch 'jt/perf-updates' into maint

The t/perf performance test suite was not prepared to test not so
old versions of Git, but now it covers versions of Git that are not
so ancient.

* jt/perf-updates:
  t/perf: add fallback for pre-bin-wrappers versions of git
  t/perf: use $MODERN_GIT for all repo-copying steps
  t/perf: export variable used in other blocks

9 years agoMerge branch 'rs/strbuf-add-real-path' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:19 +0000 (13:52 -0700)]
Merge branch 'rs/strbuf-add-real-path' into maint

An helper function to make it easier to append the result from
real_path() to a strbuf has been added.

* rs/strbuf-add-real-path:
  strbuf: add strbuf_add_real_path()
  cocci: use ALLOC_ARRAY

9 years agoMerge branch 'jk/parse-config-key-cleanup' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:18 +0000 (13:52 -0700)]
Merge branch 'jk/parse-config-key-cleanup' into maint

The "parse_config_key()" API function has been cleaned up.

* jk/parse-config-key-cleanup:
  parse_hide_refs_config: tell parse_config_key we don't want a subsection
  parse_config_key: allow matching single-level config
  parse_config_key: use skip_prefix instead of starts_with
  refs: parse_hide_refs_config to use parse_config_key

9 years agotravis-ci: build and test Git on Windows
Lars Schneider [Fri, 24 Mar 2017 11:37:47 +0000 (12:37 +0100)]
travis-ci: build and test Git on Windows

Most Git developers work on Linux and they have no way to know if their
changes would break the Git for Windows build. Let's fix that by adding
a job to TravisCI that builds and tests Git on Windows. Unfortunately,
TravisCI does not support Windows.

Therefore, we did the following:
* Johannes Schindelin set up a Visual Studio Team Services build
  sponsored by Microsoft and made it accessible via an Azure Function
  that speaks a super-simple API. We made TravisCI use this API to
  trigger a build, wait until its completion, and print the build and
  test results.
* A Windows build and test run takes up to 3h and TravisCI has a timeout
  after 50min for Open Source projects. Since the TravisCI job does not
  use heavy CPU/memory/etc. resources, the friendly TravisCI folks
  extended the job timeout for git/git to 3h.

Things, that would need to be done:
* Someone with write access to https://travis-ci.org/git/git would need
  to add the secret token as "GFW_CI_TOKEN" variable in the TravisCI
  repository setting [1]. Afterwards the build should just work.

Things, that might need to be done:
* The Windows box can only process a single build at a time. A second
  Windows build would need to wait until the first finishes. This
  waiting time and the build time after the wait could exceed the 3h
  threshold. If this is a problem, then it is likely to happen every day
  as usually multiple branches are pushed at the same time (pu/next/
  master/maint). I cannot test this as my TravisCI account has the 50min
  timeout. One solution could be to limit the number of concurrent
  TravisCI jobs [2].

[1] https://docs.travis-ci.com/user/environment-variables#Defining-Variables-in-Repository-Settings
[2] https://docs.travis-ci.com/user/customizing-the-build#Limiting-Concurrent-Builds

Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agosha1-array: convert internal storage for struct sha1_array to object_id
brian m. carlson [Sun, 26 Mar 2017 16:01:37 +0000 (16:01 +0000)]
sha1-array: convert internal storage for struct sha1_array to object_id

Make the internal storage for struct sha1_array use an array of struct
object_id internally.  Update the users of this struct which inspect its
internals.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agobuiltin/pull: convert to struct object_id
brian m. carlson [Sun, 26 Mar 2017 16:01:36 +0000 (16:01 +0000)]
builtin/pull: convert to struct object_id

Convert virtually all uses of unsigned char [20] to struct object_id.
Leave all the arguments that come from struct sha1_array, as these will
be converted in a later patch.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agosubmodule: convert check_for_new_submodule_commits to object_id
brian m. carlson [Sun, 26 Mar 2017 16:01:35 +0000 (16:01 +0000)]
submodule: convert check_for_new_submodule_commits to object_id

All of the callers of this function have been converted, so convert this
function and update the callers.  This function also calls
sha1_array_append, which we'll convert shortly.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agosha1_name: convert disambiguate_hint_fn to take object_id
brian m. carlson [Sun, 26 Mar 2017 16:01:34 +0000 (16:01 +0000)]
sha1_name: convert disambiguate_hint_fn to take object_id

Convert this function pointer type and the functions that implement it
to take a struct object_id.  Introduce a temporary in
show_ambiguous_object to avoid having to convert for_each_abbrev at this
point.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agosha1_name: convert struct disambiguate_state to object_id
brian m. carlson [Sun, 26 Mar 2017 16:01:33 +0000 (16:01 +0000)]
sha1_name: convert struct disambiguate_state to object_id

Convert struct disambiguate_state to use struct object_id by changing
the structure definition and applying the following semantic patch:

@@
struct disambiguate_state E1;
@@
- E1.bin_pfx
+ E1.bin_pfx.hash

@@
struct disambiguate_state *E1;
@@
- E1->bin_pfx
+ E1->bin_pfx.hash

@@
struct disambiguate_state E1;
@@
- E1.candidate
+ E1.candidate.hash

@@
struct disambiguate_state *E1;
@@
- E1->candidate
+ E1->candidate.hash

This conversion is needed so we can convert disambiguate_hint_fn later.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agotest-sha1-array: convert most code to struct object_id
brian m. carlson [Sun, 26 Mar 2017 16:01:32 +0000 (16:01 +0000)]
test-sha1-array: convert most code to struct object_id

This helper is very small, so convert the entire thing.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoparse-options-cb: convert sha1_array_append caller to struct object_id
brian m. carlson [Sun, 26 Mar 2017 16:01:31 +0000 (16:01 +0000)]
parse-options-cb: convert sha1_array_append caller to struct object_id

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agofsck: convert init_skiplist to struct object_id
brian m. carlson [Sun, 26 Mar 2017 16:01:30 +0000 (16:01 +0000)]
fsck: convert init_skiplist to struct object_id

Convert a hardcoded constant buffer size to a use of GIT_MAX_HEXSZ, and
use parse_oid_hex to reduce the dependency on the size of the hash.
This function is a caller of sha1_array_append, which will be converted
later.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agobuiltin/receive-pack: convert portions to struct object_id
brian m. carlson [Sun, 26 Mar 2017 16:01:29 +0000 (16:01 +0000)]
builtin/receive-pack: convert portions to struct object_id

Convert some hardcoded constants into uses of parse_oid_hex.
Additionally, convert all uses of struct command, and miscellaneous
other functions necessary for that.  This work is necessary to be able
to convert sha1_array_append later on.

To avoid needing to specify a constant, reject shallow lines with the
wrong length instead of simply ignoring them.

Note that in queue_command we are guaranteed to have a NUL-terminated
buffer or at least one byte of overflow that we can safely read, so the
linelen check can be elided.  We would die in such a case, but not read
invalid memory.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agobuiltin/receive-pack: fix incorrect pointer arithmetic
brian m. carlson [Sun, 26 Mar 2017 16:01:28 +0000 (16:01 +0000)]
builtin/receive-pack: fix incorrect pointer arithmetic

If we had already processed the last newline in a push certificate, we
would end up subtracting NULL from the end-of-certificate pointer when
computing the length of the line.  This would have resulted in an
absurdly large length, and possibly a buffer overflow.  Instead,
subtract the beginning-of-certificate pointer from the
end-of-certificate pointer, which is what's expected.

Note that this situation should never occur, since not only do we
require the certificate to be newline terminated, but the signature will
only be read from the beginning of a line.  Nevertheless, it seems
prudent to correct it.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agonotes: do not break note_tree structure in note_tree_consolidate()
Mike Hommey [Sun, 26 Mar 2017 01:52:12 +0000 (10:52 +0900)]
notes: do not break note_tree structure in note_tree_consolidate()

After a note is removed, note_tree_consolidate is called to eliminate
some useless nodes. The typical case is that if you had an int_node
with 2 PTR_TYPE_NOTEs in it, and remove one of them, then the
PTR_TYPE_INTERNAL pointer in the parent tree can be replaced with the
remaining PTR_TYPE_NOTE.

This works fine when PTR_TYPE_NOTEs are involved, but falls flat when
other types are involved.

To put things in more practical terms, let's say we start from an empty
notes tree, and add 3 notes:

- one for a sha1 that starts with 424
- one for a sha1 that starts with 428
- one for a sha1 that starts with 4c

To keep track of this, note_tree.root will have a PTR_TYPE_INTERNAL at
a[4], pointing to an int_node*.
In turn, that int_node* will have a PTR_TYPE_NOTE at a[0xc], pointing to
the leaf_node* with the key and value, and a PTR_TYPE_INTERNAL at a[2],
pointing to another int_node*.
That other int_node* will have 2 PTR_TYPE_NOTE, one at a[4] and the
other at a[8].

When looking for the note for the sha1 starting with 428, get_note() will
recurse through (simplified) root.a[4].a[2].a[8].

Now, if we remove the note for the sha1 that starts with 4c, we're left
with a int_node* with only one PTR_TYPE_INTERNAL entry in it. After
note_tree_consolidate runs, root.a[4] now points to what used to be
pointed at by root.a[4].a[2].

Which means looking up for the note for the sha1 starting with 428 now
fails because there is nothing at root.a[4].a[2] anymore: there is only
root.a[4].a[4] and root.a[4].a[8], which don't match the expected
structure for the lookup.

So if all there is left in an int_node* is a PTR_TYPE_INTERNAL pointer,
we can't safely remove it. I think the same applies for PTR_TYPE_SUBTREE
pointers. IOW, only PTR_TYPE_NOTEs are safe to be moved to the parent
int_node*.

This doesn't have a practical effect on git because all that happens
after a remove_note is a write_notes_tree, which just iterates the entire
note tree, but this affects anything using libgit.a that would try to do
lookups after removing notes.

Signed-off-by: Mike Hommey <mh@glandium.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agosequencer: allow the commit-msg hooks to run during a `reword`
Johannes Schindelin [Thu, 23 Mar 2017 16:07:17 +0000 (17:07 +0100)]
sequencer: allow the commit-msg hooks to run during a `reword`

The `reword` command used to call `git commit` in a manner that asks for
the prepare-commit-msg and commit-msg hooks to do their thing.

Converting that part of the interactive rebase to C code introduced the
regression where those hooks were no longer run.

Let's fix this.

Note: the flag is called `VERIFY_MSG` instead of the more intuitive
`RUN_COMMIT_MSG_HOOKS` to indicate that the flag suppresses the
`--no-verify` flag (which may do other things in the future in addition
to suppressing the commit message hooks, too).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agosequencer: make commit options more extensible
Johannes Schindelin [Thu, 23 Mar 2017 16:07:11 +0000 (17:07 +0100)]
sequencer: make commit options more extensible

So far every time we need to tweak the behaviour of run_git_commit()
we have been adding a "int" parameter to it.  As the function gains
parameters and different callsites having different needs, this is
becoming a maintenance burden.  When a new knob needs to be added to
address a specific need for a single callsite, all the other callsites
need to add a "no, I do not want anything special with respect to the
new knob" argument.

Consolidate the existing four parameters into a flag word to make it
more maintainable, as we will be adding a new one to the mix soon.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agol10n: de: translate describe debug terms
Michael J Gruber [Mon, 27 Mar 2017 16:50:06 +0000 (18:50 +0200)]
l10n: de: translate describe debug terms

Signed-off-by: Michael J Gruber <git@grubix.eu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agodescribe: localize debug output fully
Michael J Gruber [Mon, 27 Mar 2017 16:50:05 +0000 (18:50 +0200)]
describe: localize debug output fully

git describe --debug localizes all debug messages but not the terms
head, lightweight, annotated that it outputs for the candidates.
Localize them, too.

Signed-off-by: Michael J Gruber <git@grubix.eu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoEighth batch for 2.13
Junio C Hamano [Mon, 27 Mar 2017 18:00:12 +0000 (11:00 -0700)]
Eighth batch for 2.13

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoMerge branch 'km/config-grammofix'
Junio C Hamano [Mon, 27 Mar 2017 17:59:29 +0000 (10:59 -0700)]
Merge branch 'km/config-grammofix'

Doc update.

* km/config-grammofix:
  doc/config: grammar fixes for core.{editor,commentChar}

9 years agoMerge branch 'sb/t3600-rephrase'
Junio C Hamano [Mon, 27 Mar 2017 17:59:28 +0000 (10:59 -0700)]
Merge branch 'sb/t3600-rephrase'

A test retitling.

* sb/t3600-rephrase:
  t3600: rename test to describe its functionality

9 years agoMerge branch 'sb/describe-broken'
Junio C Hamano [Mon, 27 Mar 2017 17:59:27 +0000 (10:59 -0700)]
Merge branch 'sb/describe-broken'

"git describe --dirty" dies when it cannot be determined if the
state in the working tree matches that of HEAD (e.g. broken
repository or broken submodule).  The command learned a new option
"git describe --broken" to give "$name-broken" (where $name is the
description of HEAD) in such a case.

* sb/describe-broken:
  builtin/describe: introduce --broken flag

9 years agoMerge branch 'sb/push-options-via-transport'
Junio C Hamano [Mon, 27 Mar 2017 17:59:27 +0000 (10:59 -0700)]
Merge branch 'sb/push-options-via-transport'

Recently we started passing the "--push-options" through the
external remote helper interface; now the "smart HTTP" remote
helper understands what to do with the passed information.

* sb/push-options-via-transport:
  remote-curl: allow push options
  send-pack: send push options correctly in stateless-rpc case

9 years agoMerge branch 'km/t1400-modernization'
Junio C Hamano [Mon, 27 Mar 2017 17:59:26 +0000 (10:59 -0700)]
Merge branch 'km/t1400-modernization'

Code clean-up.

* km/t1400-modernization:
  t1400: use test_when_finished for cleanup
  t1400: remove a set of unused output files
  t1400: use test_path_is_* helpers
  t1400: set core.logAllRefUpdates in "logged by touch" tests
  t1400: rename test descriptions to be unique

9 years agoMerge branch 'jk/prefix-filename'
Junio C Hamano [Mon, 27 Mar 2017 17:59:26 +0000 (10:59 -0700)]
Merge branch 'jk/prefix-filename'

Code clean-up with minor bugfixes.

* jk/prefix-filename:
  bundle: use prefix_filename with bundle path
  prefix_filename: simplify windows #ifdef
  prefix_filename: return newly allocated string
  prefix_filename: drop length parameter
  prefix_filename: move docstring to header file
  hash-object: fix buffer reuse with --path in a subdirectory

9 years agoMerge branch 'jc/lint-runaway-here-doc'
Junio C Hamano [Mon, 27 Mar 2017 17:59:25 +0000 (10:59 -0700)]
Merge branch 'jc/lint-runaway-here-doc'

The test framework learned to detect unterminated here documents.

* jc/lint-runaway-here-doc:
  tests: lint for run-away here-doc

9 years agoMerge branch 'st/verify-tag'
Junio C Hamano [Mon, 27 Mar 2017 17:59:22 +0000 (10:59 -0700)]
Merge branch 'st/verify-tag'

A few unterminated here documents in tests were fixed, which in
turn revealed incorrect expectations the tests make. These tests
have been updated.

* st/verify-tag:
  t7004, t7030: fix here-doc syntax errors

9 years agoMerge branch 'sb/submodule-update-initial-runs-custom-script'
Junio C Hamano [Mon, 27 Mar 2017 17:59:21 +0000 (10:59 -0700)]
Merge branch 'sb/submodule-update-initial-runs-custom-script'

A test fix.

* sb/submodule-update-initial-runs-custom-script:
  t7406: correct test case for submodule-update initial population

9 years agoMerge branch 'jk/quote-env-path-list-component'
Junio C Hamano [Mon, 27 Mar 2017 17:59:21 +0000 (10:59 -0700)]
Merge branch 'jk/quote-env-path-list-component'

A test fix.

* jk/quote-env-path-list-component:
  t5615: fix a here-doc syntax error

9 years agorev-parse: match @{upstream}, @{u} and @{push} case-insensitively
Ævar Arnfjörð Bjarmason [Mon, 27 Mar 2017 11:16:55 +0000 (11:16 +0000)]
rev-parse: match @{upstream}, @{u} and @{push} case-insensitively

Change the revision parsing logic to match @{upstream}, @{u} & @{push}
case-insensitively.

Before this change supplying anything except the lower-case forms
emits an "unknown revision or path not in the working tree"
error. This change makes upper-case & mixed-case versions equivalent
to the lower-case versions.

The use-case for this is being able to hold the shift key down while
typing @{u} on certain keyboard layouts, which makes the sequence
easier to type, and reduces cases where git throws an error at the
user where it could do what he means instead.

These suffixes now join various other suffixes & special syntax
documented in gitrevisions(7) that matches case-insensitively. A table
showing the status of the various forms documented there before &
after this patch is shown below. The key for the table is:

 - CI  = Case Insensitive
 - CIP = Case Insensitive Possible (without ambiguities)
 - AG  = Accepts Garbage (.e.g. @{./.4.minutes./.})

Before this change:

    |----------------+-----+------+-----|
    | What?          | CI? | CIP? | AG? |
    |----------------+-----+------+-----|
    | @{<date>}      | Y   | Y    | Y   |
    | @{upstream}    | N   | Y    | N   |
    | @{push}        | N   | Y    | N   |
    |----------------+-----+------+-----|

After it:

    |----------------+-----+------+-----|
    | What?          | CI? | CIP? | AG? |
    |----------------+-----+------+-----|
    | @{<date>}      | Y   | Y    | Y   |
    | @{upstream}    | Y   | Y    | N   |
    | @{push}        | Y   | Y    | N   |
    |----------------+-----+------+-----|

The ^{<type>} suffix is not made case-insensitive, because other
places that take <type> like "cat-file -t <type>" do want them case
sensitively (after all we never declared that type names are case
insensitive). Allowing case-insensitive typename only with this syntax
will make the resulting Git as a whole inconsistent.

This change was independently authored to scratch a longtime itch, but
when I was about to submit it I discovered that a similar patch had
been submitted unsuccessfully before by Conrad Irwin in August 2011 as
"rev-parse: Allow @{U} as a synonym for
@{u}" (<1313287071-7851-1-git-send-email-conrad.irwin@gmail.com>).

The tests for this patch are more exhaustive than in the 2011
submission. The starting point for them was to first change the code
to only support upper-case versions of the existing words, seeing what
broke, and amending the breaking tests to check upper case & mixed
case as appropriate, and where not redundant to other similar
tests. The implementation itself is equivalent.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agorefs: move submodule code out of files-backend.c
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:31 +0000 (09:42 +0700)]
refs: move submodule code out of files-backend.c

files-backend is now initialized with a $GIT_DIR. Converting a submodule
path to where real submodule gitdir is located is done in get_ref_store().

This gives a slight performance improvement for submodules since we
don't convert submodule path to gitdir at every backend call like
before. We pay that once at ref-store creation.

More cleanup in files_downcast() and files_assert_main_repository()
follows shortly. It's separate to keep noises from this patch.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agopath.c: move some code out of strbuf_git_path_submodule()
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:30 +0000 (09:42 +0700)]
path.c: move some code out of strbuf_git_path_submodule()

refs is learning to avoid path rewriting that is done by
strbuf_git_path_submodule(). Factor out this code so it could be reused
by refs_* functions.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agorefs.c: make get_main_ref_store() public and use it
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:29 +0000 (09:42 +0700)]
refs.c: make get_main_ref_store() public and use it

get_ref_store() will soon be renamed to get_submodule_ref_store().
Together with future get_worktree_ref_store(), the three functions
provide an appropriate ref store for different operation modes. New APIs
will be added to operate directly on ref stores.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agorefs.c: kill register_ref_store(), add register_submodule_ref_store()
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:28 +0000 (09:42 +0700)]
refs.c: kill register_ref_store(), add register_submodule_ref_store()

This is the last function in this code (besides public API) that takes
submodule argument and handles both main/submodule cases. Break it down,
move main store registration in get_main_ref_store() and keep the rest
in register_submodule_ref_store().

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agorefs.c: flatten get_ref_store() a bit
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:27 +0000 (09:42 +0700)]
refs.c: flatten get_ref_store() a bit

This helps the future changes in this code. And because get_ref_store()
is destined to become get_submodule_ref_store(), the "get main store"
code path will be removed eventually. After this the patch to delete
that code will be cleaner.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agorefs: rename lookup_ref_store() to lookup_submodule_ref_store()
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:26 +0000 (09:42 +0700)]
refs: rename lookup_ref_store() to lookup_submodule_ref_store()

With get_main_ref_store() being used inside get_ref_store(),
lookup_ref_store() is only used for submodule code path. Rename to
reflect that and delete dead code.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agorefs.c: introduce get_main_ref_store()
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:25 +0000 (09:42 +0700)]
refs.c: introduce get_main_ref_store()

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agofiles-backend: remove the use of git_path()
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:24 +0000 (09:42 +0700)]
files-backend: remove the use of git_path()

Given $GIT_DIR and $GIT_COMMON_DIR, files-backend is now in charge of
deciding what goes where (*). The end goal is to pass $GIT_DIR only. A
refs "view" of a linked worktree is a logical ref store that combines
two files backends together.

(*) Not entirely true since strbuf_git_path_submodule() still does path
translation underneath. But that's for another patch.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agofiles-backend: add and use files_ref_path()
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:23 +0000 (09:42 +0700)]
files-backend: add and use files_ref_path()

Keep repo-related path handling in one place. This will make it easier
to add submodule/multiworktree support later.

This automatically adds the "if submodule then use the submodule version
of git_path" to other call sites too. But it does not mean those
operations are submodule-ready. Not yet.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agofiles-backend: add and use files_reflog_path()
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:22 +0000 (09:42 +0700)]
files-backend: add and use files_reflog_path()

Keep repo-related path handling in one place. This will make it easier
to add submodule/multiworktree support later.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agofiles-backend: move "logs/" out of TMP_RENAMED_LOG
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:21 +0000 (09:42 +0700)]
files-backend: move "logs/" out of TMP_RENAMED_LOG

This makes reflog path building consistent, always in the form of

    strbuf_git_path(sb, "logs/%s", refname);

It reduces the mental workload a bit in the next patch when that
function call is converted.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agofiles-backend: convert git_path() to strbuf_git_path()
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:20 +0000 (09:42 +0700)]
files-backend: convert git_path() to strbuf_git_path()

git_path() and friends are going to be killed in files-backend.c in near
future. And because there's a risk with overwriting buffer in
git_path(), let's convert them all to strbuf_git_path(). We'll have
easier time killing/converting strbuf_git_path() then because we won't
have to worry about memory management again.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agofiles-backend: make sure files_rename_ref() always reach the end
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:19 +0000 (09:42 +0700)]
files-backend: make sure files_rename_ref() always reach the end

This is a no-op patch. It prepares the function so that we can release
resources (to be added later in this function) before we return.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agofiles-backend: add and use files_packed_refs_path()
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:18 +0000 (09:42 +0700)]
files-backend: add and use files_packed_refs_path()

Keep repo-related path handling in one place. This will make it easier
to add submodule/multiworktree support later.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agofiles-backend: delete dead code in files_init_db()
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:17 +0000 (09:42 +0700)]
files-backend: delete dead code in files_init_db()

safe_create_dir() can do adjust_shared_perm() internally, and init-db
has always created 'refs' in shared mode since the beginning,
af6e277c5e (git-init-db: initialize shared repositories with --shared -
2005-12-22). So this code looks like extra adjust_shared_perm calls are
unnecessary.

And they are. But let's see why there are here in the first place.

This code was added in 6fb5acfd8f (refs: add methods to init refs db -
2016-09-04). From the diff alone this looks like a faithful refactored
code from init-db.c. But there is a subtle difference:

Between the safe_create_dir() block and adjust_shared_perm() block in
the old init-db.c, we may copy/recreate directories from the repo
template. So it makes sense that adjust_shared_perm() is re-executed
then to fix potential permission screwups.

After 6fb5acfd8f, refs dirs are created after template is copied. Nobody
will change directory permission again. So the extra adjust_shared_perm()
is redudant. Delete them.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agofiles-backend.c: delete dead code in files_ref_iterator_begin()
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:16 +0000 (09:42 +0700)]
files-backend.c: delete dead code in files_ref_iterator_begin()

It's not in the diff context, but files_downcast() is called before this
check. If "refs" is NULL, we would have segfaulted before reaching the
check here. And we should never see NULL refs in backend code (frontend
should have caught it).

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agofiles-backend: make files_log_ref_write() static
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:15 +0000 (09:42 +0700)]
files-backend: make files_log_ref_write() static

Created in 5f3c3a4e6f (files_log_ref_write: new function - 2015-11-10)
but probably never used outside refs-internal.c

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agosubmodule.c: stricter checking for submodules in is_submodule_modified
Stefan Beller [Sat, 25 Mar 2017 00:36:08 +0000 (17:36 -0700)]
submodule.c: stricter checking for submodules in is_submodule_modified

By having a stricter check in the superproject we catch errors earlier,
instead of spawning a child process to tell us.

Signed-off-by: Stefan Beller <sbeller@google.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agosubmodule.c: port is_submodule_modified to use porcelain 2
Stefan Beller [Sat, 25 Mar 2017 00:36:07 +0000 (17:36 -0700)]
submodule.c: port is_submodule_modified to use porcelain 2

Migrate 'is_submodule_modified' to the new porcelain format of
git-status. This conversion attempts to convert faithfully, i.e.
the behavior ought to be exactly the same.

As the output in the parsing only distinguishes between untracked files
and the rest, this is easy to port to the new format, as we only
need to identify untracked files and the rest is handled in the "else"
case.

untracked files are indicated by only a single question mark instead of
two question marks, so the conversion is easy.

Signed-off-by: Stefan Beller <sbeller@google.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agosubmodule.c: convert is_submodule_modified to use strbuf_getwholeline
Stefan Beller [Sat, 25 Mar 2017 00:36:06 +0000 (17:36 -0700)]
submodule.c: convert is_submodule_modified to use strbuf_getwholeline

Instead of implementing line reading yet again, make use of our beautiful
library function to read one line.  By using strbuf_getwholeline instead
of strbuf_read, we avoid having to allocate memory for the entire child
process output at once.  That is, we limit maximum memory usage.
Also we can start processing the output as it comes in, no need to
wait for all of it.

Once we know all information that we care about, we can terminate
the child early. In that case we do not care about its exit code as well.
By just closing our side of the pipe the child process will get a SIGPIPE
signal, which it will not report nor do we report it in finish_command,
ac78663b0d (run-command: don't warn on SIGPIPE deaths, 2015-12-29).

Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agosubmodule.c: factor out early loop termination in is_submodule_modified
Stefan Beller [Sat, 25 Mar 2017 00:36:05 +0000 (17:36 -0700)]
submodule.c: factor out early loop termination in is_submodule_modified

This makes it easier for a follow up patch.

Signed-off-by: Stefan Beller <sbeller@google.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agosubmodule.c: use argv_array in is_submodule_modified
Stefan Beller [Sat, 25 Mar 2017 00:36:04 +0000 (17:36 -0700)]
submodule.c: use argv_array in is_submodule_modified

struct argv_array is easier to use and maintain.

Signed-off-by: Stefan Beller <sbeller@google.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agobuiltin/pull: convert portions to struct object_id
brian m. carlson [Sun, 26 Mar 2017 16:01:27 +0000 (16:01 +0000)]
builtin/pull: convert portions to struct object_id

Convert the caller of sha1_array_append to struct object_id.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agobuiltin/diff: convert to struct object_id
brian m. carlson [Sun, 26 Mar 2017 16:01:26 +0000 (16:01 +0000)]
builtin/diff: convert to struct object_id

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoConvert GIT_SHA1_RAWSZ used for allocation to GIT_MAX_RAWSZ
brian m. carlson [Sun, 26 Mar 2017 16:01:25 +0000 (16:01 +0000)]
Convert GIT_SHA1_RAWSZ used for allocation to GIT_MAX_RAWSZ

Since we will likely be introducing a new hash function at some point,
and that hash function might be longer than 20 bytes, use the constant
GIT_MAX_RAWSZ, which is designed to be suitable for allocations, instead
of GIT_SHA1_RAWSZ.  This will ease the transition down the line by
distinguishing between places where we need to allocate memory suitable
for the largest hash from those where we need to handle the current
hash.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoConvert GIT_SHA1_HEXSZ used for allocation to GIT_MAX_HEXSZ
brian m. carlson [Sun, 26 Mar 2017 16:01:24 +0000 (16:01 +0000)]
Convert GIT_SHA1_HEXSZ used for allocation to GIT_MAX_HEXSZ

Since we will likely be introducing a new hash function at some point,
and that hash function might be longer than 40 hex characters, use the
constant GIT_MAX_HEXSZ, which is designed to be suitable for
allocations, instead of GIT_SHA1_HEXSZ.  This will ease the transition
down the line by distinguishing between places where we need to allocate
memory suitable for the largest hash from those where we need to handle
the current hash.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoDefine new hash-size constants for allocating memory
brian m. carlson [Sun, 26 Mar 2017 16:01:23 +0000 (16:01 +0000)]
Define new hash-size constants for allocating memory

Since we will want to transition to a new hash at some point in the
future, and that hash may be larger in size than 160 bits, introduce two
constants that can be used for allocating a sufficient amount of memory.
They can be increased to reflect the largest supported hash size.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agostrbuf: support long paths w/o read rights in strbuf_getcwd() on FreeBSD
René Scharfe [Sun, 26 Mar 2017 13:43:50 +0000 (15:43 +0200)]
strbuf: support long paths w/o read rights in strbuf_getcwd() on FreeBSD

FreeBSD implements getcwd(3) as a syscall, but falls back to a version
based on readdir(3) if it fails for some reason.  The latter requires
permissions to read and execute path components, while the former does
not.  That means that if our buffer is too small and we're missing
rights we could get EACCES, but we may succeed with a bigger buffer.

Keep retrying if getcwd(3) indicates lack of permissions until our
buffer can fit PATH_MAX bytes, as that's the maximum supported by the
syscall on FreeBSD anyway.  This way we do what we can to be able to
benefit from the syscall, but we also won't loop forever if there is a
real permission issue.

This fixes a regression introduced with 7333ed17 (setup: convert
setup_git_directory_gently_1 et al. to strbuf, 2014-07-28) for paths
longer than 127 bytes with components that miss read or execute
permissions (e.g. 0711 on /home for privacy reasons); we used a fixed
PATH_MAX-sized buffer before.

Reported-by: Zenobiusz Kunegunda <zenobiusz.kunegunda@interia.pl>
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agodoc/SubmittingPatches: show how to get a CLI commit summary
Ævar Arnfjörð Bjarmason [Tue, 21 Mar 2017 14:21:54 +0000 (14:21 +0000)]
doc/SubmittingPatches: show how to get a CLI commit summary

Amend the section which describes how to get a commit summary to show
how do to that with "git show", currently the documentation only shows
how to do that with gitk.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>