read-cache: mark cache_entry pointers const

ie_match_stat and ie_modified only derefence their struct cache_entry
pointers for reading.  Add const to the parameter declaration here and
do the same for the static helper function used by them, as it's the
same there as well.  This allows callers to pass in const pointers.

Signed-off-by: René Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
unpack-trees: factor out dup_entry

While we're add it, mark the struct cache_entry pointer of add_entry
const because we only read from it and this allows callers to pass in
const pointers.

Signed-off-by: René Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
unpack-trees: create working copy of merge entry in merged_entry

Duplicate the merge entry right away and work with that instead of
modifying the entry we got and duplicating it only at the end of
the function.  Then mark that pointer const to document that we
don't modify the referenced cache_entry.

This change is safe because all existing merge functions call
merged_entry just before returning (or not at all), i.e. they don't
care about changes to the referenced cache_entry after the call.
unpack_nondirectories and unpack_index_entry, which call the merge
functions through call_unpack_fn, aren't interested in such changes
neither.

The change complicates merged_entry a bit because we have to free the
copy if we error out, but allows callers to pass a const pointer.

Signed-off-by: René Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff-lib, read-tree, unpack-trees: mark cache_entry pointers const

Add const to struct cache_entry pointers throughout the tree which are
only used for reading.  This allows callers to pass in const pointers.

Signed-off-by: René Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff-lib, read-tree, unpack-trees: mark cache_entry array paramters const

Change the type merge_fn_t to accept the array of cache_entry pointers
as const pointers to const pointers.  This documents the fact that the
merge functions don't modify the cache_entry contents or replace any of
the pointers in the array.

Only a single cast is necessary in unpack_nondirectories because adding
two const modifiers at once is not allowed in C.  The cast is safe in
that it doesn't mask any modfication; call_unpack_fn only needs the
array for reading.

Signed-off-by: René Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
unpack-trees: free cache_entry array members for merges

The merge functions duplicate entries as needed and they don't free
them.  Release them in unpack_nondirectories, the same function
where they were allocated, after we're done.

As suggested by Felipe, use the same loop style (zero-based for loop)
for freeing as for allocating.

Improved-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: René Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib: remove continuous/ and patches/

They haven't been touched in six years.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Merge branch 'fc/zsh-leftover-bits'

* fc/zsh-leftover-bits:
  completion: zsh: improve bash script loading
  completion: synchronize zsh wrapper
  completion: cleanup zsh wrapper
Merge branch 'fc/completion'

* fc/completion:
  completion: remove __git_index_file_list_filter()
  completion: add space after completed filename
  completion: add hack to enable file mode in bash < 4
  completion: refactor __git_complete_index_file()
  completion: refactor diff_index wrappers
  completion: use __gitcompadd for __gitcomp_file
  completion; remove unuseful comments
  completion: document tilde expansion failure in tests
  completion: add file completion tests
Merge branch 'an/diff-index-doc'

* an/diff-index-doc:
  Documentation/diff-index: mention two modes of operation
Merge branch 'rh/merge-options-doc-fix'

* rh/merge-options-doc-fix:
  Documentation/merge-options.txt: restore `-e` option
Merge branch 'rs/empty-archive'

Fixes tests added in 1.8.2 era that are broken on BSDs.

* rs/empty-archive:
  t5004: resurrect original empty tar archive test
  t5004: avoid using tar for checking emptiness of archive
Merge branch 'fc/fast-export-persistent-marks'

Optimization for fast-export by avoiding unnecessarily resolving
arbitrary object name and parsing object when only presence and
type information is necessary, etc.

* fc/fast-export-persistent-marks:
  fast-{import,export}: use get_sha1_hex() to read from marks file
  fast-export: don't parse commits while reading marks file
  fast-export: do not parse non-commit objects while reading marks file
Merge branch 'nd/clone-local-with-colon'

"git clone foo/bar:baz" cannot be a request to clone from a remote
over git-over-ssh specified in the scp style.  Detect this case and
clone from a local repository at "foo/bar:baz".

* nd/clone-local-with-colon:
  clone: allow cloning local paths with colons in them
Merge branch 'vv/help-unknown-ref'

Detect "git merge foo" that might have meant "git merge origin/foo"
and give an error message that is more specific than "foo is not
something we can merge".

* vv/help-unknown-ref:
  merge: use help_unknown_ref()
  help: add help_unknown_ref()
Merge branch 'fc/macos-x-clipped-write'

Mac OS X does not like to write(2) more than INT_MAX number of
bytes.

* fc/macos-x-clipped-write:
  compate/clipped-write.c: large write(2) fails on Mac OS X/XNU
Merge branch 'da/darwin'

Newer MacOS X encourages the programs to compile and link with
their CommonCrypto, not with OpenSSL.

* da/darwin:
  imap-send: eliminate HMAC deprecation warnings on Mac OS X
  cache.h: eliminate SHA-1 deprecation warnings on Mac OS X
  Makefile: add support for Apple CommonCrypto facility
  Makefile: fix default regex settings on Darwin
Merge branch 'jc/t5551-posix-sed-bre'

POSIX fix for a test script.

* jc/t5551-posix-sed-bre:
  t5551: do not use unportable sed '\+'
Merge branch 'kb/ancestry-path-threedots'

"git log --ancestry-path A...B" did not work as expected, as it did
not pay attention to the fact that the merge base between A and B
was the bottom of the range being specified.

* kb/ancestry-path-threedots:
  revision.c: treat A...B merge bases as if manually specified
  t6019: demonstrate --ancestry-path A...B breakage
Merge branch 'mk/combine-diff-context-horizon-fix'

"git diff -c -p" was not showing a deleted line from a hunk when
another hunk immediately begins where the earlier one ends.

* mk/combine-diff-context-horizon-fix:
  combine-diff.c: Fix output when changes are exactly 3 lines apart